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


Java FieldInfo.getFieldType方法代码示例

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


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

示例1: _deserObject

import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
private void _deserObject(Context context, MethodVisitor mw, FieldInfo fieldInfo, Class<?> fieldClass) {
    _getFieldDeser(context, mw, fieldInfo);

    mw.visitVarInsn(ALOAD, 1);
    if (fieldInfo.getFieldType() instanceof Class) {
        mw.visitLdcInsn(com.alibaba.fastjson.asm.Type.getType(getDesc(fieldInfo.getFieldClass())));
    } else {
        mw.visitVarInsn(ALOAD, 0);
        mw.visitLdcInsn(fieldInfo.getName());
        mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/parser/deserializer/ASMJavaBeanDeserializer", "getFieldType",
                           "(Ljava/lang/String;)Ljava/lang/reflect/Type;");
    }
    mw.visitLdcInsn(fieldInfo.getName());
    mw.visitMethodInsn(INVOKEINTERFACE, "com/alibaba/fastjson/parser/deserializer/ObjectDeserializer", "deserialze",
                       "(Lcom/alibaba/fastjson/parser/DefaultJSONParser;Ljava/lang/reflect/Type;Ljava/lang/Object;)Ljava/lang/Object;");
    mw.visitTypeInsn(CHECKCAST, getType(fieldClass)); // cast
    mw.visitVarInsn(ASTORE, context.var(fieldInfo.getName() + "_asm"));
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:19,代码来源:ASMDeserializerFactory.java

示例2: _deserObject

import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
private void _deserObject(Context context, MethodVisitor mw, FieldInfo fieldInfo, Class<?> fieldClass) {
    _getFieldDeser(context, mw, fieldInfo);
    mw.visitVarInsn(25, 1);
    if (fieldInfo.getFieldType() instanceof Class) {
        mw.visitLdcInsn(com.alibaba.fastjson.asm.Type.getType(ASMUtils.getDesc(fieldInfo.getFieldClass())));
    } else {
        mw.visitVarInsn(25, 0);
        mw.visitLdcInsn(fieldInfo.getName());
        mw.visitMethodInsn(182, "com/alibaba/fastjson/parser/deserializer/ASMJavaBeanDeserializer", "getFieldType", "(Ljava/lang/String;)Ljava/lang/reflect/Type;");
    }
    mw.visitLdcInsn(fieldInfo.getName());
    mw.visitMethodInsn(185, "com/alibaba/fastjson/parser/deserializer/ObjectDeserializer", "deserialze", "(Lcom/alibaba/fastjson/parser/DefaultJSONParser;Ljava/lang/reflect/Type;Ljava/lang/Object;)Ljava/lang/Object;");
    mw.visitTypeInsn(192, ASMUtils.getType(fieldClass));
    mw.visitVarInsn(58, context.var(fieldInfo.getName() + "_asm"));
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:16,代码来源:ASMDeserializerFactory.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(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

示例4: parseField

import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的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

示例5: _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);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:55,代码来源:ASMDeserializerFactory.java

示例6: _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.class) {
        mw.visitVarInsn(ALOAD, context.var("instance"));
        mw.visitVarInsn(ILOAD, context.var(fieldInfo.getName() + "_asm"));
        _set(context, mw, fieldInfo);
    } else if (fieldClass == byte.class //
               || fieldClass == short.class //
               || fieldClass == int.class //
               || fieldClass == char.class) {
        mw.visitVarInsn(ALOAD, context.var("instance"));
        mw.visitVarInsn(ILOAD, context.var(fieldInfo.getName() + "_asm"));
        _set(context, mw, fieldInfo);
    } else if (fieldClass == long.class) {
        mw.visitVarInsn(ALOAD, context.var("instance"));
        mw.visitVarInsn(LLOAD, context.var(fieldInfo.getName() + "_asm", 2));
        if (fieldInfo.getMethod() != null) {
            mw.visitMethodInsn(INVOKEVIRTUAL, getType(context.getClazz()), fieldInfo.getMethod().getName(),
                               getDesc(fieldInfo.getMethod()));
            if (!fieldInfo.getMethod().getReturnType().equals(Void.TYPE)) {
                mw.visitInsn(POP);
            }
        } else {
            mw.visitFieldInsn(PUTFIELD, getType(fieldInfo.getDeclaringClass()), fieldInfo.getField().getName(),
                              getDesc(fieldInfo.getFieldClass()));
        }
    } else if (fieldClass == float.class) {
        mw.visitVarInsn(ALOAD, context.var("instance"));
        mw.visitVarInsn(FLOAD, context.var(fieldInfo.getName() + "_asm"));
        _set(context, mw, fieldInfo);
    } else if (fieldClass == double.class) {
        mw.visitVarInsn(ALOAD, context.var("instance"));
        mw.visitVarInsn(DLOAD, context.var(fieldInfo.getName() + "_asm", 2));
        _set(context, mw, fieldInfo);
    } else if (fieldClass == String.class) {
        mw.visitVarInsn(ALOAD, context.var("instance"));
        mw.visitVarInsn(ALOAD, context.var(fieldInfo.getName() + "_asm"));
        _set(context, mw, fieldInfo);
    } else if (fieldClass.isEnum()) {
        mw.visitVarInsn(ALOAD, context.var("instance"));
        mw.visitVarInsn(ALOAD, context.var(fieldInfo.getName() + "_asm"));
        _set(context, mw, fieldInfo);
    } else if (Collection.class.isAssignableFrom(fieldClass)) {
        mw.visitVarInsn(ALOAD, context.var("instance"));
        Type itemType = TypeUtils.getCollectionItemClass(fieldType);
        if (itemType == String.class) {
            mw.visitVarInsn(ALOAD, context.var(fieldInfo.getName() + "_asm"));
            mw.visitTypeInsn(CHECKCAST, getType(fieldClass)); // cast
        } else {
            mw.visitVarInsn(ALOAD, context.var(fieldInfo.getName() + "_asm"));
        }
        _set(context, mw, fieldInfo);

    } else {
        // mw.visitFieldInsn(GETSTATIC, getType(System.class), "out", "Ljava/io/PrintStream;");
        // mw.visitIntInsn(ILOAD, context.var(fieldInfo.getName() + "_asm_flag"));
        // mw.visitMethodInsn(INVOKEVIRTUAL, getType(java.io.PrintStream.class), "println", "(I)V");

        // _isFlag(mw, context, i, notSet_);

        mw.visitVarInsn(ALOAD, context.var("instance"));
        mw.visitVarInsn(ALOAD, context.var(fieldInfo.getName() + "_asm"));
        _set(context, mw, fieldInfo);

    }
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:69,代码来源:ASMDeserializerFactory.java

