convert
This commit is contained in:
@@ -126,14 +126,14 @@ public class MapDecoder<R extends Reader, K, V> implements Decodeable<R, Map<K,
|
||||
if (len == Reader.SIGN_VARIABLE) {
|
||||
while (in.hasNext()) {
|
||||
K key = kdecoder.convertFrom(in);
|
||||
in.readBlank();
|
||||
in.readColon();
|
||||
V value = vdecoder.convertFrom(in);
|
||||
result.put(key, value);
|
||||
}
|
||||
} else { // 固定长度
|
||||
for (int i = 0; i < len; i++) {
|
||||
K key = kdecoder.convertFrom(in);
|
||||
in.readBlank();
|
||||
in.readColon();
|
||||
V value = vdecoder.convertFrom(in);
|
||||
result.put(key, value);
|
||||
}
|
||||
|
||||
@@ -294,8 +294,9 @@ public class ObjectDecoder<R extends Reader, T> implements Decodeable<R, T> {
|
||||
if (member.index > 0) {
|
||||
member.position = member.index;
|
||||
} else {
|
||||
while (pos.contains(++pidx))
|
||||
;
|
||||
while (pos.contains(++pidx)) {
|
||||
// do nothing
|
||||
}
|
||||
member.position = pidx;
|
||||
}
|
||||
initForEachDeMember(factory, member);
|
||||
@@ -375,7 +376,7 @@ public class ObjectDecoder<R extends Reader, T> implements Decodeable<R, T> {
|
||||
final T result = this.creator == null ? null : this.creator.create();
|
||||
while (in.hasNext()) {
|
||||
DeMember member = in.readField(info);
|
||||
in.readBlank();
|
||||
in.readColon();
|
||||
if (member == null) {
|
||||
in.skipValue(); // 跳过不存在的属性的值
|
||||
} else {
|
||||
@@ -392,7 +393,7 @@ public class ObjectDecoder<R extends Reader, T> implements Decodeable<R, T> {
|
||||
int oc = 0;
|
||||
while (in.hasNext()) {
|
||||
DeMember member = in.readField(info);
|
||||
in.readBlank();
|
||||
in.readColon();
|
||||
if (member == null) {
|
||||
in.skipValue(); // 跳过不存在的属性的值
|
||||
} else {
|
||||
|
||||
@@ -57,11 +57,15 @@ public abstract class Reader {
|
||||
*/
|
||||
public abstract int position();
|
||||
|
||||
/** 跳过值(不包含值前面的字段) */
|
||||
/**
|
||||
* 跳过值(不包含值前面的字段)
|
||||
*/
|
||||
public abstract void skipValue();
|
||||
|
||||
/** /跳过字段与值之间的多余内容, json就是跳过:符, map跳过: */
|
||||
public abstract void readBlank();
|
||||
/**
|
||||
* 跳过字段与值之间的多余内容, json就是跳过:符, map跳过:
|
||||
*/
|
||||
public abstract void readColon();
|
||||
|
||||
/**
|
||||
* 读取下个值的类型
|
||||
@@ -74,6 +78,7 @@ public abstract class Reader {
|
||||
* 读取对象的类名, 返回 null 表示对象为null, 返回空字符串表示当前class与返回的class一致,返回非空字符串表示class是当前class的子类。
|
||||
*
|
||||
* @param clazz 类名
|
||||
*
|
||||
* @return 返回字段数
|
||||
*/
|
||||
public String readObjectB(final Class clazz) {
|
||||
@@ -97,7 +102,9 @@ public abstract class Reader {
|
||||
*/
|
||||
public abstract int readArrayB(@Nullable Decodeable componentDecoder);
|
||||
|
||||
/** 读取数组的尾端 */
|
||||
/**
|
||||
* 读取数组的尾端
|
||||
*/
|
||||
public abstract void readArrayE();
|
||||
|
||||
/**
|
||||
@@ -109,7 +116,9 @@ public abstract class Reader {
|
||||
*/
|
||||
public abstract int readMapB(Decodeable keyDecoder, Decodeable valueDecoder);
|
||||
|
||||
/** 读取数组的尾端 */
|
||||
/**
|
||||
* 读取Map的尾端
|
||||
*/
|
||||
public abstract void readMapE();
|
||||
|
||||
/**
|
||||
|
||||
@@ -203,7 +203,7 @@ public class JsonByteBufferReader extends JsonReader {
|
||||
|
||||
/** 判断下一个非空白字符是否: */
|
||||
@Override
|
||||
public final void readBlank() {
|
||||
public final void readColon() {
|
||||
char ch = nextGoodChar(true);
|
||||
if (ch == ':') {
|
||||
return;
|
||||
|
||||
@@ -143,7 +143,7 @@ public class JsonMultiImplDecoder<T> implements Decodeable<JsonReader, T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
in.readBlank();
|
||||
in.readColon();
|
||||
if (member == null) {
|
||||
in.skipValue(); // 跳过不存在的属性的值
|
||||
} else {
|
||||
|
||||
@@ -109,7 +109,7 @@ public class JsonReader extends Reader {
|
||||
for (String key1 : keys) {
|
||||
while (this.hasNext()) {
|
||||
String field = this.readStandardString();
|
||||
readBlank();
|
||||
readColon();
|
||||
if (key1.equals(field)) {
|
||||
break;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public class JsonReader extends Reader {
|
||||
case '{':
|
||||
while (hasNext()) {
|
||||
this.readStandardString(); // 读掉field
|
||||
this.readBlank();
|
||||
this.readColon();
|
||||
this.skipValue();
|
||||
}
|
||||
break;
|
||||
@@ -347,7 +347,7 @@ public class JsonReader extends Reader {
|
||||
|
||||
/** 判断下一个非空白字符是否: */
|
||||
@Override
|
||||
public void readBlank() {
|
||||
public void readColon() {
|
||||
char ch = nextGoodChar(true);
|
||||
if (ch == ':') {
|
||||
return;
|
||||
|
||||
@@ -147,7 +147,7 @@ public class ProtobufReader extends Reader {
|
||||
|
||||
/** 判断下一个非空白字节是否: */
|
||||
@Override
|
||||
public final void readBlank() {
|
||||
public final void readColon() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ public class InnerCoderEntityTest {
|
||||
final Object[] params = new Object[deMembers.length];
|
||||
while (in.hasNext()) {
|
||||
DeMember member = in.readField(memberInfo); // 读取字段名
|
||||
in.readBlank(); // 读取字段名与字段值之间的间隔符,JSON则是跳过冒号:
|
||||
in.readColon(); // 读取字段名与字段值之间的间隔符,JSON则是跳过冒号:
|
||||
if (member == null) {
|
||||
in.skipValue(); // 跳过不存在的字段的值, 一般不会发生
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user