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


Java NumberType类代码示例

本文整理汇总了Java中com.fasterxml.jackson.core.JsonParser.NumberType的典型用法代码示例。如果您正苦于以下问题:Java NumberType类的具体用法?Java NumberType怎么用?Java NumberType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NumberType类属于com.fasterxml.jackson.core.JsonParser包,在下文中一共展示了NumberType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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