Java 类com.alibaba.fastjson.parser.deserializer.FieldDeserializer 实例源码

项目:boohee_v5.6    文件:ParserConfig.java   
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);
}
项目:boohee_v5.6    文件:DefaultJSONParser.java   
public void handleResovleTask(Object value) {
    if (this.resolveTaskList != null) {
        int size = this.resolveTaskList.size();
        for (int i = 0; i < size; i++) {
            ResolveTask task = (ResolveTask) this.resolveTaskList.get(i);
            FieldDeserializer fieldDeser = task.getFieldDeserializer();
            if (fieldDeser != null) {
                Object refValue;
                Object object = null;
                if (task.getOwnerContext() != null) {
                    object = task.getOwnerContext().getObject();
                }
                String ref = task.getReferenceValue();
                if (ref.startsWith("$")) {
                    refValue = getObject(ref);
                } else {
                    refValue = task.getContext().getObject();
                }
                fieldDeser.setValue(object, refValue);
            }
        }
    }
}
项目:uavstack    文件:ParserConfig.java   
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);
}
项目:itmarry    文件:ParserConfig.java   
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);
}
项目:boohee_v5.6    文件:ParserConfig.java   
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);
    }
}
项目:boohee_v5.6    文件:ParserConfig.java   
public Map<String, FieldDeserializer> getFieldDeserializers(Class<?> clazz) {
    ObjectDeserializer deserizer = getDeserializer((Type) clazz);
    if (deserizer instanceof JavaBeanDeserializer) {
        return ((JavaBeanDeserializer) deserizer).getFieldDeserializerMap();
    }
    if (deserizer instanceof ASMJavaBeanDeserializer) {
        return ((ASMJavaBeanDeserializer) deserizer).getInnterSerializer().getFieldDeserializerMap();
    }
    return Collections.emptyMap();
}
项目:uavstack    文件:ParserConfig.java   
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);
}
项目:uavstack    文件:ParserConfig.java   
public Map<String, FieldDeserializer> getFieldDeserializers(Class<?> clazz) {
    ObjectDeserializer deserizer = getDeserializer(clazz);

    if (deserizer instanceof JavaBeanDeserializer) {
        return ((JavaBeanDeserializer) deserizer).getFieldDeserializerMap();
    } else if (deserizer instanceof ASMJavaBeanDeserializer) {
        return ((ASMJavaBeanDeserializer) deserizer).getInnterSerializer().getFieldDeserializerMap();
    } else {
        return Collections.emptyMap();
    }
}
项目:uavstack    文件:DefaultJSONParser.java   
public void handleResovleTask(Object value) {
    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 = getObject(ref);
        } else {
            refValue = task.getContext().getObject();
        }
        fieldDeser.setValue(object, refValue);
    }
}
项目:itmarry    文件:ParserConfig.java   
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 (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);
}
项目:itmarry    文件:ParserConfig.java   
public Map<String, FieldDeserializer> getFieldDeserializers(Class<?> clazz) {
    ObjectDeserializer deserizer = getDeserializer(clazz);

    if (deserizer instanceof JavaBeanDeserializer) {
        return ((JavaBeanDeserializer) deserizer).getFieldDeserializerMap();
    } else if (deserizer instanceof ASMJavaBeanDeserializer) {
        return ((ASMJavaBeanDeserializer) deserizer).getInnterSerializer().getFieldDeserializerMap();
    } else {
        return Collections.emptyMap();
    }
}
项目:itmarry    文件:JSON.java   
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);
    }
}
项目:android_http_demo    文件:ParserConfig.java   
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) {
        Type fieldType = fieldInfo.getFieldType();
        if (fieldType instanceof ParameterizedType) {
            Type itemType = ((ParameterizedType) fieldType).getActualTypeArguments()[0];
            if (itemType == String.class) {
                return new ArrayListStringFieldDeserializer(mapping, clazz, fieldInfo);
            }
        }

        return new ArrayListTypeFieldDeserializer(mapping, clazz, fieldInfo);
    }

    return new DefaultFieldDeserializer(mapping, clazz, fieldInfo);
}
项目:android_http_demo    文件:ParserConfig.java   
public Map<String, FieldDeserializer> getFieldDeserializers(Class<?> clazz) {
    ObjectDeserializer deserizer = getDeserializer(clazz);

    if (deserizer instanceof JavaBeanDeserializer) {
        return ((JavaBeanDeserializer) deserizer).getFieldDeserializerMap();
    } else {
        return Collections.emptyMap();
    }
}
项目:android_http_demo    文件:JSON.java   
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;
}
项目:AndroidNio    文件:ParserConfig.java   
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) {
        Type fieldType = fieldInfo.getFieldType();
        if (fieldType instanceof ParameterizedType) {
            Type itemType = ((ParameterizedType) fieldType).getActualTypeArguments()[0];
            if (itemType == String.class) {
                return new ArrayListStringFieldDeserializer(mapping, clazz, fieldInfo);
            }
        }

        return new ArrayListTypeFieldDeserializer(mapping, clazz, fieldInfo);
    }

    return new DefaultFieldDeserializer(mapping, clazz, fieldInfo);
}
项目:AndroidNio    文件:ParserConfig.java   
public Map<String, FieldDeserializer> getFieldDeserializers(Class<?> clazz) {
    ObjectDeserializer deserizer = getDeserializer(clazz);

    if (deserizer instanceof JavaBeanDeserializer) {
        return ((JavaBeanDeserializer) deserizer).getFieldDeserializerMap();
    } else {
        return Collections.emptyMap();
    }
}
项目:AndroidNio    文件:JSON.java   
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;
}
项目:boohee_v5.6    文件:DefaultJSONParser.java   
public FieldDeserializer getFieldDeserializer() {
    return this.fieldDeserializer;
}
项目:boohee_v5.6    文件:DefaultJSONParser.java   
public void setFieldDeserializer(FieldDeserializer fieldDeserializer) {
    this.fieldDeserializer = fieldDeserializer;
}
项目:uavstack    文件:DefaultJSONParser.java   
public FieldDeserializer getFieldDeserializer() {
    return fieldDeserializer;
}
项目:uavstack    文件:DefaultJSONParser.java   
public void setFieldDeserializer(FieldDeserializer fieldDeserializer) {
    this.fieldDeserializer = fieldDeserializer;
}
项目:itmarry    文件:DefaultJSONParser.java   
public void parseObject(Object object) {
    Class<?> clazz = object.getClass();
    Map<String, FieldDeserializer> setters = config.getFieldDeserializers(clazz);

    if (lexer.token() != JSONToken.LBRACE && lexer.token() != JSONToken.COMMA) {
        throw new JSONException("syntax error, expect {, actual " + lexer.tokenName());
    }

    for (;;) {
        // lexer.scanSymbol
        String key = lexer.scanSymbol(symbolTable);

        if (key == null) {
            if (lexer.token() == JSONToken.RBRACE) {
                lexer.nextToken(JSONToken.COMMA);
                break;
            }
            if (lexer.token() == JSONToken.COMMA) {
                if (isEnabled(Feature.AllowArbitraryCommas)) {
                    continue;
                }
            }
        }

        FieldDeserializer fieldDeser = setters.get(key);
        if (fieldDeser == null) {
            if (!isEnabled(Feature.IgnoreNotMatch)) {
                throw new JSONException("setter not found, class " + clazz.getName() + ", property " + key);
            }

            lexer.nextTokenWithColon();
            parse(); // skip

            if (lexer.token() == JSONToken.RBRACE) {
                lexer.nextToken();
                return;
            }

            continue;
        } else {
            Class<?> fieldClass = fieldDeser.getFieldClass();
            Type fieldType = fieldDeser.getFieldType();
            Object fieldValue;
            if (fieldClass == int.class) {
                lexer.nextTokenWithColon(JSONToken.LITERAL_INT);
                fieldValue = IntegerCodec.instance.deserialze(this, fieldType, null);
            } else if (fieldClass == String.class) {
                lexer.nextTokenWithColon(JSONToken.LITERAL_STRING);
                fieldValue = StringCodec.deserialze(this);
            } else if (fieldClass == long.class) {
                lexer.nextTokenWithColon(JSONToken.LITERAL_INT);
                fieldValue = LongCodec.instance.deserialze(this, fieldType, null);
            } else {
                ObjectDeserializer fieldValueDeserializer = config.getDeserializer(fieldClass, fieldType);

                lexer.nextTokenWithColon(fieldValueDeserializer.getFastMatchToken());
                fieldValue = fieldValueDeserializer.deserialze(this, fieldType, null);
            }

            fieldDeser.setValue(object, fieldValue);
        }

        if (lexer.token() == JSONToken.COMMA) {
            continue;
        }

        if (lexer.token() == JSONToken.RBRACE) {
            lexer.nextToken(JSONToken.COMMA);
            return;
        }
    }
}
项目:itmarry    文件:DefaultJSONParser.java   
public FieldDeserializer getFieldDeserializer() {
    return fieldDeserializer;
}
项目:itmarry    文件:DefaultJSONParser.java   
public void setFieldDeserializer(FieldDeserializer fieldDeserializer) {
    this.fieldDeserializer = fieldDeserializer;
}
项目:android_http_demo    文件:ParserConfig.java   
public FieldDeserializer createFieldDeserializer(ParserConfig mapping, Class<?> clazz, FieldInfo fieldInfo) {
    return createFieldDeserializerWithoutASM(mapping, clazz, fieldInfo);
}
项目:android_http_demo    文件:DefaultJSONParser.java   
public FieldDeserializer getFieldDeserializer() {
    return fieldDeserializer;
}
项目:android_http_demo    文件:DefaultJSONParser.java   
public void setFieldDeserializer(FieldDeserializer fieldDeserializer) {
    this.fieldDeserializer = fieldDeserializer;
}
项目:AndroidNio    文件:ParserConfig.java   
public FieldDeserializer createFieldDeserializer(ParserConfig mapping, Class<?> clazz, FieldInfo fieldInfo) {
    return createFieldDeserializerWithoutASM(mapping, clazz, fieldInfo);
}
项目:AndroidNio    文件:DefaultJSONParser.java   
public FieldDeserializer getFieldDeserializer() {
    return fieldDeserializer;
}
项目:AndroidNio    文件:DefaultJSONParser.java   
public void setFieldDeserializer(FieldDeserializer fieldDeserializer) {
    this.fieldDeserializer = fieldDeserializer;
}