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


Java JSONToken.LBRACKET属性代码示例

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


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

示例1: deserialze

@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
    Image image = new Image();

    final JSONLexer lexer = parser.getLexer();
    if (lexer.token() != JSONToken.LBRACKET) {
        throw new JSONException("error");
    }
    
    int height = lexer.scanInt(',');
    int width = lexer.scanInt(',');
    String sizeName = lexer.scanSymbolWithSeperator(parser.getSymbolTable(), ',');
    String title = lexer.scanString(',');
    String uri = lexer.scanString(']');
    
    lexer.nextToken(JSONToken.COMMA);
    
    image.setHeight(height);
    image.setWidth(width);
    image.setSize(Size.valueOf(sizeName));
    image.setTitle(title);
    image.setUri(uri);
    return (T) image;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:ImageDeserializer.java

示例2: _quickNextToken

private void _quickNextToken(Context context, MethodVisitor mw, int token) {
    Label quickElse_ = new Label(), quickEnd_ = new Label();
    mw.visitVarInsn(ALOAD, context.var("lexer"));
    mw.visitMethodInsn(INVOKEVIRTUAL, JSONLexerBase, "getCurrent", "()C");
    if (token == JSONToken.LBRACE) {
        mw.visitVarInsn(BIPUSH, '{');
    } else if (token == JSONToken.LBRACKET) {
        mw.visitVarInsn(BIPUSH, '[');
    } else {
        throw new IllegalStateException();
    }

    mw.visitJumpInsn(IF_ICMPNE, quickElse_);

    mw.visitVarInsn(ALOAD, context.var("lexer"));
    mw.visitMethodInsn(INVOKEVIRTUAL, JSONLexerBase, "next", "()C");
    mw.visitInsn(POP);
    mw.visitVarInsn(ALOAD, context.var("lexer"));
    mw.visitLdcInsn(token);
    mw.visitMethodInsn(INVOKEVIRTUAL, JSONLexerBase, "setToken", "(I)V");
    mw.visitJumpInsn(GOTO, quickEnd_);

    mw.visitLabel(quickElse_);
    mw.visitVarInsn(ALOAD, context.var("lexer"));
    mw.visitLdcInsn(token);
    mw.visitMethodInsn(INVOKEVIRTUAL, JSONLexerBase, "nextToken", "(I)V");

    mw.visitLabel(quickEnd_);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:ASMDeserializerFactory.java

示例3: parseArray

@SuppressWarnings({ "unchecked", "rawtypes" })
public final void parseArray(DefaultJSONParser parser, Type objectType, Collection array) {
    Type itemType = this.itemType;
    ObjectDeserializer itemTypeDeser = this.deserializer;
    
    if (itemType instanceof TypeVariable //
        && objectType instanceof ParameterizedType) {
        TypeVariable typeVar = (TypeVariable) itemType;
        ParameterizedType paramType = (ParameterizedType) objectType;

        Class<?> objectClass = null;
        if (paramType.getRawType() instanceof Class) {
            objectClass = (Class<?>) paramType.getRawType();
        }

        int paramIndex = -1;
        if (objectClass != null) {
            for (int i = 0, size = objectClass.getTypeParameters().length; i < size; ++i) {
                TypeVariable item = objectClass.getTypeParameters()[i];
                if (item.getName().equals(typeVar.getName())) {
                    paramIndex = i;
                    break;
                }
            }
        }

        if (paramIndex != -1) {
            itemType = paramType.getActualTypeArguments()[paramIndex];
            if (!itemType.equals(this.itemType)) {
                itemTypeDeser = parser.getConfig().getDeserializer(itemType);
            }
        }
    }

    final JSONLexer lexer = parser.getLexer();

    if (lexer.token() != JSONToken.LBRACKET) {
        String errorMessage = "exepct '[', but " + JSONToken.name(lexer.token());
        if (objectType != null) {
            errorMessage += ", type : " + objectType;
        }
        throw new JSONException(errorMessage);
    }

    if (itemTypeDeser == null) {
        itemTypeDeser = deserializer = parser.getConfig().getDeserializer(itemType);
        itemFastMatchToken = deserializer.getFastMatchToken();
    }

    lexer.nextToken(itemFastMatchToken);

    for (int i = 0;; ++i) {
        if (lexer.isEnabled(Feature.AllowArbitraryCommas)) {
            while (lexer.token() == JSONToken.COMMA) {
                lexer.nextToken();
                continue;
            }
        }

        if (lexer.token() == JSONToken.RBRACKET) {
            break;
        }

        Object val = itemTypeDeser.deserialze(parser, itemType, i);
        array.add(val);

        parser.checkListResolve(array);

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

    lexer.nextToken(JSONToken.COMMA);
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:76,代码来源:ArrayListTypeFieldDeserializer.java

示例4: getFastMatchToken

public int getFastMatchToken() {
    return JSONToken.LBRACKET;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:3,代码来源:ArrayListTypeFieldDeserializer.java

示例5: parseArray

@SuppressWarnings({ "unchecked", "rawtypes" })
    protected static void parseArray(Collection collection, //
                              ObjectDeserializer deser, //
                              DefaultJSONParser parser, //
                              Type type, //
                              Object fieldName) {

        final JSONLexerBase lexer = (JSONLexerBase) parser.lexer;
        int token = lexer.token();
        if (token == JSONToken.NULL) {
            lexer.nextToken(JSONToken.COMMA);
            token = lexer.token();
            return;
        }

        if (token != JSONToken.LBRACKET) {
            parser.throwException(token);
        }
        char ch = lexer.getCurrent();
        if (ch == '[') {
            lexer.next();
            lexer.setToken(JSONToken.LBRACKET);
        } else {
            lexer.nextToken(JSONToken.LBRACKET);
        }
        
        if (lexer.token() == JSONToken.RBRACKET) {
            lexer.nextToken();
            return;
        }

        int index = 0;
        for (;;) {
            Object item = deser.deserialze(parser, type, index);
            collection.add(item);
            index++;
            if (lexer.token() == JSONToken.COMMA) {
                ch = lexer.getCurrent();
                if (ch == '[') {
                    lexer.next();
                    lexer.setToken(JSONToken.LBRACKET);
                } else {
                    lexer.nextToken(JSONToken.LBRACKET);
                }
            } else {
                break;
            }
        }
        
        token = lexer.token();
        if (token != JSONToken.RBRACKET) {
            parser.throwException(token);
        }
        
        ch = lexer.getCurrent();
        if (ch == ',') {
            lexer.next();
            lexer.setToken(JSONToken.COMMA);
        } else {
            lexer.nextToken(JSONToken.COMMA);
        }
//        parser.accept(JSONToken.RBRACKET, JSONToken.COMMA);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:63,代码来源:JavaBeanDeserializer.java

示例6: deserialze

@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
    final JSONLexer lexer = parser.getLexer();

    if (lexer.token() != JSONToken.LBRACKET) {
        throw new JSONException("error");
    }

    Media media = new Media();

    int bitrate = lexer.scanInt(',');
    int height = lexer.scanInt(',');
    int width = lexer.scanInt(',');
    String copyright = lexer.scanString(',');
    long duration = lexer.scanLong(',');
    String format = lexer.scanString(',');

    List<String> persons = new ArrayList<String>();
    lexer.scanStringArray(persons, ',');

    String playerName = lexer.scanSymbolWithSeperator(parser.getSymbolTable(), ',');
    long size = lexer.scanLong(',');
    String title = lexer.scanString(',');
    String uri = lexer.scanString(']');

    lexer.nextToken(JSONToken.COMMA);

    media.setBitrate(bitrate);
    media.setHeight(height);
    media.setWidth(width);
    media.setCopyright(copyright);
    media.setDuration(duration);
    media.setFormat(format);
    media.setPersons(persons);
    media.setPlayer(playerName == null ? null : Player.valueOf(playerName));
    media.setSize(size);
    media.setTitle(title);
    media.setUri(uri);

    return (T) media;

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:42,代码来源:MediaDeserializer.java


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