本文整理汇总了Java中com.alibaba.fastjson.parser.DefaultJSONParser.ResolveTask类的典型用法代码示例。如果您正苦于以下问题:Java ResolveTask类的具体用法?Java ResolveTask怎么用?Java ResolveTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResolveTask类属于com.alibaba.fastjson.parser.DefaultJSONParser包,在下文中一共展示了ResolveTask类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parseField
import com.alibaba.fastjson.parser.DefaultJSONParser.ResolveTask; //导入依赖的package包/类
public void parseField(DefaultJSONParser parser, Object object, Type objectType, Map<String, Object> fieldValues) {
if (this.fieldValueDeserilizer == null) {
this.fieldValueDeserilizer = parser.getConfig().getDeserializer(this.fieldInfo);
}
if (objectType instanceof ParameterizedType) {
parser.getContext().setType(objectType);
}
Object value = this.fieldValueDeserilizer.deserialze(parser, getFieldType(), this.fieldInfo.getName());
if (parser.getResolveStatus() == 1) {
ResolveTask task = parser.getLastResolveTask();
task.setFieldDeserializer(this);
task.setOwnerContext(parser.getContext());
parser.setResolveStatus(0);
} else if (object == null) {
fieldValues.put(this.fieldInfo.getName(), value);
} else {
setValue(object, value);
}
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:DefaultFieldDeserializer.java
示例2: parseField
import com.alibaba.fastjson.parser.DefaultJSONParser.ResolveTask; //导入依赖的package包/类
@Override
public void parseField(DefaultJSONParser parser, Object object, Type objectType, Map<String, Object> fieldValues) {
if (fieldValueDeserilizer == null) {
fieldValueDeserilizer = parser.getConfig().getDeserializer(fieldInfo);
}
if (objectType instanceof ParameterizedType) {
ParseContext objContext = parser.getContext();
objContext.setType(objectType);
}
Object value = fieldValueDeserilizer.deserialze(parser, getFieldType(), fieldInfo.getName());
if (parser.getResolveStatus() == DefaultJSONParser.NeedToResolve) {
ResolveTask task = parser.getLastResolveTask();
task.setFieldDeserializer(this);
task.setOwnerContext(parser.getContext());
parser.setResolveStatus(DefaultJSONParser.NONE);
} else {
if (object == null) {
fieldValues.put(fieldInfo.getName(), value);
} else {
setValue(object, value);
}
}
}
开发者ID:uavorg,项目名称:uavstack,代码行数:26,代码来源:DefaultFieldDeserializer.java
示例3: parseField
import com.alibaba.fastjson.parser.DefaultJSONParser.ResolveTask; //导入依赖的package包/类
@Override
public void parseField(DefaultJSONParser parser, Object object, Type objectType, Map<String, Object> fieldValues) {
if (fieldValueDeserilizer == null) {
fieldValueDeserilizer = parser.getConfig().getDeserializer(fieldInfo);
}
Object value = fieldValueDeserilizer.deserialze(parser, getFieldType(), fieldInfo.getName());
if (parser.getResolveStatus() == DefaultJSONParser.NeedToResolve) {
ResolveTask task = parser.getLastResolveTask();
task.setFieldDeserializer(this);
task.setOwnerContext(parser.getContext());
parser.setResolveStatus(DefaultJSONParser.NONE);
} else {
if (object == null) {
fieldValues.put(fieldInfo.getName(), value);
} else {
setValue(object, value);
}
}
}
开发者ID:baogongtc,项目名称:android_http_demo,代码行数:21,代码来源:DefaultFieldDeserializer.java
示例4: handleResovleTask
import com.alibaba.fastjson.parser.DefaultJSONParser.ResolveTask; //导入依赖的package包/类
public static void handleResovleTask(DefaultJSONParser parser, Object value) {
List<ResolveTask> resolveTaskList = parser.getResolveTaskListDirect();
if (resolveTaskList == null) {
return;
}
int size = resolveTaskList.size();
for (int i = 0; i < size; ++i) {
ResolveTask task = resolveTaskList.get(i);
FieldDeserializer fieldDeser = task.getFieldDeserializer();
if (fieldDeser == null) {
continue;
}
Object object = null;
if (task.getOwnerContext() != null) {
object = task.getOwnerContext().getObject();
}
String ref = task.getReferenceValue();
Object refValue;
if (ref.startsWith("$")) {
refValue = parser.getObject(ref);
} else {
refValue = task.getContext().getObject();
}
fieldDeser.setValue(object, refValue);
}
}
开发者ID:liufeiit,项目名称:itmarry,代码行数:30,代码来源:JSON.java
示例5: handleResovleTask
import com.alibaba.fastjson.parser.DefaultJSONParser.ResolveTask; //导入依赖的package包/类
public static <T> int handleResovleTask(DefaultJSONParser parser, T value) {
if (parser.isEnabled(Feature.DisableCircularReferenceDetect)) {
return 0;
}
int size = parser.getResolveTaskList().size();
for (int i = 0; i < size; ++i) {
ResolveTask task = parser.getResolveTaskList().get(i);
FieldDeserializer fieldDeser = task.getFieldDeserializer();
Object object = null;
if (task.getOwnerContext() != null) {
object = task.getOwnerContext().getObject();
}
String ref = task.getReferenceValue();
Object refValue;
if (ref.startsWith("$")) {
refValue = parser.getObject(ref);
} else {
refValue = task.getContext().getObject();
}
fieldDeser.setValue(object, refValue);
}
return size;
}
开发者ID:baogongtc,项目名称:android_http_demo,代码行数:28,代码来源:JSON.java
示例6: _deserialze_obj
import com.alibaba.fastjson.parser.DefaultJSONParser.ResolveTask; //导入依赖的package包/类
private void _deserialze_obj(Context context, MethodVisitor mw, Label reset_, FieldInfo fieldInfo,
Class<?> fieldClass, int i) {
Label matched_ = new Label();
Label _end_if = new Label();
mw.visitVarInsn(ALOAD, context.var("lexer"));
mw.visitVarInsn(ALOAD, 0);
mw.visitFieldInsn(GETFIELD, context.className, fieldInfo.name + "_asm_prefix__", "[C");
mw.visitMethodInsn(INVOKEVIRTUAL, JSONLexerBase, "matchField", "([C)Z");
mw.visitJumpInsn(IFNE, matched_);
mw.visitInsn(ACONST_NULL);
mw.visitVarInsn(ASTORE, context.var(fieldInfo.name + "_asm"));
mw.visitJumpInsn(GOTO, _end_if);
mw.visitLabel(matched_);
_setFlag(mw, context, i);
// increment matchedCount
mw.visitVarInsn(ILOAD, context.var("matchedCount"));
mw.visitInsn(ICONST_1);
mw.visitInsn(IADD);
mw.visitVarInsn(ISTORE, context.var("matchedCount"));
_deserObject(context, mw, fieldInfo, fieldClass, i);
mw.visitVarInsn(ALOAD, 1);
mw.visitMethodInsn(INVOKEVIRTUAL, DefaultJSONParser, "getResolveStatus", "()I");
mw.visitLdcInsn(com.alibaba.fastjson.parser.DefaultJSONParser.NeedToResolve);
mw.visitJumpInsn(IF_ICMPNE, _end_if);
mw.visitVarInsn(ALOAD, 1);
mw.visitMethodInsn(INVOKEVIRTUAL, DefaultJSONParser, "getLastResolveTask", "()" + desc(ResolveTask.class));
mw.visitVarInsn(ASTORE, context.var("resolveTask"));
mw.visitVarInsn(ALOAD, context.var("resolveTask"));
mw.visitVarInsn(ALOAD, 1);
mw.visitMethodInsn(INVOKEVIRTUAL, DefaultJSONParser, "getContext", "()" + desc(ParseContext.class));
mw.visitFieldInsn(PUTFIELD, type(ResolveTask.class), "ownerContext", desc(ParseContext.class));
mw.visitVarInsn(ALOAD, context.var("resolveTask"));
mw.visitVarInsn(ALOAD, 0);
mw.visitLdcInsn(fieldInfo.name);
mw.visitMethodInsn(INVOKEVIRTUAL, type(JavaBeanDeserializer.class), "getFieldDeserializer",
"(Ljava/lang/String;)" + desc(FieldDeserializer.class));
mw.visitFieldInsn(PUTFIELD, type(ResolveTask.class), "fieldDeserializer", desc(FieldDeserializer.class));
mw.visitVarInsn(ALOAD, 1);
mw.visitLdcInsn(com.alibaba.fastjson.parser.DefaultJSONParser.NONE);
mw.visitMethodInsn(INVOKEVIRTUAL, DefaultJSONParser, "setResolveStatus", "(I)V");
mw.visitLabel(_end_if);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:56,代码来源:ASMDeserializerFactory.java
示例7: parseMap
import com.alibaba.fastjson.parser.DefaultJSONParser.ResolveTask; //导入依赖的package包/类
public static Object parseMap(DefaultJSONParser parser, Map<Object, Object> map, Type keyType, Type valueType, Object fieldName) {
JSONLexer lexer = parser.getLexer();
if (lexer.token() == 12 || lexer.token() == 16) {
ObjectDeserializer keyDeserializer = parser.getConfig().getDeserializer(keyType);
ObjectDeserializer valueDeserializer = parser.getConfig().getDeserializer(valueType);
lexer.nextToken(keyDeserializer.getFastMatchToken());
ParseContext context = parser.getContext();
while (lexer.token() != 13) {
try {
if (lexer.token() == 4 && lexer.isRef()) {
Map<Object, Object> object = null;
lexer.nextTokenWithColon(4);
if (lexer.token() == 4) {
String ref = lexer.stringVal();
if ("..".equals(ref)) {
object = context.getParentContext().getObject();
} else if ("$".equals(ref)) {
ParseContext rootContext = context;
while (rootContext.getParentContext() != null) {
rootContext = rootContext.getParentContext();
}
object = rootContext.getObject();
} else {
parser.addResolveTask(new ResolveTask(context, ref));
parser.setResolveStatus(1);
}
lexer.nextToken(13);
if (lexer.token() != 13) {
throw new JSONException("illegal ref");
}
lexer.nextToken(16);
parser.setContext(context);
return object;
}
throw new JSONException("illegal ref, " + JSONToken.name(lexer.token()));
}
if (map.size() == 0 && lexer.token() == 4 && JSON.DEFAULT_TYPE_KEY.equals(lexer.stringVal())) {
lexer.nextTokenWithColon(4);
lexer.nextToken(16);
if (lexer.token() == 13) {
lexer.nextToken();
return map;
}
lexer.nextToken(keyDeserializer.getFastMatchToken());
}
Object key = keyDeserializer.deserialze(parser, keyType, null);
if (lexer.token() != 17) {
throw new JSONException("syntax error, expect :, actual " + lexer.token());
}
lexer.nextToken(valueDeserializer.getFastMatchToken());
map.put(key, valueDeserializer.deserialze(parser, valueType, key));
if (lexer.token() == 16) {
lexer.nextToken(keyDeserializer.getFastMatchToken());
}
} finally {
parser.setContext(context);
}
}
lexer.nextToken(16);
parser.setContext(context);
return map;
}
throw new JSONException("syntax error, expect {, actual " + lexer.tokenName());
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:65,代码来源:MapDeserializer.java
示例8: _deserialze_obj
import com.alibaba.fastjson.parser.DefaultJSONParser.ResolveTask; //导入依赖的package包/类
private void _deserialze_obj(Context context, MethodVisitor mw, Label reset_, FieldInfo fieldInfo,
Class<?> fieldClass, int i) {
Label matched_ = new Label();
Label _end_if = new Label();
mw.visitVarInsn(ALOAD, context.var("lexer"));
mw.visitVarInsn(ALOAD, 0);
mw.visitFieldInsn(GETFIELD, context.getClassName(), fieldInfo.getName() + "_asm_prefix__", "[C");
mw.visitMethodInsn(INVOKEVIRTUAL, getType(JSONLexerBase.class), "matchField", "([C)Z");
mw.visitJumpInsn(IFNE, matched_);
mw.visitInsn(ACONST_NULL);
mw.visitVarInsn(ASTORE, context.var(fieldInfo.getName() + "_asm"));
mw.visitJumpInsn(GOTO, _end_if);
mw.visitLabel(matched_);
_setFlag(mw, context, i);
// increment matchedCount
mw.visitVarInsn(ILOAD, context.var("matchedCount"));
mw.visitInsn(ICONST_1);
mw.visitInsn(IADD);
mw.visitVarInsn(ISTORE, context.var("matchedCount"));
_deserObject(context, mw, fieldInfo, fieldClass);
mw.visitVarInsn(ALOAD, 1);
mw.visitMethodInsn(INVOKEVIRTUAL, getType(DefaultJSONParser.class), "getResolveStatus", "()I");
mw.visitFieldInsn(GETSTATIC, getType(DefaultJSONParser.class), "NeedToResolve", "I");
mw.visitJumpInsn(IF_ICMPNE, _end_if);
// ResolveTask task = parser.getLastResolveTask();
// task.setFieldDeserializer(this);
// task.setOwnerContext(parser.getContext());
mw.visitVarInsn(ALOAD, 1);
mw.visitMethodInsn(INVOKEVIRTUAL, getType(DefaultJSONParser.class), "getLastResolveTask",
"()" + getDesc(ResolveTask.class));
mw.visitVarInsn(ASTORE, context.var("resolveTask"));
mw.visitVarInsn(ALOAD, context.var("resolveTask"));
mw.visitVarInsn(ALOAD, 1);
mw.visitMethodInsn(INVOKEVIRTUAL, getType(DefaultJSONParser.class), "getContext", "()"
+ getDesc(ParseContext.class));
mw.visitMethodInsn(INVOKEVIRTUAL, getType(ResolveTask.class), "setOwnerContext", "("
+ getDesc(ParseContext.class)
+ ")V");
mw.visitVarInsn(ALOAD, context.var("resolveTask"));
mw.visitVarInsn(ALOAD, 0);
mw.visitLdcInsn(fieldInfo.getName());
mw.visitMethodInsn(INVOKEVIRTUAL, getType(ASMJavaBeanDeserializer.class), "getFieldDeserializer",
"(Ljava/lang/String;)" + getDesc(FieldDeserializer.class));
mw.visitMethodInsn(INVOKEVIRTUAL, getType(ResolveTask.class), "setFieldDeserializer",
"(" + getDesc(FieldDeserializer.class) + ")V");
mw.visitVarInsn(ALOAD, 1);
mw.visitFieldInsn(GETSTATIC, getType(DefaultJSONParser.class), "NONE", "I");
mw.visitMethodInsn(INVOKEVIRTUAL, getType(DefaultJSONParser.class), "setResolveStatus", "(I)V");
mw.visitLabel(_end_if);
}
开发者ID:liufeiit,项目名称:itmarry,代码行数:65,代码来源:ASMDeserializerFactory.java
注:本文中的com.alibaba.fastjson.parser.DefaultJSONParser.ResolveTask类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论