Java Code Examples for com.alibaba.fastjson.util.TypeUtils#castToInt()
The following examples show how to use
com.alibaba.fastjson.util.TypeUtils#castToInt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JSONReader.java From uavstack with Apache License 2.0 | 5 votes |
public Integer readInteger() { Object object; if (context == null) { object = parser.parse(); } else { readBefore(); object = parser.parse(); readAfter(); } return TypeUtils.castToInt(object); }
Example 2
Source File: IntegerCodec.java From uavstack with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) { final JSONLexer lexer = parser.lexer; final int token = lexer.token(); if (token == JSONToken.NULL) { lexer.nextToken(JSONToken.COMMA); return null; } Integer intObj; try { if (token == JSONToken.LITERAL_INT) { int val = lexer.intValue(); lexer.nextToken(JSONToken.COMMA); intObj = Integer.valueOf(val); } else if (token == JSONToken.LITERAL_FLOAT) { BigDecimal number = lexer.decimalValue(); intObj = TypeUtils.intValue(number); lexer.nextToken(JSONToken.COMMA); } else { if (token == JSONToken.LBRACE) { JSONObject jsonObject = new JSONObject(true); parser.parseObject(jsonObject); intObj = TypeUtils.castToInt(jsonObject); } else { Object value = parser.parse(); intObj = TypeUtils.castToInt(value); } } } catch (Exception ex) { throw new JSONException("parseInt error, field : " + fieldName, ex); } if (clazz == AtomicInteger.class) { return (T) new AtomicInteger(intObj.intValue()); } return (T) intObj; }
Example 3
Source File: PropertiesModel.java From phone with Apache License 2.0 | 4 votes |
public Integer getInteger(Object key){ return TypeUtils.castToInt(get(key)); }
Example 4
Source File: ExcelCellValue.java From poi-excel-utils with Apache License 2.0 | 4 votes |
public Integer getIntValue() { return TypeUtils.castToInt(originalValue); }