Permalink
Browse files

changes during exam

  • Loading branch information...
angryziber committed May 31, 2011
1 parent 2f55fef commit 7b545e1aa80156f79711f01cf2827b7da6d0a738
View
@@ -6,6 +6,7 @@
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="IdProvider" IDEtalkID="5CF13FE4B2F72E19A1B2617B169B21C1" />
<component name="JavadocGenerationManager">
<option name="OUTPUT_DIRECTORY" />
<option name="OPTION_SCOPE" value="protected" />
@@ -63,5 +64,6 @@
</option>
<option name="mySupportsUserInfoFilter" value="true" />
</component>
<component name="WebServicesPlugin" addRequiredLibraries="true" />
</project>
View
Binary file not shown.
@@ -7,30 +7,30 @@
* @author t092855
*/
public enum Error {
ERROR_NUMBER_FORMAT ("Error: number format is wrong."),
ERROR_FILE_NOT_FOUND ("Error: file not found."),
ERROR_FILE_WRONG_ENCODING("Error: file wrong encoding. Must be UTF-8 without BOM."),
ERROR_FILE_CLOSING_FAILED("Error: file closing failed."),
ERROR_FILE_READ("Error: file reading failed."),
ERROR_CSV_READ_LINE_FAILED("Error: CSV data reading failed."),
ERROR_RESULT_MISSING("Error: CSV data error, probable cause: result missing."),
ERROR_OUT_FILE_NO_NAME("Error: output file name is empty."),
ERROR_CSV_FILE("Error: can't create output file."),
ERROR_CSV_FILE_WRITE("Error: can't write to output file."),
ERROR_DB_PROPERTIES_FILE_NOT_FOUND("Error: database properties file not found."),
ERROR_DB_PROPERTIES_READ("Error: can't read from database properties file."),
ERROR_DB_FILE_CLOSE("Error: database file close failed."),
ERROR_DB_CONNECTION("Error: can't access database."),
ERROR_DB_CLOSE("Error: can't close database."),
ERROR_DB_ATHLETE_NOT_FOUND("Error: can't find specified athlete in database."),
ERROR_DB_ATHLETE_PARSING_FAILED("Error: athlete parsing failed from database."),
ERROR_DB_ATHLETE_RESULTS_PARSING_FAILED("Error: athlete results parsing failed from database."),
ERROR_XML_CREATION_FAILED("Error: XML creation failed."),
ERROR_HTML_CREATION_FAILED("Error: HTML creation failed."),
ERROR_XSL_CLOSING_FAILED("Error: XSL file closing failed."),
ERROR_INPUT_PARAMETERS_INCORRECT("Error: input parameters are incorrect."),
ERROR_OUTPUT_PARAMETERS_INCORRECT("Error: output parameters are incorrect."),
ERROR_IO_PARAMETERS_INCORRECT("Error: input/output parameters are incorrect.");
ERROR_NUMBER_FORMAT ("number format is wrong."),
ERROR_FILE_NOT_FOUND ("file not found."),
ERROR_FILE_WRONG_ENCODING("file wrong encoding. Must be UTF-8 without BOM."),
ERROR_FILE_CLOSING_FAILED("file closing failed."),
ERROR_FILE_READ("file reading failed."),
ERROR_CSV_READ_LINE_FAILED("CSV data reading failed."),
ERROR_RESULT_MISSING("CSV data error, probable cause: result missing."),
ERROR_OUT_FILE_NO_NAME("output file name is empty."),
ERROR_CSV_FILE("can't create output file."),
ERROR_CSV_FILE_WRITE("can't write to output file."),
ERROR_DB_PROPERTIES_FILE_NOT_FOUND("database properties file not found."),
ERROR_DB_PROPERTIES_READ("can't read from database properties file."),
ERROR_DB_FILE_CLOSE("database file close failed."),
ERROR_DB_CONNECTION("can't access database."),
ERROR_DB_CLOSE("can't close database."),
ERROR_DB_ATHLETE_NOT_FOUND("can't find specified athlete in database."),
ERROR_DB_ATHLETE_PARSING_FAILED("athlete parsing failed from database."),
ERROR_DB_ATHLETE_RESULTS_PARSING_FAILED("athlete results parsing failed from database."),
ERROR_XML_CREATION_FAILED("XML creation failed."),
ERROR_HTML_CREATION_FAILED("HTML creation failed."),
ERROR_XSL_CLOSING_FAILED("XSL file closing failed."),
ERROR_INPUT_PARAMETERS_INCORRECT("input parameters are incorrect."),
ERROR_OUTPUT_PARAMETERS_INCORRECT("output parameters are incorrect."),
ERROR_IO_PARAMETERS_INCORRECT("input/output parameters are incorrect.");
private final String errorText;
@@ -39,7 +39,7 @@
*/
public List<Athlete> readAthleteFromDB() throws SQLException, ParseException, IOException {
int i = 0;
BufferedReader reader = new BufferedReader(new FileReader("src\\net\\azib\\java\\students\\t103784\\homework\\db.properties"));
BufferedReader reader = new BufferedReader(new FileReader("src/net/azib/java/students/t103784/homework/db.properties"));
String connAddress = reader.readLine();
String connUserPass = reader.readLine();
Connection conn = DriverManager.getConnection(connAddress, connUserPass, connUserPass);
@@ -141,7 +141,7 @@
tokenizer = new StringTokenizer(line.trim(), ",");
while (tokenizer.hasMoreTokens()) {
athlete.setName(checkName(tokenizer.nextToken().trim()));
athlete.setBirthDate(checkDate(tokenizer.nextToken().trim()));
athlete.setBirthDate(tokenizer.nextToken().trim());
athlete.setCountry(checkCountry(tokenizer.nextToken().trim()));
for (int c = 0; c < 10; c++) {
if (c == 4 || c == 9) {
@@ -2,6 +2,9 @@
import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
@@ -10,10 +13,6 @@
import java.text.ParseException;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
/**
* The main class.
*
@@ -88,7 +87,7 @@ public static void main(String[] args) throws IOException {
if (inputParameter != null) {
file = new File(inputParameter);
} else {
file = new File("src\\net\\azib\\java\\students\\t103784\\homework\\tmp\\sample.csv");
file = new File("src/net/azib/java/students/t103784/homework/tmp/sample.csv");
}
reader = new BufferedReader(new FileReader(file));
contestants = input.readAthleteFromCSV(reader);
@@ -1,18 +1,23 @@
package net.azib.java.students.t103784.homework;
import java.io.*;
import java.util.List;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.*;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.List;
/**
* This class is used to output the athletes and their results.
@@ -69,7 +74,7 @@ public void outputToCSV(List<Athlete> contestants) throws FileNotFoundException
(parameter)));
} else {
out = new PrintStream((new FileOutputStream
("src\\net\\azib\\java\\students\\t103784\\homework\\tmp\\sampleOutput.csv")));
("src/net/azib/java/students/t103784/homework/tmp/sampleOutput.csv")));
}
for (Athlete athlete : contestants) {
out.print(athlete.getPlace() + ",");
@@ -114,22 +119,22 @@ public void outputToHTML(List<Athlete> contestants) throws TransformerException,
newInstance();
Transformer transformer = tFactory.
newTransformer(new javax.xml.transform.stream.StreamSource
("src\\net\\azib\\java\\students\\t103784\\homework\\decathlonHTML.xsl"));
("src/net/azib/java/students/t103784/homework/decathlonHTML.xsl"));
if (parameter != null && parameter.contains(".html")) {
transformer.transform
(new javax.xml.transform.
stream.StreamSource("src\\net\\azib\\java\\students\\t103784\\homework\\tmp\\temp.xml"),
stream.StreamSource("src/net/azib/java/students/t103784/homework/tmp/temp.xml"),
new javax.xml.transform.
stream.StreamResult(new FileOutputStream
(parameter)));
} else {
transformer.transform
(new javax.xml.transform.
stream.StreamSource("src\\net\\azib\\java\\students\\t103784\\homework\\tmp\\temp.xml"),
stream.StreamSource("src/net/azib/java/students/t103784/homework/tmp/temp.xml"),
new javax.xml.transform.
stream.StreamResult(new FileOutputStream
("src\\net\\azib\\java\\students\\t103784\\homework\\tmp\\temp.html")));
("src/net/azib/java/students/t103784/homework/tmp/temp.html")));
}
} catch (Exception e) {
e.printStackTrace();
@@ -273,9 +278,10 @@ public void outputToXML(List<Athlete> contestants) throws IOException,
if (parameter != null && parameter.contains(".xml")) {
transformer.transform
(new DOMSource(results), new StreamResult(parameter));
System.out.println();
} else {
transformer.transform
(new DOMSource(results), new StreamResult("src\\net\\azib\\java\\students\\t103784\\homework\\tmp\\temp.xml"));
(new DOMSource(results), new StreamResult("src/net/azib/java/students/t103784/homework/tmp/temp.xml"));
}
}
}
@@ -1,80 +1,5 @@
Name: Ültimäte Äthlétö
Date of Birth: 11.06.1991
Country: EE
100 meter dash(s): 10.395
Long jump(m): 7.76
Shot Put(m): 18.4
High jump(m): 2.2
400 meter race(s): 46.17
110 meter hurdles(s): 13.8
Discus throw(m): 56.17
Pole vault(m): 5.28
Javelin throw(m): 77.19
1500 meter race(s): 233.79
Score: 9990
Place: 1
Name: "Siim Susi"
Date of Birth: 01.01.1976
Country: EE
100 meter dash(s): 12.61
Long jump(m): 5.0
Shot Put(m): 9.22
High jump(m): 1.5
400 meter race(s): 59.39
110 meter hurdles(s): 16.43
Discus throw(m): 21.6
Pole vault(m): 2.6
Javelin throw(m): 35.81
1500 meter race(s): 325.72
Score: 4234
Place: 2
Name: "José Mañana Perez"
Date of Birth: 3.04.1972
Country: ES
100 meter dash(s): 13.75
Long jump(m): 4.84
Shot Put(m): 10.12
High jump(m): 1.5
400 meter race(s): 68.44
110 meter hurdles(s): 19.18
Discus throw(m): 30.85
Pole vault(m): 2.8
Javelin throw(m): 33.88
1500 meter race(s): 382.75
Score: 3494
Place: 3
Name: "Beata Kana"
Date of Birth: 28.02.1982
Country: ZA
100 meter dash(s): 13.04
Long jump(m): 4.53
Shot Put(m): 7.79
High jump(m): 1.55
400 meter race(s): 64.72
110 meter hurdles(s): 18.74
Discus throw(m): 24.2
Pole vault(m): 2.4
Javelin throw(m): 28.2
1500 meter race(s): 410.76
Score: 3199
Place: 4
Name: "Василий Пупкин"
Date of Birth: 21.10.1980
Country: UA
100 meter dash(s): 13.43
Long jump(m): 4.35
Shot Put(m): 8.64
High jump(m): 1.5
400 meter race(s): 66.06
110 meter hurdles(s): 19.05
Discus throw(m): 24.89
Pole vault(m): 2.2
Javelin throw(m): 33.48
1500 meter race(s): 411.01
Score: 3099
Place: 5
Full name (Name Surname): Date of Birth (dd/MM/yy): Country (2-digits, eg. EE): 100m (seconds.milliseconds): Long jump (meters.centimeters): Shot put (meters.centimeters): High jump (meters.centimeters): 400m (minutes:seconds.milliseconds): 110m hurdles (seconds.milliseconds): Discus throw (meters.centimeters): Pole vault (meters.centimeters): Javelin throw (meters.centimeters): 1500m race (minutes:seconds.milliseconds): Add more athletes (y/n)? Test success for athlete 0 : 59361
Test success for athlete 1 : 59361
Test success for athlete 2 : 28224
Test success for athlete 3 : 28224
Test success for athlete 4 : 28224
@@ -1,5 +1,5 @@
�ltim�te �thl�t�
11.06.1991
11/06/1991
EE
10.395
7.76
@@ -11,4 +11,4 @@ EE
5.28
77.19
3:53.79
n
n
@@ -1,5 +1,5 @@
"Siim Susi",01.01.1976,EE,12.61,5.00,9.22,1.50,59.39,16.43,21.60,2.60,35.81,5:25.72
"Beata Kana",28.02.1982,ZA,13.04,4.53,7.79,1.55,1:04.72,18.74,24.20,2.40,28.20,6:50.76
"Beata Kana",27.02.1982,ZA,13.04,4.53,7.79,1.55,1:04.72,18.74,24.20,2.40,28.20,6:50.76
"José Mañana Perez",3.04.1972,ES,13.75,4.84,10.12,1.50,1:08.44,19.18,30.85,2.80,33.88,6:22.75
"Василий Пупкин",21.10.1980,UA,13.43,4.35,8.64,1.50,1:06.06,19.05,24.89,2.20,33.48,6:51.01
Ültimäte Äthlétö,11.06.1991,EE,10.395,7.76,18.4,2.20,46.17,13.8,56.17,5.28,77.19,3:53.79
@@ -1,56 +1,8 @@
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<body>
<table border="1">
<td><b>Place</b></td>
<td><b>Name</b></td>
<td><b>Date of Birth</b></td>
<td><b>Country</b></td>
<td><b>100m</b></td>
<td><b>Long Jump</b></td>
<td><b>Shot Put</b></td>
<td><b>High Jump</b></td>
<td><b>400m</b></td>
<td><b>110m Hurdles</b></td>
<td><b>Discus Throw</b></td>
<td><b>Pole Vault</b></td>
<td><b>Javelin Throw</b></td>
<td><b>1500m</b></td>
<td><b>SCORE</b></td>
<tr>
<td><b>1</b></td>
<td><b>Erki Nool</b></td>
<td><b>1970-06-25</b></td>
<td><b>EE</b></td>
<td><b>10.94</b></td>
<td><b>7.83</b></td>
<td><b>12.48</b></td>
<td><b>2.0</b></td>
<td><b>49.72</b></td>
<td><b>15.67</b></td>
<td><b>38.3</b></td>
<td><b>5.4</b></td>
<td><b>55.84</b></td>
<td><b>271.72</b></td>
<td><b>8001</b></td>
</tr>
<tr>
<td><b>2</b></td>
<td><b>Siim Susi</b></td>
<td><b>1976-01-01</b></td>
<td><b>EE</b></td>
<td><b>14.15</b></td>
<td><b>3.98</b></td>
<td><b>10.0</b></td>
<td><b>1.45</b></td>
<td><b>70.12</b></td>
<td><b>18.65</b></td>
<td><b>29.15</b></td>
<td><b>2.15</b></td>
<td><b>32.67</b></td>
<td><b>466.6</b></td>
<td><b>2889</b></td>
</tr>
</table>
</body>
</html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<body>
<table border="1">
<td><b>Place</b></td><td><b>Name</b></td><td><b>Date of Birth</b></td><td><b>Country</b></td><td><b>100m</b></td><td><b>Long Jump</b></td><td><b>Shot Put</b></td><td><b>High Jump</b></td><td><b>400m</b></td><td><b>110m Hurdles</b></td><td><b>Discus Throw</b></td><td><b>Pole Vault</b></td><td><b>Javelin Throw</b></td><td><b>1500m</b></td><td><b>SCORE</b></td>
</table>
</body>
</html>
Oops, something went wrong.

0 comments on commit 7b545e1

Please sign in to comment.