本文整理汇总了Java中com.fasterxml.jackson.core.JsonParser.NumberType类的典型用法代码示例。如果您正苦于以下问题:Java NumberType类的具体用法?Java NumberType怎么用?Java NumberType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NumberType类属于com.fasterxml.jackson.core.JsonParser包,在下文中一共展示了NumberType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: _testInts
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
private void _testInts(JsonFactory f, int[] values,
byte[] data, int offset, int readSize) throws IOException
{
AsyncReaderWrapper r = asyncForBytes(f, readSize, data, offset);
// start with "no token"
assertNull(r.currentToken());
assertToken(JsonToken.START_ARRAY, r.nextToken());
for (int i = 0; i < values.length; ++i) {
assertToken(JsonToken.VALUE_NUMBER_INT, r.nextToken());
assertEquals(values[i], r.getIntValue());
assertEquals(NumberType.INT, r.getNumberType());
// and then couple of special modes, just to get better test coverage
String asStr = String.valueOf(values[i]);
assertEquals(asStr, r.currentText());
StringWriter sw = new StringWriter();
assertEquals(asStr.length(), r.parser().getText(sw));
assertEquals(asStr, sw.toString());
}
assertToken(JsonToken.END_ARRAY, r.nextToken());
// and end up with "no token" as well
assertNull(r.nextToken());
assertTrue(r.isClosed());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:AsyncScalarArrayTest.java
示例2: _testLong
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
private void _testLong(JsonFactory f, long[] values,
byte[] data, int offset, int readSize) throws IOException
{
AsyncReaderWrapper r = asyncForBytes(f, readSize, data, offset);
// start with "no token"
assertNull(r.currentToken());
assertToken(JsonToken.START_ARRAY, r.nextToken());
for (int i = 0; i < values.length; ++i) {
assertToken(JsonToken.VALUE_NUMBER_INT, r.nextToken());
assertEquals(values[i], r.getLongValue());
assertEquals(NumberType.LONG, r.getNumberType());
}
assertToken(JsonToken.END_ARRAY, r.nextToken());
// and end up with "no token" as well
assertNull(r.nextToken());
assertTrue(r.isClosed());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:AsyncScalarArrayTest.java
示例3: _testFloats
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
private void _testFloats(JsonFactory f, float[] values,
byte[] data, int offset, int readSize) throws IOException
{
AsyncReaderWrapper r = asyncForBytes(f, readSize, data, offset);
// start with "no token"
assertNull(r.currentToken());
assertToken(JsonToken.START_ARRAY, r.nextToken());
for (int i = 0; i < values.length; ++i) {
assertToken(JsonToken.VALUE_NUMBER_FLOAT, r.nextToken());
assertEquals(values[i], r.getFloatValue());
// json can't distinguish floats from doubles so
assertEquals(NumberType.DOUBLE, r.getNumberType());
}
assertToken(JsonToken.END_ARRAY, r.nextToken());
// and end up with "no token" as well
assertNull(r.nextToken());
assertTrue(r.isClosed());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:AsyncScalarArrayTest.java
示例4: _testDoubles
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
private void _testDoubles(JsonFactory f, double[] values,
byte[] data, int offset, int readSize) throws IOException
{
AsyncReaderWrapper r = asyncForBytes(f, readSize, data, offset);
// start with "no token"
assertNull(r.currentToken());
assertToken(JsonToken.START_ARRAY, r.nextToken());
for (int i = 0; i < values.length; ++i) {
assertToken(JsonToken.VALUE_NUMBER_FLOAT, r.nextToken());
assertEquals(String.format("Entry #%d: %s (textual '%s')",
i, values[i], r.currentText()),
values[i], r.getDoubleValue());
assertEquals(NumberType.DOUBLE, r.getNumberType());
}
assertToken(JsonToken.END_ARRAY, r.nextToken());
// and end up with "no token" as well
assertNull(r.nextToken());
assertTrue(r.isClosed());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:AsyncScalarArrayTest.java
示例5: _testBigIntegers
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
private void _testBigIntegers(JsonFactory f, BigInteger[] values,
byte[] data, int offset, int readSize) throws IOException
{
AsyncReaderWrapper r = asyncForBytes(f, readSize, data, offset);
// start with "no token"
assertNull(r.currentToken());
assertToken(JsonToken.START_ARRAY, r.nextToken());
for (int i = 0; i < values.length; ++i) {
BigInteger expValue = values[i];
assertToken(JsonToken.VALUE_NUMBER_INT, r.nextToken());
assertEquals(expValue, r.getBigIntegerValue());
assertEquals(NumberType.BIG_INTEGER, r.getNumberType());
}
assertToken(JsonToken.END_ARRAY, r.nextToken());
assertNull(r.nextToken());
assertTrue(r.isClosed());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:AsyncScalarArrayTest.java
示例6: _testBigDecimals
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
private void _testBigDecimals(JsonFactory f, BigDecimal[] values,
byte[] doc, int offset, int readSize) throws IOException
{
AsyncReaderWrapper r = asyncForBytes(f, readSize, doc, offset);
// start with "no token"
assertNull(r.currentToken());
assertToken(JsonToken.START_ARRAY, r.nextToken());
for (int i = 0; i < values.length; ++i) {
BigDecimal expValue = values[i];
assertToken(JsonToken.VALUE_NUMBER_FLOAT, r.nextToken());
assertEquals(expValue, r.getDecimalValue());
assertEquals(NumberType.BIG_DECIMAL, r.getNumberType());
}
assertToken(JsonToken.END_ARRAY, r.nextToken());
assertNull(r.nextToken());
assertTrue(r.isClosed());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:AsyncScalarArrayTest.java
示例7: doLe
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
protected boolean doLe(JsonNode propertyNode, JsonNode passedNode){
if(propertyNode.isNumber() && passedNode.isNumber() && propertyNode.numberType() == passedNode.numberType()) {
Number propertyValue = propertyNode.numberValue();
Number passedValue = passedNode.numberValue();
if(propertyNode.numberType() == NumberType.INT) {
return ((Integer) propertyValue <= (Integer) passedValue);
} else if(propertyNode.numberType() == NumberType.LONG) {
return ((Long) propertyValue <= (Long) passedValue);
} else if(propertyNode.numberType() == NumberType.FLOAT) {
return ((Float) propertyValue <= (Float) passedValue);
} else if(propertyNode.numberType() == NumberType.DOUBLE) {
return ((Double) propertyValue <= (Double) passedValue);
} else {
throw new UnsupportedExprException("Le supports only INT, LONG, DOUBLE, FLOAT values");
}
} else {
throw new UnsupportedExprException("Le supports only numeric values of same type for comparison");
}
}
开发者ID:kcthota,项目名称:JSONQuery,代码行数:20,代码来源:LeExpression.java
示例8: doGt
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
protected boolean doGt(JsonNode propertyNode, JsonNode passedNode){
if(propertyNode.isNumber() && passedNode.isNumber() && propertyNode.numberType() == passedNode.numberType()) {
Number propertyValue = propertyNode.numberValue();
Number passedValue = passedNode.numberValue();
if(propertyNode.numberType() == NumberType.INT) {
return ((Integer) propertyValue > (Integer) passedValue);
} else if(propertyNode.numberType() == NumberType.LONG) {
return ((Long) propertyValue > (Long) passedValue);
} else if(propertyNode.numberType() == NumberType.FLOAT) {
return ((Float) propertyValue > (Float) passedValue);
} else if(propertyNode.numberType() == NumberType.DOUBLE) {
return ((Double) propertyValue > (Double) passedValue);
} else {
throw new UnsupportedExprException("Gt supports only INT, LONG, DOUBLE, FLOAT values");
}
} else {
throw new UnsupportedExprException("Gt supports only numeric values of same type for comparison");
}
}
开发者ID:kcthota,项目名称:JSONQuery,代码行数:20,代码来源:GtExpression.java
示例9: doLt
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
protected boolean doLt(JsonNode propertyNode, JsonNode passedNode){
if(propertyNode.isNumber() && passedNode.isNumber() && propertyNode.numberType() == passedNode.numberType()) {
Number propertyValue = propertyNode.numberValue();
Number passedValue = passedNode.numberValue();
if(propertyNode.numberType() == NumberType.INT) {
return ((Integer) propertyValue < (Integer) passedValue);
} else if(propertyNode.numberType() == NumberType.LONG) {
return ((Long) propertyValue < (Long) passedValue);
} else if(propertyNode.numberType() == NumberType.FLOAT) {
return ((Float) propertyValue < (Float) passedValue);
} else if(propertyNode.numberType() == NumberType.DOUBLE) {
return ((Double) propertyValue < (Double) passedValue);
} else {
throw new UnsupportedExprException("Lt supports only INT, LONG, DOUBLE, FLOAT values");
}
} else {
throw new UnsupportedExprException("Lt supports only numeric values of same type for comparison");
}
}
开发者ID:kcthota,项目名称:JSONQuery,代码行数:20,代码来源:LtExpression.java
示例10: doGe
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
private boolean doGe(JsonNode propertyNode, JsonNode passedNode){
if(propertyNode.isNumber() && passedNode.isNumber() && propertyNode.numberType() == passedNode.numberType()) {
Number propertyValue = propertyNode.numberValue();
Number passedValue = passedNode.numberValue();
if(propertyNode.numberType() == NumberType.INT) {
return ((Integer) propertyValue >= (Integer) passedValue);
} else if(propertyNode.numberType() == NumberType.LONG) {
return ((Long) propertyValue >= (Long) passedValue);
} else if(propertyNode.numberType() == NumberType.FLOAT) {
return ((Float) propertyValue >= (Float) passedValue);
} else if(propertyNode.numberType() == NumberType.DOUBLE) {
return ((Double) propertyValue >=(Double) passedValue);
} else {
throw new UnsupportedExprException("Ge supports only INT, LONG, DOUBLE, FLOAT values");
}
} else {
throw new UnsupportedExprException("Ge supports only numeric values of same type for comparison");
}
}
开发者ID:kcthota,项目名称:JSONQuery,代码行数:20,代码来源:GeExpression.java
示例11: acceptJsonFormatVisitor
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper paramJsonFormatVisitorWrapper, JavaType paramJavaType)
{
boolean bool1 = this._useTimestamp;
boolean bool2 = bool1;
if ((!bool1) && (this._customFormat == null))
bool2 = paramJsonFormatVisitorWrapper.getProvider().isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
if (bool2)
{
JsonIntegerFormatVisitor localJsonIntegerFormatVisitor = paramJsonFormatVisitorWrapper.expectIntegerFormat(paramJavaType);
if (localJsonIntegerFormatVisitor != null)
{
localJsonIntegerFormatVisitor.numberType(JsonParser.NumberType.LONG);
localJsonIntegerFormatVisitor.format(JsonValueFormat.UTC_MILLISEC);
}
return;
}
JsonStringFormatVisitor localJsonStringFormatVisitor = paramJsonFormatVisitorWrapper.expectStringFormat(paramJavaType);
if (localJsonStringFormatVisitor != null)
localJsonStringFormatVisitor.format(JsonValueFormat.DATE_TIME);
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:21,代码来源:DateTimeSerializerBase.java
示例12: acceptJsonFormatVisitor
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper paramJsonFormatVisitorWrapper, JavaType paramJavaType)
{
if (paramJsonFormatVisitorWrapper.getProvider().isEnabled(SerializationFeature.WRITE_ENUMS_USING_INDEX))
{
JsonIntegerFormatVisitor localJsonIntegerFormatVisitor = paramJsonFormatVisitorWrapper.expectIntegerFormat(paramJavaType);
if (localJsonIntegerFormatVisitor != null)
localJsonIntegerFormatVisitor.numberType(JsonParser.NumberType.INT);
return;
}
JsonStringFormatVisitor localJsonStringFormatVisitor = paramJsonFormatVisitorWrapper.expectStringFormat(paramJavaType);
if ((paramJavaType != null) && (localJsonStringFormatVisitor != null) && (paramJavaType.isEnumType()))
{
LinkedHashSet localLinkedHashSet = new LinkedHashSet();
Iterator localIterator = this._values.values().iterator();
while (localIterator.hasNext())
localLinkedHashSet.add(((SerializedString)localIterator.next()).getValue());
localJsonStringFormatVisitor.enumTypes(localLinkedHashSet);
}
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:20,代码来源:EnumSerializer.java
示例13: _parseBooleanFromNumber
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
protected final boolean _parseBooleanFromNumber(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
{
if (paramJsonParser.getNumberType() == JsonParser.NumberType.LONG)
{
Boolean localBoolean;
if (paramJsonParser.getLongValue() == 0L)
localBoolean = Boolean.FALSE;
else
localBoolean = Boolean.TRUE;
return localBoolean.booleanValue();
}
String str = paramJsonParser.getText();
if (("0.0".equals(str)) || ("0".equals(str)))
return Boolean.FALSE.booleanValue();
return Boolean.TRUE.booleanValue();
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:17,代码来源:StdDeserializer.java
示例14: _parseBooleanPrimitive
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
protected final boolean _parseBooleanPrimitive(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
{
JsonToken localJsonToken = paramJsonParser.getCurrentToken();
if (localJsonToken == JsonToken.VALUE_TRUE)
return true;
if (localJsonToken == JsonToken.VALUE_FALSE)
return false;
if (localJsonToken == JsonToken.VALUE_NULL)
return false;
if (localJsonToken == JsonToken.VALUE_NUMBER_INT)
{
if (paramJsonParser.getNumberType() == JsonParser.NumberType.INT)
return paramJsonParser.getIntValue() != 0;
return _parseBooleanFromNumber(paramJsonParser, paramDeserializationContext);
}
if (localJsonToken == JsonToken.VALUE_STRING)
{
String str = paramJsonParser.getText().trim();
if ("true".equals(str))
return true;
if (("false".equals(str)) || (str.length() == 0))
return Boolean.FALSE.booleanValue();
throw paramDeserializationContext.weirdStringException(str, this._valueClass, "only \"true\" or \"false\" recognized");
}
throw paramDeserializationContext.mappingException(this._valueClass, localJsonToken);
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:27,代码来源:StdDeserializer.java
示例15: getNumberType
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
public final JsonParser.NumberType getNumberType()
{
Number localNumber = getNumberValue();
if ((localNumber instanceof Integer))
return JsonParser.NumberType.INT;
if ((localNumber instanceof Long))
return JsonParser.NumberType.LONG;
if ((localNumber instanceof Double))
return JsonParser.NumberType.DOUBLE;
if ((localNumber instanceof BigDecimal))
return JsonParser.NumberType.BIG_DECIMAL;
if ((localNumber instanceof BigInteger))
return JsonParser.NumberType.BIG_INTEGER;
if ((localNumber instanceof Float))
return JsonParser.NumberType.FLOAT;
if ((localNumber instanceof Short))
return JsonParser.NumberType.INT;
return null;
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:20,代码来源:TokenBuffer.java
示例16: _testNumbers
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
private void _testNumbers(JsonFactory f,
byte[] data, int offset, int readSize) throws IOException
{
AsyncReaderWrapper r = asyncForBytes(f, readSize, data, offset);
// start with "no token"
assertNull(r.currentToken());
assertToken(JsonToken.START_OBJECT, r.nextToken());
assertToken(JsonToken.FIELD_NAME, r.nextToken());
assertEquals("i1", r.currentText());
assertToken(JsonToken.VALUE_NUMBER_INT, r.nextToken());
assertEquals(NumberType.INT, r.getNumberType());
assertEquals(NUMBER_EXP_I, r.getIntValue());
assertEquals((double)NUMBER_EXP_I, r.getDoubleValue());
assertToken(JsonToken.FIELD_NAME, r.nextToken());
assertEquals("doubley", r.currentText());
assertToken(JsonToken.VALUE_NUMBER_FLOAT, r.nextToken());
assertEquals(NumberType.DOUBLE, r.getNumberType());
assertEquals(NUMBER_EXP_D, r.getDoubleValue());
assertEquals((long) NUMBER_EXP_D, r.getLongValue());
assertToken(JsonToken.FIELD_NAME, r.nextToken());
assertEquals("biggieDecimal", r.currentText());
assertToken(JsonToken.VALUE_NUMBER_FLOAT, r.nextToken());
// can't really tell double/BigDecimal apart in plain json
assertEquals(NumberType.DOUBLE, r.getNumberType());
assertEquals(NUMBER_EXP_BD, r.getDecimalValue());
assertEquals(""+NUMBER_EXP_BD, r.currentText());
assertToken(JsonToken.END_OBJECT, r.nextToken());
// and end up with "no token" as well
assertNull(r.nextToken());
assertTrue(r.isClosed());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:37,代码来源:AsyncSimpleObjectTest.java
示例17: parseArray
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
private cfData parseArray(JsonParser jp, cfArrayData array, boolean bStrictMapping ) throws JsonParseException, IOException, cfmRunTimeException{
JsonToken token = jp.nextToken();
while ( token != JsonToken.END_ARRAY ){
if ( token == JsonToken.START_ARRAY ){
array.addElement( parseArray(jp,cfArrayData.createArray(1),bStrictMapping ) );
}else if ( token == JsonToken.START_OBJECT ){
array.addElement( parseObject(jp,new cfStructData(),bStrictMapping) );
}else if ( token == JsonToken.VALUE_NUMBER_INT ){
if ( jp.getNumberType() == NumberType.INT )
array.addElement( new cfNumberData(jp.getIntValue()) );
else if ( jp.getNumberType() == NumberType.LONG || jp.getNumberType() == NumberType.BIG_INTEGER )
array.addElement( new cfNumberData(jp.getLongValue()) );
}else if ( token == JsonToken.VALUE_NUMBER_FLOAT ){
if ( jp.getNumberType() == NumberType.FLOAT )
array.addElement( new cfNumberData(jp.getFloatValue()) );
else if ( jp.getNumberType() == NumberType.DOUBLE )
array.addElement( new cfNumberData(jp.getDoubleValue()) );
} else if ( token == JsonToken.VALUE_FALSE ){
array.addElement( cfBooleanData.FALSE );
} else if ( token == JsonToken.VALUE_TRUE ){
array.addElement( cfBooleanData.TRUE );
} else if ( token == JsonToken.VALUE_NULL ){
array.addElement( cfNullData.NULL );
}else
array.addElement( getString(jp.getText()) );
token = jp.nextToken();
}
return array;
}
开发者ID:OpenBD,项目名称:openbd-core,代码行数:38,代码来源:DeserializeJSONJackson.java
示例18: _parseBoolean
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
protected final Boolean _parseBoolean(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
{
JsonToken localJsonToken = paramJsonParser.getCurrentToken();
if (localJsonToken == JsonToken.VALUE_TRUE)
return Boolean.TRUE;
if (localJsonToken == JsonToken.VALUE_FALSE)
return Boolean.FALSE;
if (localJsonToken == JsonToken.VALUE_NUMBER_INT)
{
if (paramJsonParser.getNumberType() == JsonParser.NumberType.INT)
{
if (paramJsonParser.getIntValue() == 0)
return Boolean.FALSE;
return Boolean.TRUE;
}
return Boolean.valueOf(_parseBooleanFromNumber(paramJsonParser, paramDeserializationContext));
}
if (localJsonToken == JsonToken.VALUE_NULL)
return (Boolean)getNullValue();
if (localJsonToken == JsonToken.VALUE_STRING)
{
String str = paramJsonParser.getText().trim();
if ("true".equals(str))
return Boolean.TRUE;
if ("false".equals(str))
return Boolean.FALSE;
if (str.length() == 0)
return (Boolean)getEmptyValue();
throw paramDeserializationContext.weirdStringException(str, this._valueClass, "only \"true\" or \"false\" recognized");
}
throw paramDeserializationContext.mappingException(this._valueClass, localJsonToken);
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:33,代码来源:StdDeserializer.java
示例19: getBigIntegerValue
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
public final BigInteger getBigIntegerValue()
{
Number localNumber = getNumberValue();
if ((localNumber instanceof BigInteger))
return (BigInteger)localNumber;
if (getNumberType() == JsonParser.NumberType.BIG_DECIMAL)
return ((BigDecimal)localNumber).toBigInteger();
return BigInteger.valueOf(localNumber.longValue());
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:10,代码来源:TokenBuffer.java
示例20: getNumberType
import com.fasterxml.jackson.core.JsonParser.NumberType; //导入依赖的package包/类
public JsonParser.NumberType getNumberType()
{
JsonNode localJsonNode = currentNumericNode();
if (localJsonNode == null)
return null;
return localJsonNode.numberType();
}
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:8,代码来源:TreeTraversingParser.java
注:本文中的com.fasterxml.jackson.core.JsonParser.NumberType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论