本文整理汇总了Java中com.alibaba.fastjson.util.FieldInfo.getFieldClass方法的典型用法代码示例。如果您正苦于以下问题:Java FieldInfo.getFieldClass方法的具体用法?Java FieldInfo.getFieldClass怎么用?Java FieldInfo.getFieldClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.fastjson.util.FieldInfo
的用法示例。
在下文中一共展示了FieldInfo.getFieldClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFieldDeserializerWithoutASM
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
public FieldDeserializer createFieldDeserializerWithoutASM(ParserConfig mapping, Class<?> clazz, FieldInfo fieldInfo) {
Class<?> fieldClass = fieldInfo.getFieldClass();
if (fieldClass == Boolean.TYPE || fieldClass == Boolean.class) {
return new BooleanFieldDeserializer(mapping, clazz, fieldInfo);
}
if (fieldClass == Integer.TYPE || fieldClass == Integer.class) {
return new IntegerFieldDeserializer(mapping, clazz, fieldInfo);
}
if (fieldClass == Long.TYPE || fieldClass == Long.class) {
return new LongFieldDeserializer(mapping, clazz, fieldInfo);
}
if (fieldClass == String.class) {
return new StringFieldDeserializer(mapping, clazz, fieldInfo);
}
if (fieldClass == List.class || fieldClass == ArrayList.class) {
return new ArrayListTypeFieldDeserializer(mapping, clazz, fieldInfo);
}
return new DefaultFieldDeserializer(mapping, clazz, fieldInfo);
}
示例2: createFieldDeserializerWithoutASM
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
public FieldDeserializer createFieldDeserializerWithoutASM(ParserConfig mapping, Class<?> clazz, FieldInfo fieldInfo) {
Class<?> fieldClass = fieldInfo.getFieldClass();
if (fieldClass == boolean.class || fieldClass == Boolean.class) {
return new BooleanFieldDeserializer(mapping, clazz, fieldInfo);
}
if (fieldClass == int.class || fieldClass == Integer.class) {
return new IntegerFieldDeserializer(mapping, clazz, fieldInfo);
}
if (fieldClass == long.class || fieldClass == Long.class) {
return new LongFieldDeserializer(mapping, clazz, fieldInfo);
}
if (fieldClass == String.class) {
return new StringFieldDeserializer(mapping, clazz, fieldInfo);
}
if (fieldClass == List.class || fieldClass == ArrayList.class) {
return new ArrayListTypeFieldDeserializer(mapping, clazz, fieldInfo);
}
return new DefaultFieldDeserializer(mapping, clazz, fieldInfo);
}
示例3: createFieldDeserializer
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
public FieldDeserializer createFieldDeserializer(ParserConfig mapping, Class<?> clazz, FieldInfo fieldInfo) throws Exception {
Class<?> fieldClass = fieldInfo.getFieldClass();
if (fieldClass == Integer.TYPE || fieldClass == Long.TYPE || fieldClass == String.class) {
return createStringFieldDeserializer(mapping, clazz, fieldInfo);
}
return mapping.createFieldDeserializerWithoutASM(mapping, clazz, fieldInfo);
}
示例4: createFieldSerializer
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
public FieldSerializer createFieldSerializer(FieldInfo fieldInfo) {
Class<?> clazz = fieldInfo.getFieldClass();
if (clazz == Number.class) {
return new NumberFieldSerializer(fieldInfo);
}
return new ObjectFieldSerializer(fieldInfo);
}
示例5: createFieldDeserializer
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
public FieldDeserializer createFieldDeserializer(ParserConfig mapping, Class<?> clazz, FieldInfo fieldInfo) {
boolean asmEnable = this.asmEnable;
if (asmEnable) {
Class<?> superClass = clazz;
while (Modifier.isPublic(superClass.getModifiers())) {
superClass = superClass.getSuperclass();
if (superClass != Object.class) {
if (superClass == null) {
break;
}
}
break;
}
asmEnable = false;
}
if (fieldInfo.getFieldClass() == Class.class) {
asmEnable = false;
}
if (asmEnable && this.asmFactory != null && this.asmFactory.isExternalClass(clazz)) {
asmEnable = false;
}
if (!asmEnable) {
return createFieldDeserializerWithoutASM(mapping, clazz, fieldInfo);
}
try {
return this.asmFactory.createFieldDeserializer(mapping, clazz, fieldInfo);
} catch (Throwable th) {
return createFieldDeserializerWithoutASM(mapping, clazz, fieldInfo);
}
}
示例6: _notWriteDefault
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
private void _notWriteDefault(MethodVisitor mw, FieldInfo property, Context context, Label _end) {
Label elseLabel = new Label();
mw.visitVarInsn(25, context.var("out"));
mw.visitFieldInsn(178, "com/alibaba/fastjson/serializer/SerializerFeature", "NotWriteDefaultValue", "Lcom/alibaba/fastjson/serializer/SerializerFeature;");
mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "isEnabled", "(Lcom/alibaba/fastjson/serializer/SerializerFeature;)Z");
mw.visitJumpInsn(153, elseLabel);
Class<?> propertyClass = property.getFieldClass();
if (propertyClass == Boolean.TYPE) {
mw.visitVarInsn(21, context.var("boolean"));
mw.visitJumpInsn(153, _end);
} else if (propertyClass == Byte.TYPE) {
mw.visitVarInsn(21, context.var("byte"));
mw.visitJumpInsn(153, _end);
} else if (propertyClass == Short.TYPE) {
mw.visitVarInsn(21, context.var("short"));
mw.visitJumpInsn(153, _end);
} else if (propertyClass == Integer.TYPE) {
mw.visitVarInsn(21, context.var("int"));
mw.visitJumpInsn(153, _end);
} else if (propertyClass == Long.TYPE) {
mw.visitVarInsn(22, context.var("long"));
mw.visitInsn(9);
mw.visitInsn(148);
mw.visitJumpInsn(153, _end);
} else if (propertyClass == Float.TYPE) {
mw.visitVarInsn(23, context.var("float"));
mw.visitInsn(11);
mw.visitInsn(149);
mw.visitJumpInsn(153, _end);
} else if (propertyClass == Double.TYPE) {
mw.visitVarInsn(24, context.var("double"));
mw.visitInsn(14);
mw.visitInsn(151);
mw.visitJumpInsn(153, _end);
}
mw.visitLabel(elseLabel);
}
示例7: createFieldDeserializer
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
public FieldDeserializer createFieldDeserializer(ParserConfig mapping, Class<?> clazz, FieldInfo fieldInfo)
throws Exception {
Class<?> fieldClass = fieldInfo.getFieldClass();
if (fieldClass == int.class || fieldClass == long.class || fieldClass == String.class) {
return createStringFieldDeserializer(mapping, clazz, fieldInfo);
}
FieldDeserializer fieldDeserializer = mapping.createFieldDeserializerWithoutASM(mapping, clazz, fieldInfo);
return fieldDeserializer;
}
示例8: createFieldDeserializer
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
public FieldDeserializer createFieldDeserializer(ParserConfig mapping, Class<?> clazz, FieldInfo fieldInfo) {
boolean asmEnable = this.asmEnable;
if (asmEnable) {
Class<?> superClass = clazz;
for (;;) {
if (!Modifier.isPublic(superClass.getModifiers())) {
asmEnable = false;
break;
}
superClass = superClass.getSuperclass();
if (superClass == Object.class || superClass == null) {
break;
}
}
}
if (fieldInfo.getFieldClass() == Class.class) {
asmEnable = false;
}
if (asmEnable && asmFactory != null && asmFactory.isExternalClass(clazz)) {
asmEnable = false;
}
if (!asmEnable) {
return createFieldDeserializerWithoutASM(mapping, clazz, fieldInfo);
}
try {
return asmFactory.createFieldDeserializer(mapping, clazz, fieldInfo);
} catch (Throwable e) {
// skip
}
return createFieldDeserializerWithoutASM(mapping, clazz, fieldInfo);
}
示例9: _loadAndSet
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
private void _loadAndSet(Context context, MethodVisitor mw, FieldInfo fieldInfo) {
Class<?> fieldClass = fieldInfo.getFieldClass();
Type fieldType = fieldInfo.getFieldType();
if (fieldClass == Boolean.TYPE) {
mw.visitVarInsn(25, context.var("instance"));
mw.visitVarInsn(21, context.var(fieldInfo.getName() + "_asm"));
_set(context, mw, fieldInfo);
} else if (fieldClass == Byte.TYPE || fieldClass == Short.TYPE || fieldClass == Integer.TYPE || fieldClass == Character.TYPE) {
mw.visitVarInsn(25, context.var("instance"));
mw.visitVarInsn(21, context.var(fieldInfo.getName() + "_asm"));
_set(context, mw, fieldInfo);
} else if (fieldClass == Long.TYPE) {
mw.visitVarInsn(25, context.var("instance"));
mw.visitVarInsn(22, context.var(fieldInfo.getName() + "_asm", 2));
if (fieldInfo.getMethod() != null) {
mw.visitMethodInsn(182, ASMUtils.getType(context.getClazz()), fieldInfo.getMethod().getName(), ASMUtils.getDesc(fieldInfo.getMethod()));
if (!fieldInfo.getMethod().getReturnType().equals(Void.TYPE)) {
mw.visitInsn(87);
return;
}
return;
}
mw.visitFieldInsn(181, ASMUtils.getType(fieldInfo.getDeclaringClass()), fieldInfo.getField().getName(), ASMUtils.getDesc(fieldInfo.getFieldClass()));
} else if (fieldClass == Float.TYPE) {
mw.visitVarInsn(25, context.var("instance"));
mw.visitVarInsn(23, context.var(fieldInfo.getName() + "_asm"));
_set(context, mw, fieldInfo);
} else if (fieldClass == Double.TYPE) {
mw.visitVarInsn(25, context.var("instance"));
mw.visitVarInsn(24, context.var(fieldInfo.getName() + "_asm", 2));
_set(context, mw, fieldInfo);
} else if (fieldClass == String.class) {
mw.visitVarInsn(25, context.var("instance"));
mw.visitVarInsn(25, context.var(fieldInfo.getName() + "_asm"));
_set(context, mw, fieldInfo);
} else if (fieldClass.isEnum()) {
mw.visitVarInsn(25, context.var("instance"));
mw.visitVarInsn(25, context.var(fieldInfo.getName() + "_asm"));
_set(context, mw, fieldInfo);
} else if (Collection.class.isAssignableFrom(fieldClass)) {
mw.visitVarInsn(25, context.var("instance"));
if (getCollectionItemClass(fieldType) == String.class) {
mw.visitVarInsn(25, context.var(fieldInfo.getName() + "_asm"));
mw.visitTypeInsn(192, ASMUtils.getType(fieldClass));
} else {
mw.visitVarInsn(25, context.var(fieldInfo.getName() + "_asm"));
}
_set(context, mw, fieldInfo);
} else {
mw.visitVarInsn(25, context.var("instance"));
mw.visitVarInsn(25, context.var(fieldInfo.getName() + "_asm"));
_set(context, mw, fieldInfo);
}
}
示例10: createJavaBeanDeserializer
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
public ObjectDeserializer createJavaBeanDeserializer(Class<?> clazz, Type type) {
boolean asmEnable = this.asmEnable;
if (asmEnable) {
Class<?> superClass = clazz;
while (Modifier.isPublic(superClass.getModifiers())) {
superClass = superClass.getSuperclass();
if (superClass != Object.class) {
if (superClass == null) {
break;
}
}
break;
}
asmEnable = false;
}
if (clazz.getTypeParameters().length != 0) {
asmEnable = false;
}
if (asmEnable && this.asmFactory != null && this.asmFactory.isExternalClass(clazz)) {
asmEnable = false;
}
if (asmEnable) {
asmEnable = ASMUtils.checkName(clazz.getName());
}
if (asmEnable) {
if (clazz.isInterface()) {
asmEnable = false;
}
DeserializeBeanInfo beanInfo = DeserializeBeanInfo.computeSetters(clazz, type);
if (beanInfo.getFieldList().size() > 200) {
asmEnable = false;
}
if (beanInfo.getDefaultConstructor() == null && !clazz.isInterface()) {
asmEnable = false;
}
for (FieldInfo fieldInfo : beanInfo.getFieldList()) {
if (fieldInfo.isGetOnly()) {
asmEnable = false;
break;
}
Class<?> fieldClass = fieldInfo.getFieldClass();
if (!Modifier.isPublic(fieldClass.getModifiers())) {
asmEnable = false;
break;
}
if (fieldClass.isMemberClass() && !Modifier.isStatic(fieldClass.getModifiers())) {
asmEnable = false;
}
if (!ASMUtils.checkName(fieldInfo.getMember().getName())) {
asmEnable = false;
}
}
}
if (asmEnable && clazz.isMemberClass() && !Modifier.isStatic(clazz.getModifiers())) {
asmEnable = false;
}
if (!asmEnable) {
return new JavaBeanDeserializer(this, clazz, type);
}
try {
return this.asmFactory.createJavaBeanDeserializer(this, clazz, type);
} catch (NoSuchMethodException e) {
return new JavaBeanDeserializer(this, clazz, type);
} catch (ASMException e2) {
return new JavaBeanDeserializer(this, clazz, type);
} catch (Exception e3) {
throw new JSONException("create asm deserializer error, " + clazz.getName(), e3);
}
}
示例11: _apply
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
private void _apply(MethodVisitor mw, FieldInfo property, Context context) {
Class<?> propertyClass = property.getFieldClass();
mw.visitVarInsn(25, context.serializer());
mw.visitVarInsn(25, context.obj());
mw.visitVarInsn(25, context.fieldName());
if (propertyClass == Byte.TYPE) {
mw.visitVarInsn(21, context.var("byte"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;B)Z");
} else if (propertyClass == Short.TYPE) {
mw.visitVarInsn(21, context.var("short"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;S)Z");
} else if (propertyClass == Integer.TYPE) {
mw.visitVarInsn(21, context.var("int"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;I)Z");
} else if (propertyClass == Character.TYPE) {
mw.visitVarInsn(21, context.var("char"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;C)Z");
} else if (propertyClass == Long.TYPE) {
mw.visitVarInsn(22, context.var("long", 2));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;J)Z");
} else if (propertyClass == Float.TYPE) {
mw.visitVarInsn(23, context.var("float"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;F)Z");
} else if (propertyClass == Double.TYPE) {
mw.visitVarInsn(24, context.var("double", 2));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;D)Z");
} else if (propertyClass == Boolean.TYPE) {
mw.visitVarInsn(21, context.var("boolean"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;B)Z");
} else if (propertyClass == BigDecimal.class) {
mw.visitVarInsn(25, context.var("decimal"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Z");
} else if (propertyClass == String.class) {
mw.visitVarInsn(25, context.var("string"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Z");
} else if (propertyClass.isEnum()) {
mw.visitVarInsn(25, context.var("enum"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Z");
} else if (List.class.isAssignableFrom(propertyClass)) {
mw.visitVarInsn(25, context.var("list"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Z");
} else {
mw.visitVarInsn(25, context.var("object"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "apply", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Z");
}
}
示例12: _processValue
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
private void _processValue(MethodVisitor mw, FieldInfo property, Context context) {
Class<?> propertyClass = property.getFieldClass();
mw.visitVarInsn(25, context.serializer());
mw.visitVarInsn(25, context.obj());
mw.visitVarInsn(25, context.fieldName());
if (propertyClass == Byte.TYPE) {
mw.visitVarInsn(21, context.var("byte"));
mw.visitMethodInsn(184, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;");
} else if (propertyClass == Short.TYPE) {
mw.visitVarInsn(21, context.var("short"));
mw.visitMethodInsn(184, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;");
} else if (propertyClass == Integer.TYPE) {
mw.visitVarInsn(21, context.var("int"));
mw.visitMethodInsn(184, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;");
} else if (propertyClass == Character.TYPE) {
mw.visitVarInsn(21, context.var("char"));
mw.visitMethodInsn(184, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;");
} else if (propertyClass == Long.TYPE) {
mw.visitVarInsn(22, context.var("long", 2));
mw.visitMethodInsn(184, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;");
} else if (propertyClass == Float.TYPE) {
mw.visitVarInsn(23, context.var("float"));
mw.visitMethodInsn(184, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;");
} else if (propertyClass == Double.TYPE) {
mw.visitVarInsn(24, context.var("double", 2));
mw.visitMethodInsn(184, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;");
} else if (propertyClass == Boolean.TYPE) {
mw.visitVarInsn(21, context.var("boolean"));
mw.visitMethodInsn(184, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;");
} else if (propertyClass == BigDecimal.class) {
mw.visitVarInsn(25, context.var("decimal"));
} else if (propertyClass == String.class) {
mw.visitVarInsn(25, context.var("string"));
} else if (propertyClass.isEnum()) {
mw.visitVarInsn(25, context.var("enum"));
} else if (List.class.isAssignableFrom(propertyClass)) {
mw.visitVarInsn(25, context.var("list"));
} else {
mw.visitVarInsn(25, context.var("object"));
}
mw.visitVarInsn(58, context.original());
mw.visitVarInsn(25, context.original());
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "processValue", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;");
mw.visitVarInsn(58, context.processValue());
}
示例13: _processKey
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
private void _processKey(MethodVisitor mw, FieldInfo property, Context context) {
Class<?> propertyClass = property.getFieldClass();
mw.visitVarInsn(25, context.serializer());
mw.visitVarInsn(25, context.obj());
mw.visitVarInsn(25, context.fieldName());
if (propertyClass == Byte.TYPE) {
mw.visitVarInsn(21, context.var("byte"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;B)Ljava/lang/String;");
} else if (propertyClass == Short.TYPE) {
mw.visitVarInsn(21, context.var("short"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;S)Ljava/lang/String;");
} else if (propertyClass == Integer.TYPE) {
mw.visitVarInsn(21, context.var("int"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;I)Ljava/lang/String;");
} else if (propertyClass == Character.TYPE) {
mw.visitVarInsn(21, context.var("char"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;C)Ljava/lang/String;");
} else if (propertyClass == Long.TYPE) {
mw.visitVarInsn(22, context.var("long", 2));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;J)Ljava/lang/String;");
} else if (propertyClass == Float.TYPE) {
mw.visitVarInsn(23, context.var("float"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;F)Ljava/lang/String;");
} else if (propertyClass == Double.TYPE) {
mw.visitVarInsn(24, context.var("double", 2));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;D)Ljava/lang/String;");
} else if (propertyClass == Boolean.TYPE) {
mw.visitVarInsn(21, context.var("boolean"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Z)Ljava/lang/String;");
} else if (propertyClass == BigDecimal.class) {
mw.visitVarInsn(25, context.var("decimal"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;");
} else if (propertyClass == String.class) {
mw.visitVarInsn(25, context.var("string"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;");
} else if (propertyClass.isEnum()) {
mw.visitVarInsn(25, context.var("enum"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;");
} else if (List.class.isAssignableFrom(propertyClass)) {
mw.visitVarInsn(25, context.var("list"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;");
} else {
mw.visitVarInsn(25, context.var("object"));
mw.visitMethodInsn(184, "com/alibaba/fastjson/serializer/FilterUtils", "processKey", "(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;");
}
mw.visitVarInsn(58, context.fieldName());
}
示例14: _if_write_null
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
private void _if_write_null(MethodVisitor mw, FieldInfo fieldInfo, Context context) {
Class<?> propertyClass = fieldInfo.getFieldClass();
Label _if = new Label();
Label _else = new Label();
Label _write_null = new Label();
Label _end_if = new Label();
mw.visitLabel(_if);
boolean writeNull = false;
boolean writeNullNumberAsZero = false;
boolean writeNullStringAsEmpty = false;
boolean writeNullBooleanAsFalse = false;
boolean writeNullListAsEmpty = false;
JSONField annotation = (JSONField) fieldInfo.getAnnotation(JSONField.class);
if (annotation != null) {
for (SerializerFeature feature : annotation.serialzeFeatures()) {
if (feature == SerializerFeature.WriteMapNullValue) {
writeNull = true;
} else if (feature == SerializerFeature.WriteNullNumberAsZero) {
writeNullNumberAsZero = true;
} else if (feature == SerializerFeature.WriteNullStringAsEmpty) {
writeNullStringAsEmpty = true;
} else if (feature == SerializerFeature.WriteNullBooleanAsFalse) {
writeNullBooleanAsFalse = true;
} else if (feature == SerializerFeature.WriteNullListAsEmpty) {
writeNullListAsEmpty = true;
}
}
}
if (!writeNull) {
mw.visitVarInsn(25, context.var("out"));
mw.visitFieldInsn(178, "com/alibaba/fastjson/serializer/SerializerFeature", "WriteMapNullValue", "Lcom/alibaba/fastjson/serializer/SerializerFeature;");
mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "isEnabled", "(Lcom/alibaba/fastjson/serializer/SerializerFeature;)Z");
mw.visitJumpInsn(153, _else);
}
mw.visitLabel(_write_null);
mw.visitVarInsn(25, context.var("out"));
mw.visitVarInsn(21, context.var("seperator"));
mw.visitVarInsn(25, context.fieldName());
if (propertyClass == String.class || propertyClass == Character.class) {
if (writeNullStringAsEmpty) {
mw.visitLdcInsn("");
mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;Ljava/lang/String;)V");
} else {
mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldNullString", "(CLjava/lang/String;)V");
}
} else if (Number.class.isAssignableFrom(propertyClass)) {
if (writeNullNumberAsZero) {
mw.visitInsn(3);
mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;I)V");
} else {
mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldNullNumber", "(CLjava/lang/String;)V");
}
} else if (propertyClass == Boolean.class) {
if (writeNullBooleanAsFalse) {
mw.visitInsn(3);
mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;Z)V");
} else {
mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldNullBoolean", "(CLjava/lang/String;)V");
}
} else if (!Collection.class.isAssignableFrom(propertyClass) && !propertyClass.isArray()) {
mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldNull", "(CLjava/lang/String;)V");
} else if (writeNullListAsEmpty) {
mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldEmptyList", "(CLjava/lang/String;)V");
} else {
mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldNullList", "(CLjava/lang/String;)V");
}
_seperator(mw, context);
mw.visitJumpInsn(167, _end_if);
mw.visitLabel(_else);
mw.visitLabel(_end_if);
}
示例15: createFieldSerializer
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
public FieldSerializer createFieldSerializer(FieldInfo fieldInfo) {
if (fieldInfo.getFieldClass() == Number.class) {
return new NumberFieldSerializer(fieldInfo);
}
return new ObjectFieldSerializer(fieldInfo);
}