当前位置: 首页>>代码示例>>Java>>正文


Java FieldInfo.getFormat方法代码示例

本文整理汇总了Java中com.alibaba.fastjson.util.FieldInfo.getFormat方法的典型用法代码示例。如果您正苦于以下问题:Java FieldInfo.getFormat方法的具体用法?Java FieldInfo.getFormat怎么用?Java FieldInfo.getFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.fastjson.util.FieldInfo的用法示例。


在下文中一共展示了FieldInfo.getFormat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: _writeObject

import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
private void _writeObject(MethodVisitor mw, FieldInfo fieldInfo, Context context, Label _end) {
    String format = fieldInfo.getFormat();
    Label _not_null = new Label();
    mw.visitVarInsn(25, context.processValue());
    mw.visitJumpInsn(199, _not_null);
    _if_write_null(mw, fieldInfo, context);
    mw.visitJumpInsn(167, _end);
    mw.visitLabel(_not_null);
    mw.visitVarInsn(25, context.var("out"));
    mw.visitVarInsn(21, context.var("seperator"));
    mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "write", "(C)V");
    mw.visitVarInsn(25, context.var("out"));
    mw.visitVarInsn(25, context.fieldName());
    mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldName", "(Ljava/lang/String;)V");
    mw.visitVarInsn(25, context.serializer());
    mw.visitVarInsn(25, context.processValue());
    if (format != null) {
        mw.visitLdcInsn(format);
        mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/JSONSerializer", "writeWithFormat", "(Ljava/lang/Object;Ljava/lang/String;)V");
    } else {
        mw.visitVarInsn(25, context.fieldName());
        if ((fieldInfo.getFieldType() instanceof Class) && ((Class) fieldInfo.getFieldType()).isPrimitive()) {
            mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/JSONSerializer", "writeWithFieldName", "(Ljava/lang/Object;Ljava/lang/Object;)V");
        } else {
            mw.visitVarInsn(25, 0);
            mw.visitFieldInsn(180, context.getClassName(), fieldInfo.getName() + "_asm_fieldType", "Ljava/lang/reflect/Type;");
            mw.visitLdcInsn(Integer.valueOf(fieldInfo.getSerialzeFeatures()));
            mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/JSONSerializer", "writeWithFieldName", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/reflect/Type;I)V");
        }
    }
    _seperator(mw, context);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:33,代码来源:ASMSerializerFactory.java

示例2: BeanContext

import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
public BeanContext(Class<?> beanClass, FieldInfo fieldInfo){
    this.beanClass = beanClass;
    this.fieldInfo = fieldInfo;
    this.format = fieldInfo.getFormat();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:BeanContext.java

示例3: _writeObject

import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
private void _writeObject(MethodVisitor mw, FieldInfo fieldInfo, Context context, Label _end) {
    String format = fieldInfo.getFormat();

    Label _not_null = new Label();

    mw.visitVarInsn(ALOAD, context.processValue());
    mw.visitJumpInsn(IFNONNULL, _not_null); // if (obj == null)
    _if_write_null(mw, fieldInfo, context);
    mw.visitJumpInsn(GOTO, _end);

    mw.visitLabel(_not_null);
    // writeFieldNullNumber
    mw.visitVarInsn(ALOAD, context.var("out"));
    mw.visitVarInsn(ILOAD, context.var("seperator"));
    mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/SerializeWriter", "write", "(C)V");

    // out.writeFieldName("fieldName")
    mw.visitVarInsn(ALOAD, context.var("out"));
    mw.visitVarInsn(ALOAD, context.fieldName());
    mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldName", "(Ljava/lang/String;)V");

    // serializer.write(obj)
    mw.visitVarInsn(ALOAD, context.serializer());
    mw.visitVarInsn(ALOAD, context.processValue());
    if (format != null) {
        mw.visitLdcInsn(format);
        mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/JSONSerializer", "writeWithFormat",
                           "(Ljava/lang/Object;Ljava/lang/String;)V");
    } else {
        mw.visitVarInsn(ALOAD, context.fieldName());
        if (fieldInfo.getFieldType() instanceof Class<?> //
            && ((Class<?>) fieldInfo.getFieldType()).isPrimitive()) {
            mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/JSONSerializer", "writeWithFieldName",
                               "(Ljava/lang/Object;Ljava/lang/Object;)V");
        } else {
            mw.visitVarInsn(ALOAD, 0);
            mw.visitFieldInsn(GETFIELD, context.getClassName(), fieldInfo.getName() + "_asm_fieldType",
                              "Ljava/lang/reflect/Type;");
            mw.visitLdcInsn(fieldInfo.getSerialzeFeatures());

            mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/JSONSerializer", "writeWithFieldName",
                               "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/reflect/Type;I)V");
        }
    }

    _seperator(mw, context);
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:48,代码来源:ASMSerializerFactory.java


注:本文中的com.alibaba.fastjson.util.FieldInfo.getFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。