示例7: _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

示例8: genDeserialzeObject

import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
protected void genDeserialzeObject(FieldInfo fieldInfo, int i) throws IOException {
    print("if (lexer.matchField(");
    printFieldPrefix(fieldInfo);
    print(")) {");
    println();
    print("\t");
    genSetFlag(i);
    println("\tmatchedCount++;");

    // _deserObject
    print("if (");
    printFieldDeser(fieldInfo);
    print(" == null) {");
    println();

    print("\t");
    printFieldDeser(fieldInfo);
    print(" = parser.getConfig().getDeserializer(");
    printClassName(fieldInfo.getFieldClass());
    println(".class);");
    println("}");

    print("\t");
    printFieldDeser(fieldInfo);
    print(".deserialze(parser, ");
    if (fieldInfo.getFieldType() instanceof Class) {
        printClassName(fieldInfo.getFieldClass());
        print(".class");
    } else {
        print("getFieldType(\"");
        println(fieldInfo.getName());
        print("\")");
    }
    print(",\"");
    print(fieldInfo.getName());
    println("\");");

    println("\tif(parser.getResolveStatus() == DefaultJSONParser.NeedToResolve) {");
    println("\t\tResolveTask resolveTask = parser.getLastResolveTask();");
    println("\t\tresolveTask.setOwnerContext(parser.getContext());");
    print("\t\tresolveTask.setFieldDeserializer(this.getFieldDeserializer(\"");
    print(fieldInfo.getName());
    println("\"));");
    println("\t\tparser.setResolveStatus(DefaultJSONParser.NONE);");
    println("\t}");
    println("}");
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:48,代码来源:DeserializerGen.java


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