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


Java DefaultJSONParser.getLexer方法代码示例

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


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

示例1: parseArray

import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public static final JSONArray parseArray(String text) {
    if (text == null) {
        return null;
    }
    JSONArray array;
    DefaultJSONParser parser = new DefaultJSONParser(text, ParserConfig.getGlobalInstance());
    JSONLexer lexer = parser.getLexer();
    if (lexer.token() == 8) {
        lexer.nextToken();
        array = null;
    } else if (lexer.token() == 20) {
        array = null;
    } else {
        Collection array2 = new JSONArray();
        parser.parseArray(array2);
        parser.handleResovleTask(array2);
    }
    parser.close();
    return array;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:JSON.java

示例2: deserialze

import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
        final JSONScanner lexer = (JSONScanner) parser.getLexer();
        
        MediaContent object = new MediaContent();
        
        lexer.matchField(mediaPrefix);
        if (mediaDeserializer == null) {
            //mediaDeserializer = parser.getMapping().getDeserializer(ObjectDeserializer.class);
        }
        mediaDeserializer.deserialze(parser, clazz, null);
        
        lexer.matchField(imagePrefix);
        imageDeserializer.deserialze(parser, clazz, null);
        
//        if (lexer.token() != JSONToken.RBRACE)
        
        // TODO Auto-generated method stub
        return null;
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:MediaContentDeserializer.java

示例3: deserialze

import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
    Long longObject;
    JSONLexer lexer = parser.getLexer();
    if (lexer.token() == 2) {
        long longValue = lexer.longValue();
        lexer.nextToken(16);
        longObject = Long.valueOf(longValue);
    } else {
        Object value = parser.parse();
        if (value == null) {
            return null;
        }
        longObject = TypeUtils.castToLong(value);
    }
    if (clazz == AtomicLong.class) {
        return new AtomicLong(longObject.longValue());
    }
    return longObject;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:LongCodec.java

示例4: deserialze

import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public static <T> T deserialze(DefaultJSONParser parser) {
    JSONLexer lexer = parser.getLexer();
    if (lexer.token() == 4) {
        String val = lexer.stringVal();
        lexer.nextToken(16);
        return val.toCharArray();
    } else if (lexer.token() == 2) {
        Number val2 = lexer.integerValue();
        lexer.nextToken(16);
        return val2.toString().toCharArray();
    } else {
        Object value = parser.parse();
        if (value == null) {
            return null;
        }
        return JSON.toJSONString(value).toCharArray();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:CharArrayDeserializer.java

示例5: deserialze

import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public static <T> T deserialze(DefaultJSONParser parser) {
    JSONLexer lexer = parser.getLexer();
    long val;
    if (lexer.token() == 2) {
        val = lexer.longValue();
        lexer.nextToken(16);
        return new BigDecimal(val);
    } else if (lexer.token() == 3) {
        val = lexer.decimalValue();
        lexer.nextToken(16);
        return val;
    } else {
        Object value = parser.parse();
        if (value == null) {
            return null;
        }
        return TypeUtils.castToBigDecimal(value);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:BigDecimalCodec.java

示例6: parseField

import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void parseField(DefaultJSONParser parser, Object object, Type objectType, Map<String, Object> fieldValues) {
    String value;
    JSONLexer lexer = parser.getLexer();
    if (lexer.token() == 4) {
        value = lexer.stringVal();
        lexer.nextToken(16);
    } else {
        Object obj = parser.parse();
        if (obj == null) {
            value = null;
        } else {
            value = obj.toString();
        }
    }
    if (object == null) {
        fieldValues.put(this.fieldInfo.getName(), value);
    } else {
        setValue(object, value);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:StringFieldDeserializer.java

示例7: deserialze

import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
    JSONLexer lexer = parser.getLexer();
    if (lexer.token() == 8) {
        lexer.nextToken(16);
        return null;
    }
    T intObj;
    if (lexer.token() == 2) {
        int val = lexer.intValue();
        lexer.nextToken(16);
        intObj = Integer.valueOf(val);
    } else if (lexer.token() == 3) {
        BigDecimal decimalValue = lexer.decimalValue();
        lexer.nextToken(16);
        intObj = Integer.valueOf(decimalValue.intValue());
    } else {
        intObj = TypeUtils.castToInt(parser.parse());
    }
    if (clazz == AtomicInteger.class) {
        return new AtomicInteger(intObj.intValue());
    }
    return intObj;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:24,代码来源:IntegerCodec.java

示例8: parseArray

import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public static void parseArray(Collection collection, ObjectDeserializer deser, DefaultJSONParser parser, Type type, Object fieldName) {
    JSONLexer lexer = parser.getLexer();
    if (lexer.token() == 8) {
        lexer.nextToken(16);
    }
    parser.accept(14, 14);
    int index = 0;
    while (true) {
        collection.add(deser.deserialze(parser, type, Integer.valueOf(index)));
        index++;
        if (lexer.token() == 16) {
            lexer.nextToken(14);
        } else {
            parser.accept(15, 16);
            return;
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:ASMUtils.java

示例9: deserialze

import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
    final JSONLexer lexer = parser.getLexer();

    Boolean boolObj;
    if (lexer.token() == JSONToken.TRUE) {
        lexer.nextToken(JSONToken.COMMA);
        boolObj = Boolean.TRUE;
    } else if (lexer.token() == JSONToken.FALSE) {
        lexer.nextToken(JSONToken.COMMA);
        boolObj = Boolean.FALSE;
    } else if (lexer.token() == JSONToken.LITERAL_INT) {
        int intValue = lexer.intValue();
        lexer.nextToken(JSONToken.COMMA);

        if (intValue == 1) {
            boolObj = Boolean.TRUE;
        } else {
            boolObj = Boolean.FALSE;
        }
    } else {
        Object value = parser.parse();

        if (value == null) {
            return null;
        }

        boolObj = TypeUtils.castToBoolean(value);
    }

    if (clazz == AtomicBoolean.class) {
        return (T) new AtomicBoolean(boolObj.booleanValue());
    }

    return (T) boolObj;
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:37,代码来源:BooleanCodec.java

示例10: deserialze

import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
    final JSONLexer lexer = parser.getLexer();

    if (lexer.token() == JSONToken.NULL) {
        lexer.nextToken(JSONToken.COMMA);
        return null;
    }

    Integer intObj;
    if (lexer.token() == JSONToken.LITERAL_INT) {
        int val = lexer.intValue();
        lexer.nextToken(JSONToken.COMMA);
        intObj = Integer.valueOf(val);
    } else if (lexer.token() == JSONToken.LITERAL_FLOAT) {
        BigDecimal decimalValue = lexer.decimalValue();
        lexer.nextToken(JSONToken.COMMA);
        intObj = Integer.valueOf(decimalValue.intValue());
    } else {
        Object value = parser.parse();

        intObj = TypeUtils.castToInt(value);
    }
    
    if (clazz == AtomicInteger.class) {
        return (T) new AtomicInteger(intObj.intValue());
    }
    
    return (T) intObj;
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:31,代码来源:IntegerCodec.java

示例11: deserialze

import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
    try {
        JSONLexer lexer = parser.getLexer();
        if (lexer.token() == 2) {
            Integer value = Integer.valueOf(lexer.intValue());
            lexer.nextToken(16);
            T t = this.ordinalMap.get(value);
            if (t != null) {
                return t;
            }
            throw new JSONException("parse enum " + this.enumClass.getName() + " error, value : " + value);
        } else if (lexer.token() == 4) {
            String strVal = lexer.stringVal();
            lexer.nextToken(16);
            if (strVal.length() == 0) {
                return null;
            }
            Object value2 = this.nameMap.get(strVal);
            return Enum.valueOf(this.enumClass, strVal);
        } else if (lexer.token() == 8) {
            lexer.nextToken(16);
            return null;
        } else {
            throw new JSONException("parse enum " + this.enumClass.getName() + " error, value : " + parser.parse());
        }
    } catch (JSONException e) {
        throw e;
    } catch (Throwable e2) {
        JSONException jSONException = new JSONException(e2.getMessage(), e2);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:32,代码来源:EnumDeserializer.java

示例12: deserialze

import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
    JSONLexer lexer = parser.getLexer();
    if (lexer.token() == 8) {
        lexer.nextToken();
        return null;
    } else if (lexer.token() != 4) {
        throw new JSONException("expect className");
    } else {
        String className = lexer.stringVal();
        lexer.nextToken(16);
        return TypeUtils.loadClass(className);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:ClassDerializer.java

示例13: parseField

import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public void parseField(DefaultJSONParser parser, Object object, Type objectType, Map<String, Object> fieldValues) {
    JSONLexer lexer = parser.getLexer();
    if (lexer.token() == 2) {
        int val = lexer.intValue();
        lexer.nextToken(16);
        if (object == null) {
            fieldValues.put(this.fieldInfo.getName(), Integer.valueOf(val));
            return;
        } else {
            setValue(object, val);
            return;
        }
    }
    Integer value;
    if (lexer.token() == 8) {
        value = null;
        lexer.nextToken(16);
    } else {
        value = TypeUtils.castToInt(parser.parse());
    }
    if (value != null || getFieldClass() != Integer.TYPE) {
        if (object == null) {
            fieldValues.put(this.fieldInfo.getName(), value);
        } else {
            setValue(object, (Object) value);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:29,代码来源:IntegerFieldDeserializer.java

示例14: deserialzeArrayMapping

import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public <T> T deserialzeArrayMapping(DefaultJSONParser parser, Type type, Object fieldName, Object object) {
    JSONLexer lexer = parser.getLexer();
    if (lexer.token() != 14) {
        throw new JSONException("error");
    }
    object = createInstance(parser, type);
    int size = this.sortedFieldDeserializers.size();
    int i = 0;
    while (i < size) {
        char seperator = i == size + -1 ? ']' : ',';
        FieldDeserializer fieldDeser = (FieldDeserializer) this.sortedFieldDeserializers.get(i);
        Class<?> fieldClass = fieldDeser.getFieldClass();
        if (fieldClass == Integer.TYPE) {
            fieldDeser.setValue(object, lexer.scanInt(seperator));
        } else if (fieldClass == String.class) {
            fieldDeser.setValue(object, lexer.scanString(seperator));
        } else if (fieldClass == Long.TYPE) {
            fieldDeser.setValue(object, lexer.scanLong(seperator));
        } else if (fieldClass.isEnum()) {
            fieldDeser.setValue(object, lexer.scanEnum(fieldClass, parser.getSymbolTable(), seperator));
        } else {
            lexer.nextToken(14);
            fieldDeser.setValue(object, parser.parseObject(fieldDeser.getFieldType()));
            if (seperator == ']') {
                if (lexer.token() != 15) {
                    throw new JSONException("syntax error");
                }
                lexer.nextToken(16);
            } else if (seperator == ',' && lexer.token() != 16) {
                throw new JSONException("syntax error");
            }
        }
        i++;
    }
    lexer.nextToken(16);
    return object;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:38,代码来源:JavaBeanDeserializer.java

示例15: deserialze

import com.alibaba.fastjson.parser.DefaultJSONParser; //导入方法依赖的package包/类
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
    JSONLexer lexer = parser.getLexer();
    if (lexer.token() == 4) {
        String text = lexer.stringVal();
        lexer.nextToken();
        if (type == LocalDateTime.class) {
            return LocalDateTime.parse(text);
        }
        if (type == LocalDate.class) {
            return LocalDate.parse(text);
        }
        if (type == LocalTime.class) {
            return LocalTime.parse(text);
        }
        if (type == ZonedDateTime.class) {
            return ZonedDateTime.parse(text);
        }
        if (type == OffsetDateTime.class) {
            return OffsetDateTime.parse(text);
        }
        if (type == OffsetTime.class) {
            return OffsetTime.parse(text);
        }
        if (type == ZoneId.class) {
            return ZoneId.of(text);
        }
        if (type == Period.class) {
            return Period.parse(text);
        }
        if (type == Duration.class) {
            return Duration.parse(text);
        }
        if (type == Instant.class) {
            return Instant.parse(text);
        }
        return null;
    }
    throw new UnsupportedOperationException();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:40,代码来源:Jdk8DateCodec.java


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