Search in sources :

Example 11 with ParseContext

use of com.alibaba.fastjson.parser.ParseContext in project fastjson by alibaba.

the class MediaGenDecoder method deserialze.

public Object deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
    JSONLexerBase lexer = (JSONLexerBase) parser.getLexer();
    if (!lexer.isEnabled(Feature.SortFeidFastMatch)) {
        return super.deserialze(parser, type, fieldName);
    }
    if (lexer.isEnabled(Feature.SupportArrayToBean)) {
    // deserialzeArrayMapping
    }
    if (lexer.scanType("Department") == JSONLexerBase.NOT_MATCH) {
        return super.deserialze(parser, type, fieldName);
    }
    ParseContext mark_context = parser.getContext();
    int matchedCount = 0;
    Media instance = new Media();
    ParseContext context = parser.getContext();
    ParseContext childContext = parser.setContext(context, instance, fieldName);
    if (lexer.matchStat == JSONLexerBase.END) {
        return instance;
    }
    int matchStat = 0;
    int _asm_flag_0 = 0;
    int bitrate_gen = 0;
    String copyright_gen;
    if (lexer.isEnabled(Feature.InitStringFieldAsEmpty)) {
        copyright_gen = lexer.stringDefaultValue();
        _asm_flag_0 |= 2;
    } else {
        copyright_gen = null;
    }
    long duration_gen = 0;
    String format_gen;
    if (lexer.isEnabled(Feature.InitStringFieldAsEmpty)) {
        format_gen = lexer.stringDefaultValue();
        _asm_flag_0 |= 8;
    } else {
        format_gen = null;
    }
    int height_gen = 0;
    java.util.List persons_gen = null;
    data.media.Media.Player player_gen = null;
    long size_gen = 0;
    String title_gen;
    if (lexer.isEnabled(Feature.InitStringFieldAsEmpty)) {
        title_gen = lexer.stringDefaultValue();
        _asm_flag_0 |= 256;
    } else {
        title_gen = null;
    }
    String uri_gen;
    if (lexer.isEnabled(Feature.InitStringFieldAsEmpty)) {
        uri_gen = lexer.stringDefaultValue();
        _asm_flag_0 |= 512;
    } else {
        uri_gen = null;
    }
    int width_gen = 0;
    boolean endFlag = false, restFlag = false;
    if ((!endFlag) && (!restFlag)) {
        bitrate_gen = lexer.scanFieldInt(bitrate_gen_prefix__);
        if (lexer.matchStat > 0) {
            _asm_flag_0 |= 1;
            matchedCount++;
        }
        if (lexer.matchStat == JSONLexerBase.NOT_MATCH) {
            restFlag = true;
        }
        if (lexer.matchStat == JSONLexerBase.END) {
            endFlag = true;
        }
    }
    if ((!endFlag) && (!restFlag)) {
        copyright_gen = lexer.scanFieldString(copyright_gen_prefix__);
        if (lexer.matchStat > 0) {
            _asm_flag_0 |= 2;
            matchedCount++;
        }
        if (lexer.matchStat == JSONLexerBase.NOT_MATCH) {
            restFlag = true;
        }
        if (lexer.matchStat == JSONLexerBase.END) {
            endFlag = true;
        }
    }
    if ((!endFlag) && (!restFlag)) {
        duration_gen = lexer.scanFieldLong(duration_gen_prefix__);
        if (lexer.matchStat > 0) {
            _asm_flag_0 |= 4;
            matchedCount++;
        }
        if (lexer.matchStat == JSONLexerBase.NOT_MATCH) {
            restFlag = true;
        }
        if (lexer.matchStat == JSONLexerBase.END) {
            endFlag = true;
        }
    }
    if ((!endFlag) && (!restFlag)) {
        format_gen = lexer.scanFieldString(format_gen_prefix__);
        if (lexer.matchStat > 0) {
            _asm_flag_0 |= 8;
            matchedCount++;
        }
        if (lexer.matchStat == JSONLexerBase.NOT_MATCH) {
            restFlag = true;
        }
        if (lexer.matchStat == JSONLexerBase.END) {
            endFlag = true;
        }
    }
    if ((!endFlag) && (!restFlag)) {
        height_gen = lexer.scanFieldInt(height_gen_prefix__);
        if (lexer.matchStat > 0) {
            _asm_flag_0 |= 16;
            matchedCount++;
        }
        if (lexer.matchStat == JSONLexerBase.NOT_MATCH) {
            restFlag = true;
        }
        if (lexer.matchStat == JSONLexerBase.END) {
            endFlag = true;
        }
    }
    if ((!endFlag) && (!restFlag)) {
        persons_gen = (java.util.List) lexer.scanFieldStringArray(persons_gen_prefix__, java.util.List.class);
        if (lexer.matchStat > 0) {
            _asm_flag_0 |= 32;
            matchedCount++;
        }
        if (lexer.matchStat == JSONLexerBase.NOT_MATCH) {
            restFlag = true;
        }
        if (lexer.matchStat == JSONLexerBase.END) {
            endFlag = true;
        }
    }
    if ((!endFlag) && (!restFlag)) {
        player_gen = (data.media.Media.Player) this.scanEnum(lexer, player_gen_prefix__, player_gen_deser__);
        if (lexer.matchStat > 0) {
            _asm_flag_0 |= 64;
            matchedCount++;
        }
        if (lexer.matchStat == JSONLexerBase.NOT_MATCH) {
            restFlag = true;
        }
        if (lexer.matchStat == JSONLexerBase.END) {
            endFlag = true;
        }
    }
    if ((!endFlag) && (!restFlag)) {
        size_gen = lexer.scanFieldLong(size_gen_prefix__);
        if (lexer.matchStat > 0) {
            _asm_flag_0 |= 128;
            matchedCount++;
        }
        if (lexer.matchStat == JSONLexerBase.NOT_MATCH) {
            restFlag = true;
        }
        if (lexer.matchStat == JSONLexerBase.END) {
            endFlag = true;
        }
    }
    if ((!endFlag) && (!restFlag)) {
        title_gen = lexer.scanFieldString(title_gen_prefix__);
        if (lexer.matchStat > 0) {
            _asm_flag_0 |= 256;
            matchedCount++;
        }
        if (lexer.matchStat == JSONLexerBase.NOT_MATCH) {
            restFlag = true;
        }
        if (lexer.matchStat == JSONLexerBase.END) {
            endFlag = true;
        }
    }
    if ((!endFlag) && (!restFlag)) {
        uri_gen = lexer.scanFieldString(uri_gen_prefix__);
        if (lexer.matchStat > 0) {
            _asm_flag_0 |= 512;
            matchedCount++;
        }
        if (lexer.matchStat == JSONLexerBase.NOT_MATCH) {
            restFlag = true;
        }
        if (lexer.matchStat == JSONLexerBase.END) {
            endFlag = true;
        }
    }
    if ((!endFlag) && (!restFlag)) {
        width_gen = lexer.scanFieldInt(width_gen_prefix__);
        if (lexer.matchStat > 0) {
            _asm_flag_0 |= 1024;
            matchedCount++;
        }
        if (lexer.matchStat == JSONLexerBase.NOT_MATCH) {
            restFlag = true;
        }
        if (lexer.matchStat != JSONLexerBase.END) {
            restFlag = true;
        }
    }
    if ((_asm_flag_0 & 1) != 0) {
        instance.setBitrate(bitrate_gen);
    }
    if ((_asm_flag_0 & 2) != 0) {
        instance.setCopyright(copyright_gen);
    }
    if ((_asm_flag_0 & 4) != 0) {
        instance.setDuration(duration_gen);
    }
    if ((_asm_flag_0 & 8) != 0) {
        instance.setFormat(format_gen);
    }
    if ((_asm_flag_0 & 16) != 0) {
        instance.setHeight(height_gen);
    }
    if ((_asm_flag_0 & 32) != 0) {
        instance.setPersons(persons_gen);
    }
    if ((_asm_flag_0 & 64) != 0) {
        instance.setPlayer(player_gen);
    }
    if ((_asm_flag_0 & 128) != 0) {
        instance.setSize(size_gen);
    }
    if ((_asm_flag_0 & 256) != 0) {
        instance.setTitle(title_gen);
    }
    if ((_asm_flag_0 & 512) != 0) {
        instance.setUri(uri_gen);
    }
    if ((_asm_flag_0 & 1024) != 0) {
        instance.setWidth(width_gen);
    }
    if (restFlag) {
        return super.parseRest(parser, type, fieldName, instance, 0, new int[0]);
    }
    return instance;
}
Also used : ParseContext(com.alibaba.fastjson.parser.ParseContext) JSONLexerBase(com.alibaba.fastjson.parser.JSONLexerBase)

