本文整理汇总了Java中com.alibaba.fastjson.parser.ParseContext类的典型用法代码示例。如果您正苦于以下问题:Java ParseContext类的具体用法?Java ParseContext怎么用?Java ParseContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParseContext类属于com.alibaba.fastjson.parser包,在下文中一共展示了ParseContext类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parseField
import com.alibaba.fastjson.parser.ParseContext; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public void parseField(DefaultJSONParser parser, Object object, Type objectType, Map<String, Object> fieldValues) {
JSONLexer lexer = parser.lexer;
final int token = lexer.token();
if (token == JSONToken.NULL
|| (token == JSONToken.LITERAL_STRING && lexer.stringVal().length() == 0)) {
setValue(object, null);
return;
}
ArrayList list = new ArrayList();
ParseContext context = parser.getContext();
parser.setContext(context, object, fieldInfo.name);
parseArray(parser, objectType, list);
parser.setContext(context);
if (object == null) {
fieldValues.put(fieldInfo.name, list);
} else {
setValue(object, list);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:ArrayListTypeFieldDeserializer.java
示例2: deserialze
import com.alibaba.fastjson.parser.ParseContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
ParseContext cxt = parser.getContext();
Object object = parser.parse(fieldName);
if (object == null) {
return null;
}
String moneyCentStr = null;
if (object instanceof JSONObject) {//历史数据兼容
JSONObject jsonObject = (JSONObject) object;
moneyCentStr = jsonObject.getString("cent");
} else if (object instanceof String) {
moneyCentStr = (String) object;
} else {
throw new RuntimeException("money属性反序列化失败,不支持的类型:" + object.getClass().getName());
}
if (moneyCentStr.length() != 0) {
Money m = new Money();
m.cent = Long.valueOf(moneyCentStr);
return (T) m;
}
return null;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:A20170327_0.java
示例3: parseField
import com.alibaba.fastjson.parser.ParseContext; //导入依赖的package包/类
public void parseField(DefaultJSONParser parser, Object object, Type objectType, Map<String, Object> fieldValues) {
if (parser.getLexer().token() == 8) {
setValue(object, null);
return;
}
ArrayList list = new ArrayList();
ParseContext context = parser.getContext();
parser.setContext(context, object, this.fieldInfo.getName());
parseArray(parser, objectType, list);
parser.setContext(context);
if (object == null) {
fieldValues.put(this.fieldInfo.getName(), list);
} else {
setValue(object, (Object) list);
}
}
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:ArrayListTypeFieldDeserializer.java
示例4: deserialze
import com.alibaba.fastjson.parser.ParseContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
final JSONLexer lexer = parser.getLexer();
if (lexer.token() == JSONToken.NULL) {
lexer.nextToken(JSONToken.COMMA);
return null;
}
Map<Object, Object> map = createMap(type);
ParseContext context = parser.getContext();
try {
parser.setContext(context, map, fieldName);
return (T) deserialze(parser, type, fieldName, map);
} finally {
parser.setContext(context);
}
}
开发者ID:uavorg,项目名称:uavstack,代码行数:20,代码来源:MapDeserializer.java
示例5: parseField
import com.alibaba.fastjson.parser.ParseContext; //导入依赖的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
示例6: parseField
import com.alibaba.fastjson.parser.ParseContext; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public void parseField(DefaultJSONParser parser, Object object, Type objectType, Map<String, Object> fieldValues) {
if (parser.getLexer().token() == JSONToken.NULL) {
setValue(object, null);
return;
}
ArrayList list = new ArrayList();
ParseContext context = parser.getContext();
parser.setContext(context, object, fieldInfo.getName());
parseArray(parser, objectType, list);
parser.setContext(context);
if (object == null) {
fieldValues.put(fieldInfo.getName(), list);
} else {
setValue(object, list);
}
}
开发者ID:uavorg,项目名称:uavstack,代码行数:23,代码来源:ArrayListTypeFieldDeserializer.java
示例7: _setContext
import com.alibaba.fastjson.parser.ParseContext; //导入依赖的package包/类
private void _setContext(Context context, MethodVisitor mw) {
mw.visitVarInsn(ALOAD, 1); // parser
mw.visitVarInsn(ALOAD, context.var("context"));
mw.visitMethodInsn(INVOKEVIRTUAL, getType(DefaultJSONParser.class), "setContext",
"(" + ASMUtils.getDesc(ParseContext.class) + ")V");
Label endIf_ = new Label();
mw.visitVarInsn(ALOAD, context.var("childContext"));
mw.visitJumpInsn(IFNULL, endIf_);
mw.visitVarInsn(ALOAD, context.var("childContext"));
mw.visitVarInsn(ALOAD, context.var("instance"));
mw.visitMethodInsn(INVOKEVIRTUAL, getType(ParseContext.class), "setObject", "(Ljava/lang/Object;)V");
mw.visitLabel(endIf_);
}
开发者ID:liufeiit,项目名称:itmarry,代码行数:17,代码来源:ASMDeserializerFactory.java
示例8: deserialze
import com.alibaba.fastjson.parser.ParseContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
final JSONScanner lexer = parser.getLexer();
if (lexer.token() == JSONToken.NULL) {
lexer.nextToken(JSONToken.COMMA);
return null;
}
Map<Object, Object> map = createMap(type);
ParseContext context = parser.getContext();
try {
parser.setContext(context, map, fieldName);
if (lexer.token() == JSONToken.RBRACE) {
lexer.nextToken(JSONToken.COMMA);
return (T) map;
}
return (T) deserialze(parser, type, fieldName, map);
} finally {
parser.setContext(context);
}
}
开发者ID:baogongtc,项目名称:android_http_demo,代码行数:26,代码来源:MapDeserializer.java
示例9: _setContext
import com.alibaba.fastjson.parser.ParseContext; //导入依赖的package包/类
private void _setContext(Context context, MethodVisitor mw) {
mw.visitVarInsn(ALOAD, 1); // parser
mw.visitVarInsn(ALOAD, context.var("context"));
mw.visitMethodInsn(INVOKEVIRTUAL, DefaultJSONParser, "setContext", "(" + desc(ParseContext.class) + ")V");
Label endIf_ = new Label();
mw.visitVarInsn(ALOAD, context.var("childContext"));
mw.visitJumpInsn(IFNULL, endIf_);
mw.visitVarInsn(ALOAD, context.var("childContext"));
mw.visitVarInsn(ALOAD, context.var("instance"));
mw.visitFieldInsn(PUTFIELD, type(ParseContext.class), "object", "Ljava/lang/Object;");
mw.visitLabel(endIf_);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:ASMDeserializerFactory.java
示例10: deserialze
import com.alibaba.fastjson.parser.ParseContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.NULL) {
lexer.nextToken(JSONToken.COMMA);
return null;
}
if (lexer.token() != JSONToken.LBRACE && lexer.token() != JSONToken.COMMA) {
throw new JSONException("syntax error");
}
lexer.nextToken();
T obj;
if (type == Point.class) {
obj = (T) parsePoint(parser, fieldName);
} else if (type == Rectangle.class) {
obj = (T) parseRectangle(parser);
} else if (type == Color.class) {
obj = (T) parseColor(parser);
} else if (type == Font.class) {
obj = (T) parseFont(parser);
} else {
throw new JSONException("not support awt class : " + type);
}
ParseContext context = parser.getContext();
parser.setContext(obj, fieldName);
parser.setContext(context);
return obj;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:35,代码来源:AwtCodec.java
示例11: _deserialze_obj
import com.alibaba.fastjson.parser.ParseContext; //导入依赖的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
示例12: parseField
import com.alibaba.fastjson.parser.ParseContext; //导入依赖的package包/类
@Override
public void parseField(DefaultJSONParser parser, Object object, Type objectType, Map<String, Object> fieldValues) {
if (fieldValueDeserilizer == null) {
getFieldValueDeserilizer(parser.getConfig());
}
Type fieldType = fieldInfo.fieldType;
if (objectType instanceof ParameterizedType) {
ParseContext objContext = parser.getContext();
objContext.type = objectType;
fieldType = FieldInfo.getFieldType(this.clazz, objectType, fieldType);
}
// ContextObjectDeserializer
Object value;
if (fieldValueDeserilizer instanceof JavaBeanDeserializer) {
JavaBeanDeserializer javaBeanDeser = (JavaBeanDeserializer) fieldValueDeserilizer;
value = javaBeanDeser.deserialze(parser, fieldType, fieldInfo.name, fieldInfo.parserFeatures);
} else {
if (this.fieldInfo.format != null && fieldValueDeserilizer instanceof ContextObjectDeserializer) {
value = ((ContextObjectDeserializer) fieldValueDeserilizer) //
.deserialze(parser, fieldType,
fieldInfo.name,
fieldInfo.format,
fieldInfo.parserFeatures);
} else {
value = fieldValueDeserilizer.deserialze(parser, fieldType, fieldInfo.name);
}
}
if (parser.getResolveStatus() == DefaultJSONParser.NeedToResolve) {
DefaultJSONParser.ResolveTask task = parser.getLastResolveTask();
task.fieldDeserializer = this;
task.ownerContext = parser.getContext();
parser.setResolveStatus(DefaultJSONParser.NONE);
} else {
if (object == null) {
fieldValues.put(fieldInfo.name, value);
} else {
setValue(object, value);
}
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:43,代码来源:DefaultFieldDeserializerBug569.java
示例13: test_toString
import com.alibaba.fastjson.parser.ParseContext; //导入依赖的package包/类
public void test_toString() throws Exception {
Assert.assertEquals("$", new ParseContext(null, new Object(), "id").toString());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:ParseContextTest.java
示例14: test_getDescs
import com.alibaba.fastjson.parser.ParseContext; //导入依赖的package包/类
public void test_getDescs() throws Exception {
Assert.assertEquals("Lcom/alibaba/fastjson/parser/ParseContext;", ASMUtils.desc(ParseContext.class));
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:ASMUtilsTest.java
示例15: test_getType_null
import com.alibaba.fastjson.parser.ParseContext; //导入依赖的package包/类
public void test_getType_null() throws Exception {
Assert.assertNull(ASMUtils.getMethodType(ParseContext.class, "XX"));
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:ASMUtilsTest.java
示例16: parseMap
import com.alibaba.fastjson.parser.ParseContext; //导入依赖的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
示例17: _deserialze_obj
import com.alibaba.fastjson.parser.ParseContext; //导入依赖的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.ParseContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论