1
2
3
4
5
6 package hoplugins.conv;
7
8 import org.w3c.dom.Document;
9
10 import java.io.File;
11
12 import javax.swing.JOptionPane;
13
14
15 /***
16 * DOCUMENT ME!
17 *
18 * @author Thorsten Dietz
19 */
20 public class HTForever extends HrfMaker {
21
22
23 /***
24 * Creates a new HTForever object.
25 */
26 protected HTForever() {
27 type = "HTF";
28 }
29
30
31
32 /***
33 * TODO Missing Method Documentation
34 *
35 * @param selectedFiles TODO Missing Method Parameter Documentation
36 * @param targetDir TODO Missing Method Parameter Documentation
37 */
38 protected void start(File[] selectedFiles, File targetDir) {
39 try {
40 String[] filter = null;
41 File[][] xmls = null;
42
43 filter = getName(selectedFiles);
44 xmls = getFiles(filter, selectedFiles);
45
46 for (int i = 0; i < xmls.length; i++) {
47 if ((xmls[i][0] == null)
48 || (xmls[i][1] == null)
49 || (xmls[i][2] == null)
50 || (xmls[i][3] == null)
51 || (xmls[i][4] == null)
52 || (xmls[i][5] == null)
53 || (xmls[i][6] == null)) {
54 handleException(null,
55 RSC.PROP_FILE_NOT_FOUND + " :" + filter[i]
56 + RSC.HTFOREVER_EXTENSION[i]);
57 return;
58 }
59 }
60
61 if (targetDir != null) {
62 Document doc = null;
63
64 for (int i = 0; i < xmls.length; i++) {
65 clearArrays();
66
67 addBasics();
68 doc = getDocument(xmls[i][1]);
69 analyzeClub(doc.getDocumentElement().getChildNodes());
70
71 doc = getDocument(xmls[i][0]);
72 analyzeArena(doc.getDocumentElement().getChildNodes());
73
74 doc = getDocument(xmls[i][5]);
75 analyzeTraining(doc.getDocumentElement().getChildNodes());
76
77 doc = getDocument(xmls[i][2]);
78 analyzeEconomy(doc.getDocumentElement().getChildNodes());
79
80 doc = getDocument(xmls[i][4]);
81 analyzeTeamDetails(doc.getDocumentElement().getChildNodes());
82
83 doc = getDocument(xmls[i][3]);
84 initPlayersArray(doc.getDocumentElement().getChildNodes());
85
86
87 doc = getDocument(xmls[i][6]);
88 analyzeWorldDetail(doc.getDocumentElement().getChildNodes());
89 filter[i] = filter[i].replaceAll("-", "");
90 writeHrf(filter[i], targetDir);
91 }
92 }
93
94
95 JOptionPane.showMessageDialog(null, RSC.getProperty("finished"));
96 } catch (Exception e1) {
97 handleException(e1, RSC.PROP_DEFAULT_ERROR_MESSAGE);
98 }
99 }
100
101 /***
102 * TODO Missing Method Documentation
103 *
104 * @param f TODO Missing Method Parameter Documentation
105 *
106 * @return TODO Missing Return Method Documentation
107 */
108 private static String[] getName(File[] f) {
109 String[] names = new String[f.length];
110
111 for (int i = 0; i < names.length; i++) {
112 names[i] = f[i].getName().substring(0, 10);
113 }
114
115 return names;
116 }
117
118 /***
119 * TODO Missing Method Documentation
120 *
121 * @param filter TODO Missing Method Parameter Documentation
122 * @param selectedFiles TODO Missing Method Parameter Documentation
123 *
124 * @return TODO Missing Return Method Documentation
125 */
126 private File[][] getFiles(String[] filter, File[] selectedFiles) {
127 File[][] xmls = new File[selectedFiles.length][9];
128 File[] tmp = new File[0];
129
130 File dir = selectedFiles[0].getParentFile();
131 tmp = dir.listFiles();
132
133 for (int i = 0; i < selectedFiles.length; i++) {
134 for (int j = 0; j < tmp.length; j++) {
135 if (tmp[j].getName().equals(filter[i] + RSC.HTFOREVER_EXTENSION[0])) {
136 xmls[i][0] = tmp[j];
137 }
138
139 if (tmp[j].getName().equals(filter[i] + RSC.HTFOREVER_EXTENSION[1])) {
140 xmls[i][1] = tmp[j];
141 }
142
143 if (tmp[j].getName().equals(filter[i] + RSC.HTFOREVER_EXTENSION[2])) {
144 xmls[i][2] = tmp[j];
145 }
146
147 if (tmp[j].getName().equals(filter[i] + RSC.HTFOREVER_EXTENSION[3])) {
148 xmls[i][3] = tmp[j];
149 }
150
151 if (tmp[j].getName().equals(filter[i] + RSC.HTFOREVER_EXTENSION[4])) {
152 xmls[i][4] = tmp[j];
153 }
154
155 if (tmp[j].getName().equals(filter[i] + RSC.HTFOREVER_EXTENSION[5])) {
156 xmls[i][5] = tmp[j];
157 }
158
159 if (tmp[j].getName().equals(filter[i] + RSC.HTFOREVER_EXTENSION[6])) {
160 xmls[i][6] = tmp[j];
161 }
162
163 if (tmp[j].getName().equals(filter[i] + RSC.HTFOREVER_EXTENSION[7])) {
164 xmls[i][7] = tmp[j];
165 }
166
167 if (tmp[j].getName().equals(filter[i] + RSC.HTFOREVER_EXTENSION[8])) {
168 xmls[i][8] = tmp[j];
169 }
170 }
171 }
172
173 return xmls;
174 }
175 }