本文整理汇总了Java中com.alibaba.fastjson.util.TypeUtils.castToLong方法的典型用法代码示例。如果您正苦于以下问题:Java TypeUtils.castToLong方法的具体用法?Java TypeUtils.castToLong怎么用?Java TypeUtils.castToLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.fastjson.util.TypeUtils
的用法示例。
在下文中一共展示了TypeUtils.castToLong方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserialze
import com.alibaba.fastjson.util.TypeUtils; //导入方法依赖的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;
}
示例2: deserialze
import com.alibaba.fastjson.util.TypeUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
final JSONLexer lexer = parser.getLexer();
Long longObject;
if (lexer.token() == JSONToken.LITERAL_INT) {
long longValue = lexer.longValue();
lexer.nextToken(JSONToken.COMMA);
longObject = Long.valueOf(longValue);
} else {
Object value = parser.parse();
if (value == null) {
return null;
}
longObject = TypeUtils.castToLong(value);
}
if (clazz == AtomicLong.class) {
return (T) new AtomicLong(longObject.longValue());
}
return (T) longObject;
}
示例3: readLong
import com.alibaba.fastjson.util.TypeUtils; //导入方法依赖的package包/类
public Long readLong() {
Object object;
if (context == null) {
object = parser.parse();
} else {
readBefore();
object = parser.parse();
readAfter();
}
return TypeUtils.castToLong(object);
}
示例4: deserialze
import com.alibaba.fastjson.util.TypeUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
final JSONLexer lexer = parser.lexer;
Long longObject;
try {
final int token = lexer.token();
if (token == JSONToken.LITERAL_INT) {
long longValue = lexer.longValue();
lexer.nextToken(JSONToken.COMMA);
longObject = Long.valueOf(longValue);
} else {
if (token == JSONToken.LBRACE) {
JSONObject jsonObject = new JSONObject(true);
parser.parseObject(jsonObject);
longObject = TypeUtils.castToLong(jsonObject);
} else {
Object value = parser.parse();
longObject = TypeUtils.castToLong(value);
}
if (longObject == null) {
return null;
}
}
} catch (Exception ex) {
throw new JSONException("parseLong error, field : " + fieldName, ex);
}
return clazz == AtomicLong.class //
? (T) new AtomicLong(longObject.longValue()) //
: (T) longObject;
}
示例5: parseField
import com.alibaba.fastjson.util.TypeUtils; //导入方法依赖的package包/类
public void parseField(DefaultJSONParser parser, Object object, Type objectType, Map<String, Object> fieldValues) {
JSONLexer lexer = parser.getLexer();
if (lexer.token() == 2) {
long val = lexer.longValue();
lexer.nextToken(16);
if (object == null) {
fieldValues.put(this.fieldInfo.getName(), Long.valueOf(val));
return;
} else {
setValue(object, val);
return;
}
}
Long value;
if (lexer.token() == 8) {
value = null;
lexer.nextToken(16);
} else {
value = TypeUtils.castToLong(parser.parse());
}
if (value != null || getFieldClass() != Long.TYPE) {
if (object == null) {
fieldValues.put(this.fieldInfo.getName(), value);
} else {
setValue(object, (Object) value);
}
}
}
示例6: readLong
import com.alibaba.fastjson.util.TypeUtils; //导入方法依赖的package包/类
public Long readLong() {
Object object;
if (this.context == null) {
object = this.parser.parse();
} else {
readBefore();
object = this.parser.parse();
readAfter();
}
return TypeUtils.castToLong(object);
}
示例7: parseField
import com.alibaba.fastjson.util.TypeUtils; //导入方法依赖的package包/类
@Override
public void parseField(DefaultJSONParser parser, Object object, Type objectType, Map<String, Object> fieldValues) {
Long value;
final JSONLexer lexer = parser.getLexer();
if (lexer.token() == JSONToken.LITERAL_INT) {
long val = lexer.longValue();
lexer.nextToken(JSONToken.COMMA);
if (object == null) {
fieldValues.put(fieldInfo.getName(), val);
} else {
setValue(object, val);
}
return;
} else if (lexer.token() == JSONToken.NULL) {
value = null;
lexer.nextToken(JSONToken.COMMA);
} else {
Object obj = parser.parse();
value = TypeUtils.castToLong(obj);
}
if (value == null && getFieldClass() == long.class) {
// skip
return;
}
if (object == null) {
fieldValues.put(fieldInfo.getName(), value);
} else {
setValue(object, value);
}
}
示例8: getLong
import com.alibaba.fastjson.util.TypeUtils; //导入方法依赖的package包/类
public Long getLong(String key) {
return TypeUtils.castToLong(get(key));
}
示例9: getLong
import com.alibaba.fastjson.util.TypeUtils; //导入方法依赖的package包/类
public Long getLong(int index) {
return TypeUtils.castToLong(get(index));
}