Revize c670fa2f
Přidáno uživatelem Jan Havlíček před asi 4 roky(ů)
project/Deserializer/src/Converter.java | ||
---|---|---|
90 | 90 |
continue; |
91 | 91 |
} |
92 | 92 |
|
93 |
StringBuilder html = new StringBuilder(); |
|
94 | 93 |
StringBuilder json = new StringBuilder(); |
95 | 94 |
|
96 | 95 |
boolean error = false; |
... | ... | |
99 | 98 |
System.setOut(FileWorker.createRedirectStream(false)); |
100 | 99 |
System.setErr(FileWorker.createRedirectStream(true)); |
101 | 100 |
System.out.println("--- jdeserialize begins ---".toUpperCase()); |
102 |
convert(array, html, json);
|
|
101 |
convert(array, json); |
|
103 | 102 |
} catch (Exception e) { |
104 | 103 |
e.printStackTrace(); |
105 | 104 |
error = true; |
... | ... | |
110 | 109 |
System.setErr(new PrintStream(new FileOutputStream(FileDescriptor.err))); |
111 | 110 |
System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); |
112 | 111 |
} |
113 |
|
|
114 |
//test file output |
|
115 |
try { |
|
116 |
BufferedWriter writer = new BufferedWriter(new FileWriter("html.txt")); |
|
117 |
writer.write(html.toString().replace("<br/>", "\n")); // TODO pridan replace pro odsazovani - lepsi orientace v souboru. |
|
118 |
writer.close(); |
|
119 |
|
|
120 |
BufferedWriter writer2 = new BufferedWriter(new FileWriter("json.txt")); |
|
121 |
writer2.write(json.toString()); |
|
122 |
writer2.close(); |
|
123 |
} catch (IOException e) { |
|
124 |
// TODO Auto-generated catch block |
|
125 |
e.printStackTrace(); |
|
126 |
} |
|
127 |
//test file output |
|
128 | 112 |
|
129 |
ui.completed(error ? null : html.toString(), error ? null : json.toString(), array == null ? null : new String(array));
|
|
113 |
ui.completed(error ? null : json.toString(), array == null ? null : new String(array)); |
|
130 | 114 |
} |
131 | 115 |
} |
132 | 116 |
|
... | ... | |
141 | 125 |
return array; |
142 | 126 |
} |
143 | 127 |
|
144 |
private void convert(byte[] buffer, StringBuilder html, StringBuilder json) throws Exception {
|
|
128 |
private void convert(byte[] buffer, StringBuilder json) throws Exception { |
|
145 | 129 |
jdeserialize deserializer = new jdeserialize(buffer); |
146 | 130 |
|
147 | 131 |
// gets the "contents" into an array - returnes the deserialization of all |
... | ... | |
151 | 135 |
for (content cnt : cntnts) { |
152 | 136 |
if (cnt != null) { |
153 | 137 |
json.append(cnt.toJson("", null, false)).append("\n"); |
154 |
html.append(cnt.toJson("", null, false)); |
|
155 | 138 |
} |
156 | 139 |
} |
157 | 140 |
} |
Také k dispozici: Unified diff
re #7963 DB communication repaired, tested.
html structures removed