Revize 92733e3a
Přidáno uživatelem Michal Horký před více než 4 roky(ů)
demo_jh/Deserializer_tests/src/app/App.java | ||
---|---|---|
6 | 6 |
import java.io.IOException; |
7 | 7 |
import java.io.ObjectInputStream; |
8 | 8 |
import java.io.ObjectOutputStream; |
9 |
import java.util.ArrayList; |
|
10 | 9 |
import java.util.List; |
11 | 10 |
import org.codehaus.jackson.map.ObjectMapper; |
12 | 11 |
import org.codehaus.jackson.map.ObjectWriter; |
demo_jh/Deserializer_tests/src/samples/ok/Simple.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.Serializable; |
4 | 4 |
|
5 |
public class Simple implements Serializable |
|
5 |
public class Simple extends SimpleChild implements Serializable
|
|
6 | 6 |
{ |
7 | 7 |
enum Level { |
8 | 8 |
LOW, |
demo_jh/Deserializer_tests/src/samples/ok/SimpleChild.java | ||
---|---|---|
1 | 1 |
package samples.ok; |
2 | 2 |
|
3 |
public class SimpleChild extends Simple { |
|
3 |
import java.io.Serializable; |
|
4 |
|
|
5 |
public class SimpleChild implements Serializable { |
|
4 | 6 |
String navic = "AHOJ, jsem tu navic"; |
5 | 7 |
} |
project/Deserializer/bcha.json | ||
---|---|---|
1 | 1 |
{ |
2 |
class samples.ok.SimpleChild extends samples.ok.Simple : { |
|
3 |
"navic" : "AHOJ, jsem tu navic" |
|
4 |
}, |
|
2 |
class samples.ok.Simple extends samples.ok.SimpleChild : { |
|
3 |
"testDouble" : 1.0, |
|
4 |
"testInt" : 123, |
|
5 |
"intArray" : [ 5, 10, 15 ], |
|
6 |
"locInnerClassInstance" : { |
|
7 |
class samples.ok.Inner : { |
|
8 |
"vnitrni" : "INNER STRING AM I" |
|
9 |
} |
|
10 |
}, |
|
11 |
"localEnum" : LOW, |
|
12 |
"pozdrav" : "AHOJ", |
|
13 |
"stringArray" : [ "A", "B", "C" ] |
|
14 |
} |
|
15 |
}, |
|
5 | 16 |
{ |
6 |
class samples.ok.Simple : { |
|
7 |
"testDouble" : 1.0, |
|
8 |
"testInt" : 123, |
|
9 |
"pozdrav" : "AHOJ" |
|
10 |
} |
|
11 |
} |
|
17 |
class samples.ok.SimpleChild : { |
|
18 |
"navic" : "AHOJ, jsem tu navic" |
|
19 |
} |
|
12 | 20 |
} |
project/Deserializer/src/Deserializer.java | ||
---|---|---|
159 | 159 |
}); |
160 | 160 |
|
161 | 161 |
//tests |
162 |
Converter thread = new Converter(this, new File("Deserializer/simpleChild.out"), new File("Deserializer/bcha.json"));
|
|
162 |
Converter thread = new Converter(this, new File("Deserializer/simple.out"), new File("Deserializer/bcha.json")); |
|
163 | 163 |
thread.start(); |
164 | 164 |
} |
165 | 165 |
|
project/Deserializer/src/jdeserialize/classdesc.java | ||
---|---|---|
228 | 228 |
{ |
229 | 229 |
StringBuffer sb = new StringBuffer(); |
230 | 230 |
String val = ""; |
231 |
|
|
231 |
|
|
232 |
sb.append(indentation).append("{\n"); |
|
233 |
|
|
232 | 234 |
indentation += "\t"; |
233 | 235 |
|
234 | 236 |
// ClassName |
235 |
sb.append("{\n").append(indentation).append("class ").append(this.name);
|
|
237 |
sb.append(indentation).append("class ").append(this.name); |
|
236 | 238 |
// extends |
237 | 239 |
if (this.superclass != null) { |
238 | 240 |
sb.append(" extends ").append(this.superclass.name); |
... | ... | |
274 | 276 |
indentation = indentation.substring(0, indentation.length() - 1); |
275 | 277 |
|
276 | 278 |
sb.append("\n").append(indentation).append("}"); |
277 |
|
|
278 | 279 |
|
279 | 280 |
if(this.superclass != null) |
280 | 281 |
{ |
282 |
indentation = indentation.substring(0, indentation.length() - 1); |
|
283 |
sb.append("\n}"); |
|
281 | 284 |
sb.append(",\n"); |
282 | 285 |
sb.append(this.superclass.toJson(indentation, fielddata)); |
283 | 286 |
} |
284 |
|
|
285 |
indentation = indentation.substring(0, indentation.length() - 1); |
|
286 |
sb.append(indentation).append("\n}"); |
|
287 |
else |
|
288 |
{ |
|
289 |
indentation = indentation.substring(0, indentation.length() - 1); |
|
290 |
sb.append("\n").append(indentation).append("}"); |
|
291 |
} |
|
287 | 292 |
|
288 | 293 |
return sb.toString(); |
289 | 294 |
} |
Také k dispozici: Unified diff
re #7879
Soubor instance.java změněn.