MCPcopy Create free account
hub / github.com/Beh01der/EasyFlow / JsonArrayParserTest

Class JsonArrayParserTest

src/test/java/au/com/ds/ef/JsonArrayParserTest.java:22–417  ·  view source on GitHub ↗

User: andrey Date: 11/04/13 Time: 12:05 PM

Source from the content-addressed store, hash-verified

20 * Time: 12:05 PM
21 */
22public class JsonArrayParserTest {
23 protected static class Item {
24 enum ItemType {VALUE, LIST}
25
26 private ItemType type;
27 private List<Item> list;
28 private String value;
29
30 public Item(List<Character> value) {
31 this.type = ItemType.VALUE;
32 StringBuilder sb = new StringBuilder();
33 for (Character c : value) {
34 sb.append(c);
35 }
36
37 this.value = sb.toString();
38 }
39
40 public Item() {
41 this.type = ItemType.LIST;
42 this.list = Lists.newArrayList();
43 }
44
45 public List<Item> getList() {
46 return list;
47 }
48
49 public String getValue() {
50 return value;
51 }
52
53 public ItemType getType() {
54 return type;
55 }
56 }
57
58 protected static class ParserContext extends StatefulContext {
59 private String json;
60 private int position;
61 private char thisChar;
62 private List<Character> thisValue;
63 private boolean startedValue;
64 private LinkedList<Item> stack;
65 private Item result;
66
67 public ParserContext(String json) {
68 this.json = json;
69 this.position = -1;
70 this.thisChar = 0;
71 this.stack = Lists.newLinkedList();
72 this.thisValue = Lists.newArrayList();
73 this.startedValue = false;
74 }
75
76 public char getNextChar() {
77 thisChar = ++position < json.length() ? json.charAt(position) : 0;
78 return thisChar;
79 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected