本文整理汇总了Java中com.alibaba.fastjson.parser.JSONToken.RBRACE属性的典型用法代码示例。如果您正苦于以下问题:Java JSONToken.RBRACE属性的具体用法?Java JSONToken.RBRACE怎么用?Java JSONToken.RBRACE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.alibaba.fastjson.parser.JSONToken
的用法示例。
在下文中一共展示了JSONToken.RBRACE属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasNext
public boolean hasNext() {
if (context == null) {
throw new JSONException("context is null");
}
final int token = parser.lexer.token();
final int state = context.state;
switch (state) {
case StartArray:
case ArrayValue:
return token != JSONToken.RBRACKET;
case StartObject:
case PropertyValue:
return token != JSONToken.RBRACE;
default:
throw new JSONException("illegal state : " + state);
}
}
示例2: hasNext
public boolean hasNext() {
if (context == null) {
throw new JSONException("context is null");
}
final int token = parser.getLexer().token();
final int state = context.getState();
switch (state) {
case StartArray:
case ArrayValue:
return token != JSONToken.RBRACKET;
case StartObject:
case PropertyValue:
return token != JSONToken.RBRACE;
default:
throw new JSONException("illegal state : " + state);
}
}
示例3: deserialze
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.COMMA) {
lexer.nextToken(JSONToken.LITERAL_STRING);
if (lexer.token() != JSONToken.LITERAL_STRING) {
throw new JSONException("syntax error");
}
lexer.nextTokenWithColon(JSONToken.LITERAL_INT);
if (lexer.token() != JSONToken.LITERAL_INT) {
throw new JSONException("syntax error");
}
long time = lexer.longValue();
lexer.nextToken(JSONToken.RBRACE);
if (lexer.token() != JSONToken.RBRACE) {
throw new JSONException("syntax error");
}
lexer.nextToken(JSONToken.COMMA);
return (T) new java.sql.Time(time);
}
Object val = parser.parse();
if (val == null) {
return null;
}
if (val instanceof java.sql.Time) {
return (T) val;
} else if (val instanceof Number) {
return (T) new java.sql.Time(((Number) val).longValue());
} else if (val instanceof String) {
String strVal = (String) val;
if (strVal.length() == 0) {
return null;
}
long longVal;
JSONScanner dateLexer = new JSONScanner(strVal);
if (dateLexer.scanISO8601DateIfMatch()) {
longVal = dateLexer.getCalendar().getTimeInMillis();
} else {
boolean isDigit = true;
for (int i = 0; i< strVal.length(); ++i) {
char ch = strVal.charAt(i);
if (ch < '0' || ch > '9') {
isDigit = false;
break;
}
}
if (!isDigit) {
dateLexer.close();
return (T) java.sql.Time.valueOf(strVal);
}
longVal = Long.parseLong(strVal);
}
dateLexer.close();
return (T) new java.sql.Time(longVal);
}
throw new JSONException("parse error");
}
示例4: parseFont
protected Font parseFont(DefaultJSONParser parser) {
JSONLexer lexer = parser.lexer;
int size = 0, style = 0;
String name = null;
for (;;) {
if (lexer.token() == JSONToken.RBRACE) {
lexer.nextToken();
break;
}
String key;
if (lexer.token() == JSONToken.LITERAL_STRING) {
key = lexer.stringVal();
lexer.nextTokenWithColon(JSONToken.LITERAL_INT);
} else {
throw new JSONException("syntax error");
}
if (key.equalsIgnoreCase("name")) {
if (lexer.token() == JSONToken.LITERAL_STRING) {
name = lexer.stringVal();
lexer.nextToken();
} else {
throw new JSONException("syntax error");
}
} else if (key.equalsIgnoreCase("style")) {
if (lexer.token() == JSONToken.LITERAL_INT) {
style = lexer.intValue();
lexer.nextToken();
} else {
throw new JSONException("syntax error");
}
} else if (key.equalsIgnoreCase("size")) {
if (lexer.token() == JSONToken.LITERAL_INT) {
size = lexer.intValue();
lexer.nextToken();
} else {
throw new JSONException("syntax error");
}
} else {
throw new JSONException("syntax error, " + key);
}
if (lexer.token() == JSONToken.COMMA) {
lexer.nextToken(JSONToken.LITERAL_STRING);
}
}
return new Font(name, style, size);
}
示例5: parseColor
protected Color parseColor(DefaultJSONParser parser) {
JSONLexer lexer = parser.lexer;
int r = 0, g = 0, b = 0, alpha = 0;
for (;;) {
if (lexer.token() == JSONToken.RBRACE) {
lexer.nextToken();
break;
}
String key;
if (lexer.token() == JSONToken.LITERAL_STRING) {
key = lexer.stringVal();
lexer.nextTokenWithColon(JSONToken.LITERAL_INT);
} else {
throw new JSONException("syntax error");
}
int val;
if (lexer.token() == JSONToken.LITERAL_INT) {
val = lexer.intValue();
lexer.nextToken();
} else {
throw new JSONException("syntax error");
}
if (key.equalsIgnoreCase("r")) {
r = val;
} else if (key.equalsIgnoreCase("g")) {
g = val;
} else if (key.equalsIgnoreCase("b")) {
b = val;
} else if (key.equalsIgnoreCase("alpha")) {
alpha = val;
} else {
throw new JSONException("syntax error, " + key);
}
if (lexer.token() == JSONToken.COMMA) {
lexer.nextToken(JSONToken.LITERAL_STRING);
}
}
return new Color(r, g, b, alpha);
}
示例6: deserialze
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
JSONLexer lexer = parser.getLexer();
if (lexer.token() == JSONToken.COMMA) {
lexer.nextToken(JSONToken.LITERAL_STRING);
if (lexer.token() != JSONToken.LITERAL_STRING) {
throw new JSONException("syntax error");
}
lexer.nextTokenWithColon(JSONToken.LITERAL_INT);
if (lexer.token() != JSONToken.LITERAL_INT) {
throw new JSONException("syntax error");
}
long time = lexer.longValue();
lexer.nextToken(JSONToken.RBRACE);
if (lexer.token() != JSONToken.RBRACE) {
throw new JSONException("syntax error");
}
lexer.nextToken(JSONToken.COMMA);
return (T) new java.sql.Time(time);
}
Object val = parser.parse();
if (val == null) {
return null;
}
if (val instanceof java.sql.Time) {
return (T) val;
} else if (val instanceof Number) {
return (T) new java.sql.Time(((Number) val).longValue());
} else if (val instanceof String) {
String strVal = (String) val;
if (strVal.length() == 0) {
return null;
}
long longVal;
JSONScanner dateLexer = new JSONScanner(strVal);
if (dateLexer.scanISO8601DateIfMatch()) {
longVal = dateLexer.getCalendar().getTimeInMillis();
} else {
longVal = Long.parseLong(strVal);
}
dateLexer.close();
return (T) new java.sql.Time(longVal);
}
throw new JSONException("parse error");
}
示例7: deserialze
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONLexer lexer = parser.getLexer();
if (lexer.token() == JSONToken.NULL) {
lexer.nextToken();
return null;
}
if (lexer.token() != JSONToken.LBRACE && lexer.token() != JSONToken.COMMA) {
throw new JSONException("syntax error");
}
lexer.nextToken();
int x = 0, y = 0, width = 0, height = 0;
for (;;) {
if (lexer.token() == JSONToken.RBRACE) {
lexer.nextToken();
break;
}
String key;
if (lexer.token() == JSONToken.LITERAL_STRING) {
key = lexer.stringVal();
lexer.nextTokenWithColon(JSONToken.LITERAL_INT);
} else {
throw new JSONException("syntax error");
}
int val;
if (lexer.token() == JSONToken.LITERAL_INT) {
val = lexer.intValue();
lexer.nextToken();
} else {
throw new JSONException("syntax error");
}
if (key.equalsIgnoreCase("x")) {
x = val;
} else if (key.equalsIgnoreCase("y")) {
y = val;
} else if (key.equalsIgnoreCase("width")) {
width = val;
} else if (key.equalsIgnoreCase("height")) {
height = val;
} else {
throw new JSONException("syntax error, " + key);
}
if (lexer.token() == JSONToken.COMMA) {
lexer.nextToken(JSONToken.LITERAL_STRING);
}
}
return (T) new Rectangle(x, y, width, height);
}
示例8: deserialze
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONLexer lexer = parser.getLexer();
if (lexer.token() != JSONToken.LBRACE && lexer.token() != JSONToken.COMMA) {
throw new JSONException("syntax error");
}
lexer.nextToken();
int r = 0, g = 0, b = 0, alpha = 0;
for (;;) {
if (lexer.token() == JSONToken.RBRACE) {
lexer.nextToken();
break;
}
String key;
if (lexer.token() == JSONToken.LITERAL_STRING) {
key = lexer.stringVal();
lexer.nextTokenWithColon(JSONToken.LITERAL_INT);
} else {
throw new JSONException("syntax error");
}
int val;
if (lexer.token() == JSONToken.LITERAL_INT) {
val = lexer.intValue();
lexer.nextToken();
} else {
throw new JSONException("syntax error");
}
if (key.equalsIgnoreCase("r")) {
r = val;
} else if (key.equalsIgnoreCase("g")) {
g = val;
} else if (key.equalsIgnoreCase("b")) {
b = val;
} else if (key.equalsIgnoreCase("alpha")) {
alpha = val;
} else {
throw new JSONException("syntax error, " + key);
}
if (lexer.token() == JSONToken.COMMA) {
lexer.nextToken(JSONToken.LITERAL_STRING);
}
}
return (T) new Color(r, g, b, alpha);
}
示例9: deserialze
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONLexer lexer = parser.getLexer();
if (lexer.token() == JSONToken.NULL) {
lexer.nextToken(JSONToken.COMMA);
return null;
}
if (lexer.token() != JSONToken.LBRACE && lexer.token() != JSONToken.COMMA) {
throw new JSONException("syntax error");
}
lexer.nextToken();
int size = 0, style = 0;
String name = null;
for (;;) {
if (lexer.token() == JSONToken.RBRACE) {
lexer.nextToken();
break;
}
String key;
if (lexer.token() == JSONToken.LITERAL_STRING) {
key = lexer.stringVal();
lexer.nextTokenWithColon(JSONToken.LITERAL_INT);
} else {
throw new JSONException("syntax error");
}
if (key.equalsIgnoreCase("name")) {
if (lexer.token() == JSONToken.LITERAL_STRING) {
name = lexer.stringVal();
lexer.nextToken();
} else {
throw new JSONException("syntax error");
}
} else if (key.equalsIgnoreCase("style")) {
if (lexer.token() == JSONToken.LITERAL_INT) {
style = lexer.intValue();
lexer.nextToken();
} else {
throw new JSONException("syntax error");
}
} else if (key.equalsIgnoreCase("size")) {
if (lexer.token() == JSONToken.LITERAL_INT) {
size = lexer.intValue();
lexer.nextToken();
} else {
throw new JSONException("syntax error");
}
} else {
throw new JSONException("syntax error, " + key);
}
if (lexer.token() == JSONToken.COMMA) {
lexer.nextToken(JSONToken.LITERAL_STRING);
}
}
return (T) new Font(name, style, size);
}
示例10: deserialze
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONLexer lexer = parser.getLexer();
if (lexer.token() == JSONToken.NULL) {
lexer.nextToken(JSONToken.COMMA);
return null;
}
if (lexer.token() != JSONToken.LBRACE && lexer.token() != JSONToken.COMMA) {
throw new JSONException("syntax error");
}
lexer.nextToken();
int x = 0, y = 0;
for (;;) {
if (lexer.token() == JSONToken.RBRACE) {
lexer.nextToken();
break;
}
String key;
if (lexer.token() == JSONToken.LITERAL_STRING) {
key = lexer.stringVal();
if (JSON.DEFAULT_TYPE_KEY.equals(key)) {
parser.acceptType("java.awt.Point");
continue;
}
lexer.nextTokenWithColon(JSONToken.LITERAL_INT);
} else {
throw new JSONException("syntax error");
}
int val;
if (lexer.token() == JSONToken.LITERAL_INT) {
val = lexer.intValue();
lexer.nextToken();
} else {
throw new JSONException("syntax error : " + lexer.tokenName());
}
if (key.equalsIgnoreCase("x")) {
x = val;
} else if (key.equalsIgnoreCase("y")) {
y = val;
} else {
throw new JSONException("syntax error, " + key);
}
if (lexer.token() == JSONToken.COMMA) {
lexer.nextToken(JSONToken.LITERAL_STRING);
}
}
return (T) new Point(x, y);
}