JsonTreeReader.java
6.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
package com.google.gson.internal.bind;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
public final class JsonTreeReader
extends JsonReader
{
private static final Reader a = new Reader()
{
public final void close()
throws IOException
{
throw new AssertionError();
}
public final int read(char[] paramAnonymousArrayOfChar, int paramAnonymousInt1, int paramAnonymousInt2)
throws IOException
{
throw new AssertionError();
}
};
private static final Object b = new Object();
private final List<Object> c = new ArrayList();
public JsonTreeReader(JsonElement paramJsonElement)
{
super(a);
this.c.add(paramJsonElement);
}
private Object a()
{
return this.c.get(this.c.size() - 1);
}
private void a(JsonToken paramJsonToken)
throws IOException
{
if (peek() != paramJsonToken) {
throw new IllegalStateException("Expected " + paramJsonToken + " but was " + peek());
}
}
private Object b()
{
return this.c.remove(this.c.size() - 1);
}
public final void beginArray()
throws IOException
{
a(JsonToken.BEGIN_ARRAY);
JsonArray localJsonArray = (JsonArray)a();
this.c.add(localJsonArray.iterator());
}
public final void beginObject()
throws IOException
{
a(JsonToken.BEGIN_OBJECT);
JsonObject localJsonObject = (JsonObject)a();
this.c.add(localJsonObject.entrySet().iterator());
}
public final void close()
throws IOException
{
this.c.clear();
this.c.add(b);
}
public final void endArray()
throws IOException
{
a(JsonToken.END_ARRAY);
b();
b();
}
public final void endObject()
throws IOException
{
a(JsonToken.END_OBJECT);
b();
b();
}
public final boolean hasNext()
throws IOException
{
JsonToken localJsonToken = peek();
return (localJsonToken != JsonToken.END_OBJECT) && (localJsonToken != JsonToken.END_ARRAY);
}
public final boolean nextBoolean()
throws IOException
{
a(JsonToken.BOOLEAN);
return ((JsonPrimitive)b()).getAsBoolean();
}
public final double nextDouble()
throws IOException
{
JsonToken localJsonToken = peek();
if ((localJsonToken != JsonToken.NUMBER) && (localJsonToken != JsonToken.STRING)) {
throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + localJsonToken);
}
double d = ((JsonPrimitive)a()).getAsDouble();
if ((!isLenient()) && ((Double.isNaN(d)) || (Double.isInfinite(d)))) {
throw new NumberFormatException("JSON forbids NaN and infinities: " + d);
}
b();
return d;
}
public final int nextInt()
throws IOException
{
JsonToken localJsonToken = peek();
if ((localJsonToken != JsonToken.NUMBER) && (localJsonToken != JsonToken.STRING)) {
throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + localJsonToken);
}
int i = ((JsonPrimitive)a()).getAsInt();
b();
return i;
}
public final long nextLong()
throws IOException
{
JsonToken localJsonToken = peek();
if ((localJsonToken != JsonToken.NUMBER) && (localJsonToken != JsonToken.STRING)) {
throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + localJsonToken);
}
long l = ((JsonPrimitive)a()).getAsLong();
b();
return l;
}
public final String nextName()
throws IOException
{
a(JsonToken.NAME);
Map.Entry localEntry = (Map.Entry)((Iterator)a()).next();
this.c.add(localEntry.getValue());
return (String)localEntry.getKey();
}
public final void nextNull()
throws IOException
{
a(JsonToken.NULL);
b();
}
public final String nextString()
throws IOException
{
JsonToken localJsonToken = peek();
if ((localJsonToken != JsonToken.STRING) && (localJsonToken != JsonToken.NUMBER)) {
throw new IllegalStateException("Expected " + JsonToken.STRING + " but was " + localJsonToken);
}
return ((JsonPrimitive)b()).getAsString();
}
public final JsonToken peek()
throws IOException
{
Object localObject;
boolean bool;
for (;;)
{
if (this.c.isEmpty()) {
return JsonToken.END_DOCUMENT;
}
localObject = a();
if (!(localObject instanceof Iterator)) {
break label105;
}
bool = this.c.get(this.c.size() - 2) instanceof JsonObject;
localObject = (Iterator)localObject;
if (!((Iterator)localObject).hasNext()) {
break;
}
if (bool) {
return JsonToken.NAME;
}
this.c.add(((Iterator)localObject).next());
}
if (bool) {
return JsonToken.END_OBJECT;
}
return JsonToken.END_ARRAY;
label105:
if ((localObject instanceof JsonObject)) {
return JsonToken.BEGIN_OBJECT;
}
if ((localObject instanceof JsonArray)) {
return JsonToken.BEGIN_ARRAY;
}
if ((localObject instanceof JsonPrimitive))
{
localObject = (JsonPrimitive)localObject;
if (((JsonPrimitive)localObject).isString()) {
return JsonToken.STRING;
}
if (((JsonPrimitive)localObject).isBoolean()) {
return JsonToken.BOOLEAN;
}
if (((JsonPrimitive)localObject).isNumber()) {
return JsonToken.NUMBER;
}
throw new AssertionError();
}
if ((localObject instanceof JsonNull)) {
return JsonToken.NULL;
}
if (localObject == b) {
throw new IllegalStateException("JsonReader is closed");
}
throw new AssertionError();
}
public final void promoteNameToValue()
throws IOException
{
a(JsonToken.NAME);
Map.Entry localEntry = (Map.Entry)((Iterator)a()).next();
this.c.add(localEntry.getValue());
this.c.add(new JsonPrimitive((String)localEntry.getKey()));
}
public final void skipValue()
throws IOException
{
if (peek() == JsonToken.NAME)
{
nextName();
return;
}
b();
}
public final String toString()
{
return getClass().getSimpleName();
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/google/gson/internal/bind/JsonTreeReader.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/