Skip to content

Commit 38fdfed

Browse files
committed
rename
1 parent cf98015 commit 38fdfed

23 files changed

+164
-162
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Given this JSON document `[0,1,2,3]`
1919
Parse with Java bind-api
2020

2121
```java
22-
import com.jsoniter.Jsoniter;
22+
import com.jsoniter.JsonIterator;
2323
Jsoniter iter = Jsoniter.parse("[0,1,2,3]");
2424
int[] val = iter.read(int[].class);
2525
System.out.println(val[3]);
@@ -28,7 +28,7 @@ System.out.println(val[3]);
2828
Parse with Java any-api
2929

3030
```java
31-
import com.jsoniter.Jsoniter;
31+
import com.jsoniter.JsonIterator;
3232
Jsoniter iter = Jsoniter.parse("[0,1,2,3]");
3333
Any val = iter.readAny();
3434
System.out.println(any.get(3));
@@ -37,7 +37,7 @@ System.out.println(any.get(3));
3737
Parse with Java iterator-api
3838

3939
```java
40-
import com.jsoniter.Jsoniter;
40+
import com.jsoniter.JsonIterator;
4141
Jsoniter iter = Jsoniter.parse("[0,1,2,3]");
4242
int total = 0;
4343
while(iter.readArray()) {

src/main/java/com/jsoniter/Codegen.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private synchronized static Decoder gen(String cacheKey, Type type, Type[] typeA
8585
CtMethod staticMethod = CtNewMethod.make(source, ctClass);
8686
ctClass.addMethod(staticMethod);
8787
CtMethod interfaceMethod = CtNewMethod.make("" +
88-
"public Object decode(com.jsoniter.Jsoniter iter) {" +
88+
"public Object decode(com.jsoniter.JsonIterator iter) {" +
8989
"return decode_(iter);" +
9090
"}", ctClass);
9191
ctClass.addMethod(interfaceMethod);
@@ -158,7 +158,7 @@ private static String genSource(String cacheKey, Class clazz, Type[] typeArgs) {
158158

159159
private static String genMap(Class clazz, Type valueType) {
160160
StringBuilder lines = new StringBuilder();
161-
append(lines, "public static Object decode_(com.jsoniter.Jsoniter iter) {");
161+
append(lines, "public static Object decode_(com.jsoniter.JsonIterator iter) {");
162162
append(lines, "{{clazz}} map = new {{clazz}}();");
163163
append(lines, "for (String field = iter.readObject(); field != null; field = iter.readObject()) {");
164164
append(lines, "map.put(field, {{op}});");
@@ -191,7 +191,7 @@ private static String genNative(String nativeReadKey) {
191191
throw new RuntimeException("do not know how to read: " + nativeReadKey);
192192
}
193193
StringBuilder lines = new StringBuilder();
194-
append(lines, "public static Object decode_(com.jsoniter.Jsoniter iter) {");
194+
append(lines, "public static Object decode_(com.jsoniter.JsonIterator iter) {");
195195
append(lines, "return " + op + ";");
196196
append(lines, "}");
197197
return lines.toString();
@@ -216,7 +216,7 @@ private static String genObjectUsingHash(Class clazz, String cacheKey) {
216216
return genObjectUsingSkip(clazz, ctor);
217217
}
218218
StringBuilder lines = new StringBuilder();
219-
append(lines, "public static Object decode_(com.jsoniter.Jsoniter iter) {");
219+
append(lines, "public static Object decode_(com.jsoniter.JsonIterator iter) {");
220220
append(lines, "if (iter.readNull()) { return null; }");
221221
for (Binding parameter : ctor.parameters) {
222222
appendVarDef(lines, parameter);
@@ -299,7 +299,7 @@ private static void appendVarDef(StringBuilder lines, Binding parameter) {
299299

300300
private static String genObjectUsingSkip(Class clazz, CustomizedConstructor ctor) {
301301
StringBuilder lines = new StringBuilder();
302-
append(lines, "public static Object decode_(com.jsoniter.Jsoniter iter) {");
302+
append(lines, "public static Object decode_(com.jsoniter.JsonIterator iter) {");
303303
append(lines, "if (iter.readNull()) { return null; }");
304304
append(lines, "{{clazz}} obj = {{newInst}};");
305305
append(lines, "iter.skip();");
@@ -339,7 +339,7 @@ private static void appendInvocation(StringBuilder code, List<Binding> params) {
339339
private static String genObjectUsingSlice(Class clazz, String cacheKey) {
340340
Map<Integer, Object> trieTree = buildTriTree(clazz);
341341
StringBuilder lines = new StringBuilder();
342-
append(lines, "public static Object decode_(com.jsoniter.Jsoniter iter) {");
342+
append(lines, "public static Object decode_(com.jsoniter.JsonIterator iter) {");
343343
append(lines, "if (iter.readNull()) { return null; }");
344344
append(lines, "{{clazz}} obj = {{newInst}};");
345345
append(lines, "if (!com.jsoniter.CodegenAccess.readObjectStart(iter)) { return obj; }");
@@ -547,7 +547,7 @@ private static String genArray(Class clazz) {
547547
throw new IllegalArgumentException("nested array not supported: " + clazz.getCanonicalName());
548548
}
549549
StringBuilder lines = new StringBuilder();
550-
append(lines, "public static Object decode_(com.jsoniter.Jsoniter iter) {");
550+
append(lines, "public static Object decode_(com.jsoniter.JsonIterator iter) {");
551551
append(lines, "if (iter.readNull()) { return null; }");
552552
append(lines, "if (!com.jsoniter.CodegenAccess.readArrayStart(iter)) {");
553553
append(lines, "return new {{comp}}[0];");
@@ -591,7 +591,7 @@ private static String genArray(Class clazz) {
591591

592592
private static String genCollectionWithCapacity(Class clazz, Type compType) {
593593
StringBuilder lines = new StringBuilder();
594-
append(lines, "public static Object decode_(com.jsoniter.Jsoniter iter) {");
594+
append(lines, "public static Object decode_(com.jsoniter.JsonIterator iter) {");
595595
append(lines, "if (!com.jsoniter.CodegenAccess.readArrayStart(iter)) {");
596596
append(lines, "return new {{clazz}}(0);");
597597
append(lines, "}");
@@ -635,7 +635,7 @@ private static String genCollectionWithCapacity(Class clazz, Type compType) {
635635

636636
private static String genCollection(Class clazz, Type compType) {
637637
StringBuilder lines = new StringBuilder();
638-
append(lines, "public static Object decode_(com.jsoniter.Jsoniter iter) {");
638+
append(lines, "public static Object decode_(com.jsoniter.JsonIterator iter) {");
639639
append(lines, "if (!com.jsoniter.CodegenAccess.readArrayStart(iter)) {");
640640
append(lines, "return new {{clazz}}();");
641641
append(lines, "}");

src/main/java/com/jsoniter/CodegenAccess.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,39 @@
55
// only uesd by generated code to access decoder
66
public class CodegenAccess {
77

8-
public static byte nextToken(Jsoniter iter) throws IOException {
8+
public static byte nextToken(JsonIterator iter) throws IOException {
99
return iter.nextToken();
1010
}
1111

12-
public static final boolean readBoolean(String cacheKey, Jsoniter iter) throws IOException {
12+
public static final boolean readBoolean(String cacheKey, JsonIterator iter) throws IOException {
1313
return Codegen.getBooleanDecoder(cacheKey).decodeBoolean(iter);
1414
}
1515

16-
public static final short readShort(String cacheKey, Jsoniter iter) throws IOException {
16+
public static final short readShort(String cacheKey, JsonIterator iter) throws IOException {
1717
return Codegen.getShortDecoder(cacheKey).decodeShort(iter);
1818
}
1919

20-
public static final int readInt(String cacheKey, Jsoniter iter) throws IOException {
20+
public static final int readInt(String cacheKey, JsonIterator iter) throws IOException {
2121
return Codegen.getIntDecoder(cacheKey).decodeInt(iter);
2222
}
2323

24-
public static final long readLong(String cacheKey, Jsoniter iter) throws IOException {
24+
public static final long readLong(String cacheKey, JsonIterator iter) throws IOException {
2525
return Codegen.getLongDecoder(cacheKey).decodeLong(iter);
2626
}
2727

28-
public static final float readFloat(String cacheKey, Jsoniter iter) throws IOException {
28+
public static final float readFloat(String cacheKey, JsonIterator iter) throws IOException {
2929
return Codegen.getFloatDecoder(cacheKey).decodeFloat(iter);
3030
}
3131

32-
public static final double readDouble(String cacheKey, Jsoniter iter) throws IOException {
32+
public static final double readDouble(String cacheKey, JsonIterator iter) throws IOException {
3333
return Codegen.getDoubleDecoder(cacheKey).decodeDouble(iter);
3434
}
3535

36-
public static final <T> T read(String cacheKey, Jsoniter iter) throws IOException {
36+
public static final <T> T read(String cacheKey, JsonIterator iter) throws IOException {
3737
return (T) Codegen.getDecoder(cacheKey, null).decode(iter);
3838
}
3939

40-
public static boolean readArrayStart(Jsoniter iter) throws IOException {
40+
public static boolean readArrayStart(JsonIterator iter) throws IOException {
4141
byte c = iter.nextToken();
4242
if (c != '[') {
4343
throw iter.reportError("readArrayStart", "expect [ or n");
@@ -50,7 +50,7 @@ public static boolean readArrayStart(Jsoniter iter) throws IOException {
5050
return true;
5151
}
5252

53-
public static boolean readObjectStart(Jsoniter iter) throws IOException {
53+
public static boolean readObjectStart(JsonIterator iter) throws IOException {
5454
byte c = iter.nextToken();
5555
if (c != '{') {
5656
throw iter.reportError("readObjectStart", "expect { or n, found: " + (char)c);
@@ -63,15 +63,15 @@ public static boolean readObjectStart(Jsoniter iter) throws IOException {
6363
return true;
6464
}
6565

66-
public static void reportIncompleteObject(Jsoniter iter) {
66+
public static void reportIncompleteObject(JsonIterator iter) {
6767
throw iter.reportError("genObject", "expect }");
6868
}
6969

70-
public static void reportIncompleteArray(Jsoniter iter) {
70+
public static void reportIncompleteArray(JsonIterator iter) {
7171
throw iter.reportError("genArray", "expect ]");
7272
}
7373

74-
public static final int readObjectFieldAsHash(Jsoniter iter) throws IOException {
74+
public static final int readObjectFieldAsHash(JsonIterator iter) throws IOException {
7575
if (iter.nextToken() != '"') {
7676
throw iter.reportError("readObjectFieldAsHash", "expect \"");
7777
}
@@ -100,11 +100,11 @@ public static final int readObjectFieldAsHash(Jsoniter iter) throws IOException
100100
}
101101
}
102102

103-
public static final Slice readObjectFieldAsSlice(Jsoniter iter) throws IOException {
103+
public static final Slice readObjectFieldAsSlice(JsonIterator iter) throws IOException {
104104
if (iter.nextToken() != '"') {
105105
throw iter.reportError("readObjectFieldAsSlice", "expect \"");
106106
}
107-
Slice field = StringReader.readSlice(iter);
107+
Slice field = IterImplString.readSlice(iter);
108108
boolean notCopied = field != null;
109109
if (skipWhitespacesWithoutLoadMore(iter)) {
110110
if (notCopied) {
@@ -137,7 +137,7 @@ public static final Slice readObjectFieldAsSlice(Jsoniter iter) throws IOExcepti
137137
return field;
138138
}
139139

140-
private final static boolean skipWhitespacesWithoutLoadMore(Jsoniter iter) throws IOException {
140+
private final static boolean skipWhitespacesWithoutLoadMore(JsonIterator iter) throws IOException {
141141
for (int i = iter.head; i < iter.tail; i++) {
142142
byte c = iter.buf[i];
143143
switch (c) {

src/main/java/com/jsoniter/Decoder.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,29 @@ public interface Decoder {
1010
* @return the value to set
1111
* @throws IOException when reading from iterator triggered error
1212
*/
13-
Object decode(Jsoniter iter) throws IOException;
13+
Object decode(JsonIterator iter) throws IOException;
1414

1515
interface BooleanDecoder extends Decoder {
16-
boolean decodeBoolean(Jsoniter iter) throws IOException;
16+
boolean decodeBoolean(JsonIterator iter) throws IOException;
1717
}
1818

1919
interface ShortDecoder extends Decoder {
20-
short decodeShort(Jsoniter iter) throws IOException;
20+
short decodeShort(JsonIterator iter) throws IOException;
2121
}
2222

2323
interface IntDecoder extends Decoder {
24-
int decodeInt(Jsoniter iter) throws IOException;
24+
int decodeInt(JsonIterator iter) throws IOException;
2525
}
2626

2727
interface LongDecoder extends Decoder {
28-
long decodeLong(Jsoniter iter) throws IOException;
28+
long decodeLong(JsonIterator iter) throws IOException;
2929
}
3030

3131
interface FloatDecoder extends Decoder {
32-
float decodeFloat(Jsoniter iter) throws IOException;
32+
float decodeFloat(JsonIterator iter) throws IOException;
3333
}
3434

3535
interface DoubleDecoder extends Decoder {
36-
double decodeDouble(Jsoniter iter) throws IOException;
36+
double decodeDouble(JsonIterator iter) throws IOException;
3737
}
3838
}

src/main/java/com/jsoniter/NumberReader.java renamed to src/main/java/com/jsoniter/IterImplNumber.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import java.io.IOException;
44

5-
class NumberReader {
5+
class IterImplNumber {
66

77
final static int[] digits = new int[256];
88

@@ -21,7 +21,7 @@ class NumberReader {
2121
}
2222
}
2323

24-
public static final double readDouble(Jsoniter iter) throws IOException {
24+
public static final double readDouble(JsonIterator iter) throws IOException {
2525
final byte c = iter.nextToken();
2626
// when re-read using slowpath, it should include the first byte
2727
iter.unreadByte();
@@ -32,7 +32,7 @@ public static final double readDouble(Jsoniter iter) throws IOException {
3232
return readPositiveDouble(iter, iter.head);
3333
}
3434

35-
private static final double readPositiveDouble(Jsoniter iter, int start) throws IOException {
35+
private static final double readPositiveDouble(JsonIterator iter, int start) throws IOException {
3636
long value = 0;
3737
byte c = ' ';
3838
int i = start;
@@ -69,7 +69,7 @@ private static final double readPositiveDouble(Jsoniter iter, int start) throws
6969
return readDoubleSlowPath(iter);
7070
}
7171

72-
private static final double readNegativeDouble(Jsoniter iter, int start) throws IOException {
72+
private static final double readNegativeDouble(JsonIterator iter, int start) throws IOException {
7373
long value = 0;
7474
byte c = ' ';
7575
int i = start;
@@ -106,11 +106,11 @@ private static final double readNegativeDouble(Jsoniter iter, int start) throws
106106
return readDoubleSlowPath(iter);
107107
}
108108

109-
public static final double readDoubleSlowPath(Jsoniter iter) throws IOException {
109+
public static final double readDoubleSlowPath(JsonIterator iter) throws IOException {
110110
return Double.valueOf(readNumber(iter));
111111
}
112112

113-
public static final float readFloat(Jsoniter iter) throws IOException {
113+
public static final float readFloat(JsonIterator iter) throws IOException {
114114
final byte c = iter.nextToken();
115115
// when re-read using slowpath, it should include the first byte
116116
iter.unreadByte();
@@ -121,7 +121,7 @@ public static final float readFloat(Jsoniter iter) throws IOException {
121121
return readPositiveFloat(iter, iter.head);
122122
}
123123

124-
private static final float readPositiveFloat(Jsoniter iter, int start) throws IOException {
124+
private static final float readPositiveFloat(JsonIterator iter, int start) throws IOException {
125125
long value = 0;
126126
byte c = ' ';
127127
int i = start;
@@ -158,7 +158,7 @@ private static final float readPositiveFloat(Jsoniter iter, int start) throws IO
158158
return readFloatSlowPath(iter);
159159
}
160160

161-
private static final float readNegativeFloat(Jsoniter iter, int start) throws IOException {
161+
private static final float readNegativeFloat(JsonIterator iter, int start) throws IOException {
162162
long value = 0;
163163
byte c = ' ';
164164
int i = start;
@@ -195,11 +195,11 @@ private static final float readNegativeFloat(Jsoniter iter, int start) throws IO
195195
return readFloatSlowPath(iter);
196196
}
197197

198-
public static final float readFloatSlowPath(Jsoniter iter) throws IOException {
198+
public static final float readFloatSlowPath(JsonIterator iter) throws IOException {
199199
return Float.valueOf(readNumber(iter));
200200
}
201201

202-
public static final String readNumber(Jsoniter iter) throws IOException {
202+
public static final String readNumber(JsonIterator iter) throws IOException {
203203
int j = 0;
204204
for (byte c = iter.nextToken(); !iter.eof; c = iter.readByte()) {
205205
if (j == iter.reusableChars.length) {
@@ -233,7 +233,7 @@ public static final String readNumber(Jsoniter iter) throws IOException {
233233
return new String(iter.reusableChars, 0, j);
234234
}
235235

236-
public static final int readInt(Jsoniter iter) throws IOException {
236+
public static final int readInt(JsonIterator iter) throws IOException {
237237
byte c = iter.nextToken();
238238
if (c == '-') {
239239
return -readUnsignedInt(iter);
@@ -243,7 +243,7 @@ public static final int readInt(Jsoniter iter) throws IOException {
243243
}
244244
}
245245

246-
public static final int readUnsignedInt(Jsoniter iter) throws IOException {
246+
public static final int readUnsignedInt(JsonIterator iter) throws IOException {
247247
// TODO: throw overflow
248248
byte c = iter.readByte();
249249
int v = digits[c];
@@ -266,7 +266,7 @@ public static final int readUnsignedInt(Jsoniter iter) throws IOException {
266266
return result;
267267
}
268268

269-
public static final long readLong(Jsoniter iter) throws IOException {
269+
public static final long readLong(JsonIterator iter) throws IOException {
270270
byte c = iter.nextToken();
271271
if (c == '-') {
272272
return -readUnsignedLong(iter);
@@ -276,7 +276,7 @@ public static final long readLong(Jsoniter iter) throws IOException {
276276
}
277277
}
278278

279-
public static final long readUnsignedLong(Jsoniter iter) throws IOException {
279+
public static final long readUnsignedLong(JsonIterator iter) throws IOException {
280280
// TODO: throw overflow
281281
byte c = iter.readByte();
282282
int v = digits[c];
@@ -299,7 +299,7 @@ public static final long readUnsignedLong(Jsoniter iter) throws IOException {
299299
return result;
300300
}
301301

302-
public static final char readU4(Jsoniter iter) throws IOException {
302+
public static final char readU4(JsonIterator iter) throws IOException {
303303
int v = digits[iter.readByte()];
304304
if (v == -1) {
305305
throw iter.reportError("readU4", "bad unicode");

0 commit comments

Comments
 (0)