本文整理汇总了Java中com.alibaba.fastjson.parser.DefaultJSONParser.checkListResolve方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultJSONParser.checkListResolve方法的具体用法?Java DefaultJSONParser.checkListResolve怎么用?Java DefaultJSONParser.checkListResolve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.fastjson.parser.DefaultJSONParser
的用法示例。
在下文中一共展示了DefaultJSONParser.checkListResolve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseArray
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public final void parseArray(DefaultJSONParser parser, Type objectType, Collection array) {
Type itemType = this.itemType;
ObjectDeserializer itemTypeDeser = this.deserializer;
if (itemType instanceof TypeVariable //
&& objectType instanceof ParameterizedType) {
TypeVariable typeVar = (TypeVariable) itemType;
ParameterizedType paramType = (ParameterizedType) objectType;
Class<?> objectClass = null;
if (paramType.getRawType() instanceof Class) {
objectClass = (Class<?>) paramType.getRawType();
}
int paramIndex = -1;
if (objectClass != null) {
for (int i = 0, size = objectClass.getTypeParameters().length; i < size; ++i) {
TypeVariable item = objectClass.getTypeParameters()[i];
if (item.getName().equals(typeVar.getName())) {
paramIndex = i;
break;
}
}
}
if (paramIndex != -1) {
itemType = paramType.getActualTypeArguments()[paramIndex];
if (!itemType.equals(this.itemType)) {
itemTypeDeser = parser.getConfig().getDeserializer(itemType);
}
}
}
final JSONLexer lexer = parser.getLexer();
if (lexer.token() != JSONToken.LBRACKET) {
String errorMessage = "exepct '[', but " + JSONToken.name(lexer.token());
if (objectType != null) {
errorMessage += ", type : " + objectType;
}
throw new JSONException(errorMessage);
}
if (itemTypeDeser == null) {
itemTypeDeser = deserializer = parser.getConfig().getDeserializer(itemType);
itemFastMatchToken = deserializer.getFastMatchToken();
}
lexer.nextToken(itemFastMatchToken);
for (int i = 0;; ++i) {
if (lexer.isEnabled(Feature.AllowArbitraryCommas)) {
while (lexer.token() == JSONToken.COMMA) {
lexer.nextToken();
continue;
}
}
if (lexer.token() == JSONToken.RBRACKET) {
break;
}
Object val = itemTypeDeser.deserialze(parser, itemType, i);
array.add(val);
parser.checkListResolve(array);
if (lexer.token() == JSONToken.COMMA) {
lexer.nextToken(itemFastMatchToken);
continue;
}
}
lexer.nextToken(JSONToken.COMMA);
}
示例2: parseArray
import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public final void parseArray(DefaultJSONParser parser, Type objectType, Collection array) {
int i;
Type itemType = this.itemType;
ObjectDeserializer itemTypeDeser = this.deserializer;
if ((itemType instanceof TypeVariable) && (objectType instanceof ParameterizedType)) {
TypeVariable typeVar = (TypeVariable) itemType;
ParameterizedType paramType = (ParameterizedType) objectType;
Class<?> objectClass = null;
if (paramType.getRawType() instanceof Class) {
objectClass = (Class) paramType.getRawType();
}
int paramIndex = -1;
if (objectClass != null) {
int size = objectClass.getTypeParameters().length;
for (i = 0; i < size; i++) {
if (objectClass.getTypeParameters()[i].getName().equals(typeVar.getName())) {
paramIndex = i;
break;
}
}
}
if (paramIndex != -1) {
itemType = paramType.getActualTypeArguments()[paramIndex];
if (!itemType.equals(this.itemType)) {
itemTypeDeser = parser.getConfig().getDeserializer(itemType);
}
}
}
JSONLexer lexer = parser.getLexer();
if (lexer.token() != 14) {
String errorMessage = "exepct '[', but " + JSONToken.name(lexer.token());
if (objectType != null) {
errorMessage = errorMessage + ", type : " + objectType;
}
throw new JSONException(errorMessage);
}
if (itemTypeDeser == null) {
itemTypeDeser = parser.getConfig().getDeserializer(itemType);
this.deserializer = itemTypeDeser;
this.itemFastMatchToken = this.deserializer.getFastMatchToken();
}
lexer.nextToken(this.itemFastMatchToken);
i = 0;
while (true) {
if (lexer.isEnabled(Feature.AllowArbitraryCommas)) {
while (lexer.token() == 16) {
lexer.nextToken();
}
}
if (lexer.token() == 15) {
lexer.nextToken(16);
return;
}
array.add(itemTypeDeser.deserialze(parser, itemType, Integer.valueOf(i)));
parser.checkListResolve(array);
if (lexer.token() == 16) {
lexer.nextToken(this.itemFastMatchToken);
}
i++;
}
}