Revize a5d16f0a
Přidáno uživatelem Michal Horký před asi 4 roky(ů)
project/Deserializer/src/CLI.java | ||
---|---|---|
48 | 48 |
} |
49 | 49 |
} |
50 | 50 |
|
51 |
|
|
52 |
|
|
51 | 53 |
private static HashMap<Option, Runnable> options; |
52 | 54 |
private static boolean printJSON; |
53 | 55 |
private static File outputFile; |
... | ... | |
60 | 62 |
options.put(new Option("-help", "Print this help message."), () -> { |
61 | 63 |
help(); |
62 | 64 |
}); |
63 |
options.put(new Option("-print", "Text..."), () -> {
|
|
65 |
options.put(new Option("-print", "Prints the resulting json to the console."), () -> {
|
|
64 | 66 |
setPrintJSON(); |
65 | 67 |
}); |
66 | 68 |
printJSON = false; |
67 | 69 |
} |
68 | 70 |
|
69 |
private static String printOptions() { |
|
70 |
String result = ""; |
|
71 |
for (Option option : options.keySet()) { |
|
72 |
result += " " + option + "\n"; |
|
73 |
} |
|
74 |
return result; |
|
75 |
} |
|
76 |
|
|
77 | 71 |
private static void help() { |
78 | 72 |
System.out.println("\n" |
79 | 73 |
+ "Usage:" + "\n" |
... | ... | |
99 | 93 |
private static void setPrintJSON() { |
100 | 94 |
printJSON = true; |
101 | 95 |
} |
96 |
|
|
97 |
private static String printOptions() { |
|
98 |
String result = ""; |
|
99 |
for (Option option : options.keySet()) { |
|
100 |
result += " " + option + "\n"; |
|
101 |
} |
|
102 |
return result; |
|
103 |
} |
|
102 | 104 |
|
105 |
|
|
106 |
|
|
103 | 107 |
public static void main(String[] args) { |
104 | 108 |
if (args.length == 0) { |
105 | 109 |
Application.launch(Deserializer.class, args); |
... | ... | |
139 | 143 |
|
140 | 144 |
Converter thread = new Converter(new CLI()); |
141 | 145 |
thread.start(); |
142 |
thread.setInput(inputFile); |
|
146 |
thread.setInput(inputFile, null, false); // The data in the clipboard is not tested here. |
|
147 |
try { |
|
148 |
Thread.sleep(1000); |
|
149 |
} catch (InterruptedException e) { |
|
150 |
errorMessage("interrupted sleep of the main thread"); |
|
151 |
} |
|
143 | 152 |
thread.end(); |
144 | 153 |
try { |
145 | 154 |
thread.join(); |
... | ... | |
153 | 162 |
System.out.println("\nERROR: " + message.toUpperCase() + "!\n"); |
154 | 163 |
} |
155 | 164 |
|
165 |
|
|
166 |
|
|
156 | 167 |
@Override |
157 | 168 |
public void loadingInputFileError() { |
158 |
System.out.println("There was an error loading the file.");
|
|
169 |
errorMessage("there was an error loading the file");
|
|
159 | 170 |
} |
160 | 171 |
|
161 | 172 |
@Override |
162 |
public void completed(String json) {
|
|
163 |
if (json != null) { |
|
173 |
public void completed(String html, String json, boolean testing) {
|
|
174 |
if (json != null && json.length() > 0) {
|
|
164 | 175 |
System.out.println("Deserialization completed."); |
165 | 176 |
saveJson(json); |
166 | 177 |
} else { |
167 |
System.out.println("An error occurred while deserializing!");
|
|
178 |
errorMessage("an error occurred while deserializing");
|
|
168 | 179 |
} |
169 | 180 |
} |
170 | 181 |
|
... | ... | |
174 | 185 |
FileWorker.saveJson(outputFile, json); |
175 | 186 |
System.out.println("The JSON file was saved correctly."); |
176 | 187 |
} catch (IOException e) { |
177 |
System.out.println("There was an error saving the JSON file.");
|
|
188 |
errorMessage("there was an error saving the JSON file.");
|
|
178 | 189 |
} |
179 | 190 |
} else { |
180 | 191 |
// Options contain -print. |
Také k dispozici: Unified diff
re #7879 release v0.2
release v0.2