This commit is contained in:
@@ -55,14 +55,14 @@ public final class MapDecoder<K, V> implements Decodeable<Reader, Map<K, V>> {
|
||||
if (len == Reader.SIGN_NOLENGTH) {
|
||||
while (in.hasNext()) {
|
||||
K key = keyDecoder.convertFrom(in);
|
||||
in.skipBlank();
|
||||
in.readBlank();
|
||||
V value = valueDecoder.convertFrom(in);
|
||||
result.put(key, value);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < len; i++) {
|
||||
K key = keyDecoder.convertFrom(in);
|
||||
in.skipBlank();
|
||||
in.readBlank();
|
||||
V value = valueDecoder.convertFrom(in);
|
||||
result.put(key, value);
|
||||
}
|
||||
|
||||
@@ -181,14 +181,14 @@ public final class ObjectDecoder<R extends Reader, T> implements Decodeable<R, T
|
||||
final T result = this.creator.create();
|
||||
while (in.hasNext()) {
|
||||
DeMember member = in.readFieldName(members);
|
||||
in.skipBlank();
|
||||
in.readBlank();
|
||||
if (member == null) {
|
||||
in.skipValue(); //跳过不存在的属性的值
|
||||
} else {
|
||||
member.read(in, result);
|
||||
}
|
||||
}
|
||||
in.readObjectE();
|
||||
in.readObjectE(typeClass);
|
||||
return result;
|
||||
} else { //带参数的构造函数
|
||||
final DeMember<R, T, ?>[] fields = this.creatorConstructorMembers;
|
||||
@@ -197,7 +197,7 @@ public final class ObjectDecoder<R extends Reader, T> implements Decodeable<R, T
|
||||
int oc = 0;
|
||||
while (in.hasNext()) {
|
||||
DeMember member = in.readFieldName(members);
|
||||
in.skipBlank();
|
||||
in.readBlank();
|
||||
if (member == null) {
|
||||
in.skipValue(); //跳过不存在的属性的值
|
||||
} else {
|
||||
@@ -213,7 +213,7 @@ public final class ObjectDecoder<R extends Reader, T> implements Decodeable<R, T
|
||||
if (flag) otherParams[oc++] = new Object[]{member.attribute, val};
|
||||
}
|
||||
}
|
||||
in.readObjectE();
|
||||
in.readObjectE(typeClass);
|
||||
final T result = this.creator.create(constructorParams);
|
||||
for (int i = 0; i < oc; i++) {
|
||||
((Attribute) otherParams[i][0]).set(result, otherParams[i][1]);
|
||||
|
||||
@@ -36,11 +36,12 @@ public abstract class Reader {
|
||||
/**
|
||||
* /跳过字段与值之间的多余内容, json就是跳过:符, map跳过:
|
||||
*/
|
||||
public abstract void skipBlank();
|
||||
public abstract void readBlank();
|
||||
|
||||
/**
|
||||
* 读取对象的类名, 返回 null 表示对象为null, 返回空字符串表示当前class与返回的class一致,返回非空字符串表示class是当前class的子类。
|
||||
*
|
||||
* @param clazz 类名
|
||||
* @return 返回字段数
|
||||
*/
|
||||
public String readObjectB(final Class clazz) {
|
||||
@@ -51,8 +52,9 @@ public abstract class Reader {
|
||||
/**
|
||||
* 读取对象的尾端
|
||||
*
|
||||
* @param clazz 类名
|
||||
*/
|
||||
public abstract void readObjectE();
|
||||
public abstract void readObjectE(final Class clazz);
|
||||
|
||||
/**
|
||||
* 读取数组的开头并返回数组的长度
|
||||
|
||||
@@ -170,7 +170,7 @@ public class BsonReader extends Reader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void readObjectE() {
|
||||
public final void readObjectE(final Class clazz) {
|
||||
if (readShort() != SIGN_OBJECTE) {
|
||||
throw new ConvertException("a bson object must end with " + (SIGN_OBJECTE)
|
||||
+ " (position = " + position + ") but '" + currentByte() + "'");
|
||||
@@ -210,7 +210,7 @@ public class BsonReader extends Reader {
|
||||
* 判断下一个非空白字节是否:
|
||||
*/
|
||||
@Override
|
||||
public final void skipBlank() {
|
||||
public final void readBlank() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -139,7 +139,7 @@ public class JsonByteBufferReader extends JsonReader {
|
||||
* 判断下一个非空白字符是否:
|
||||
*/
|
||||
@Override
|
||||
public final void skipBlank() {
|
||||
public final void readBlank() {
|
||||
char ch = nextGoodChar();
|
||||
if (ch == ':') return;
|
||||
throw new ConvertException("expected a ':' but '" + ch + "'(position = " + position + ")");
|
||||
|
||||
@@ -93,7 +93,7 @@ public class JsonReader extends Reader {
|
||||
for (String key1 : keys) {
|
||||
while (this.hasNext()) {
|
||||
String field = this.readSmallString();
|
||||
skipBlank();
|
||||
readBlank();
|
||||
if (key1.equals(field)) break;
|
||||
skipValue();
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class JsonReader extends Reader {
|
||||
} else if (ch == '{') {
|
||||
while (hasNext()) {
|
||||
this.readSmallString(); //读掉field
|
||||
this.skipBlank();
|
||||
this.readBlank();
|
||||
this.skipValue();
|
||||
}
|
||||
} else if (ch == '[') {
|
||||
@@ -189,7 +189,7 @@ public class JsonReader extends Reader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void readObjectE() {
|
||||
public final void readObjectE(final Class clazz) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -237,7 +237,7 @@ public class JsonReader extends Reader {
|
||||
* 判断下一个非空白字符是否:
|
||||
*/
|
||||
@Override
|
||||
public void skipBlank() {
|
||||
public void readBlank() {
|
||||
char ch = this.text[++this.position];
|
||||
if (ch == ':') return;
|
||||
if (ch <= ' ') {
|
||||
|
||||
Reference in New Issue
Block a user