Aggregations

ParseContext (com.alibaba.fastjson.parser.ParseContext)11 JSONLexerBase (com.alibaba.fastjson.parser.JSONLexerBase)5 ResolveTask (com.alibaba.fastjson.parser.DefaultJSONParser.ResolveTask)4 JSONException (com.alibaba.fastjson.JSONException)3 FieldInfo (com.alibaba.fastjson.util.FieldInfo)3 ParameterizedType (java.lang.reflect.ParameterizedType)3 Type (java.lang.reflect.Type)3 JSONObject (com.alibaba.fastjson.JSONObject)2 JSON (com.alibaba.fastjson.JSON)1 JSONField (com.alibaba.fastjson.annotation.JSONField)1 Label (com.alibaba.fastjson.asm.Label)1 MethodVisitor (com.alibaba.fastjson.asm.MethodVisitor)1 MethodWriter (com.alibaba.fastjson.asm.MethodWriter)1 DefaultJSONParser (com.alibaba.fastjson.parser.DefaultJSONParser)1 JSONLexer (com.alibaba.fastjson.parser.JSONLexer)1 ParserConfig (com.alibaba.fastjson.parser.ParserConfig)1 ContextObjectDeserializer (com.alibaba.fastjson.parser.deserializer.ContextObjectDeserializer)1 JavaBeanDeserializer (com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer)1 JavaBeanInfo (com.alibaba.fastjson.util.JavaBeanInfo)1 Font (java.awt.Font)1