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


Java JsonToken.VALUE_NUMBER_INT属性代码示例

本文整理汇总了Java中org.codehaus.jackson.JsonToken.VALUE_NUMBER_INT属性的典型用法代码示例。如果您正苦于以下问题:Java JsonToken.VALUE_NUMBER_INT属性的具体用法?Java JsonToken.VALUE_NUMBER_INT怎么用?Java JsonToken.VALUE_NUMBER_INT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.codehaus.jackson.JsonToken的用法示例。


在下文中一共展示了JsonToken.VALUE_NUMBER_INT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserialize

@Override
public Instant deserialize(final JsonParser parser, final DeserializationContext ctxt)
        throws IOException, JsonProcessingException
{
    final JsonToken jsonToken = parser.getCurrentToken();

    if (jsonToken == JsonToken.VALUE_NUMBER_INT)
    {
        return new Instant(parser.getLongValue());
    }
    else if (jsonToken == JsonToken.VALUE_STRING)
    {
        final String str = parser.getText().trim();
        if (str.length() == 0)
        {
            return null;
        }
        final DateTimeFormatter formatter = ISODateTimeFormat.dateTimeParser();
        final DateTime dateTime = formatter.parseDateTime(str);

        return new Instant(dateTime.getMillis());
    }

    throw ctxt.mappingException(Instant.class);
}
 
开发者ID:NovaOrdis,项目名称:playground,代码行数:25,代码来源:InstantDeserializer.java

示例2: _parseBooleanPrimitive

protected final boolean _parseBooleanPrimitive(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if (localJsonToken == JsonToken.VALUE_TRUE);
  while (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.getIntValue() == 0)
        return false;
    if (localJsonToken != JsonToken.VALUE_STRING)
      break;
    String str = paramJsonParser.getText().trim();
    if ("true".equals(str))
      continue;
    if (("false".equals(str)) || (str.length() == 0))
      return Boolean.FALSE.booleanValue();
    throw paramDeserializationContext.weirdStringException(this._valueClass, "only \"true\" or \"false\" recognized");
  }
  throw paramDeserializationContext.mappingException(this._valueClass);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:26,代码来源:StdDeserializer.java

示例3: _parseDate

protected java.util.Date _parseDate(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  try
  {
    if (localJsonToken == JsonToken.VALUE_NUMBER_INT)
      return new java.util.Date(paramJsonParser.getLongValue());
    if (localJsonToken == JsonToken.VALUE_STRING)
    {
      String str = paramJsonParser.getText().trim();
      if (str.length() == 0)
        return null;
      return paramDeserializationContext.parseDate(str);
    }
    throw paramDeserializationContext.mappingException(this._valueClass);
  }
  catch (IllegalArgumentException localIllegalArgumentException)
  {
  }
  throw paramDeserializationContext.weirdStringException(this._valueClass, "not a valid representation (error: " + localIllegalArgumentException.getMessage() + ")");
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:22,代码来源:StdDeserializer.java

示例4: deserialize

public BigDecimal deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if ((localJsonToken == JsonToken.VALUE_NUMBER_INT) || (localJsonToken == JsonToken.VALUE_NUMBER_FLOAT))
    return paramJsonParser.getDecimalValue();
  if (localJsonToken == JsonToken.VALUE_STRING)
  {
    String str = paramJsonParser.getText().trim();
    if (str.length() == 0)
      return null;
    try
    {
      BigDecimal localBigDecimal = new BigDecimal(str);
      return localBigDecimal;
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      throw paramDeserializationContext.weirdStringException(this._valueClass, "not a valid representation");
    }
  }
  throw paramDeserializationContext.mappingException(this._valueClass);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:23,代码来源:StdDeserializer.java

示例5: deserialize

public Enum<?> deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if (localJsonToken == JsonToken.VALUE_STRING)
  {
    String str = paramJsonParser.getText();
    Enum localEnum2 = this._resolver.findEnum(str);
    if (localEnum2 == null)
      throw paramDeserializationContext.weirdStringException(this._resolver.getEnumClass(), "value not one of declared Enum instance names");
    return localEnum2;
  }
  if (localJsonToken == JsonToken.VALUE_NUMBER_INT)
  {
    if (paramDeserializationContext.isEnabled(DeserializationConfig.Feature.FAIL_ON_NUMBERS_FOR_ENUMS))
      throw paramDeserializationContext.mappingException("Not allowed to deserialize Enum value out of JSON number (disable DeserializationConfig.Feature.FAIL_ON_NUMBERS_FOR_ENUMS to allow)");
    int i = paramJsonParser.getIntValue();
    Enum localEnum1 = this._resolver.getEnum(i);
    if (localEnum1 == null)
      throw paramDeserializationContext.weirdNumberException(this._resolver.getEnumClass(), "index value outside legal index range [0.." + this._resolver.lastValidIndex() + "]");
    return localEnum1;
  }
  throw paramDeserializationContext.mappingException(this._resolver.getEnumClass());
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:24,代码来源:EnumDeserializer.java

示例6: getNumberValue

public Number getNumberValue()
  throws IOException, JsonParseException
{
  if (this._numTypesValid == 0)
    _parseNumericValue(0);
  if (this._currToken == JsonToken.VALUE_NUMBER_INT)
  {
    if ((0x1 & this._numTypesValid) != 0)
      return Integer.valueOf(this._numberInt);
    if ((0x2 & this._numTypesValid) != 0)
      return Long.valueOf(this._numberLong);
    if ((0x4 & this._numTypesValid) != 0)
      return this._numberBigInt;
    return this._numberBigDecimal;
  }
  if ((0x10 & this._numTypesValid) != 0)
    return this._numberBigDecimal;
  if ((0x8 & this._numTypesValid) == 0)
    _throwInternal();
  return Double.valueOf(this._numberDouble);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:21,代码来源:JsonNumericParserBase.java

示例7: getNumberType

public JsonParser.NumberType getNumberType()
  throws IOException, JsonParseException
{
  if (this._numTypesValid == 0)
    _parseNumericValue(0);
  if (this._currToken == JsonToken.VALUE_NUMBER_INT)
  {
    if ((0x1 & this._numTypesValid) != 0)
      return JsonParser.NumberType.INT;
    if ((0x2 & this._numTypesValid) != 0)
      return JsonParser.NumberType.LONG;
    return JsonParser.NumberType.BIG_INTEGER;
  }
  if ((0x10 & this._numTypesValid) != 0)
    return JsonParser.NumberType.BIG_DECIMAL;
  return JsonParser.NumberType.DOUBLE;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:17,代码来源:JsonNumericParserBase.java

示例8: _parseShort

protected final Short _parseShort(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if (localJsonToken == JsonToken.VALUE_NULL)
    return null;
  if ((localJsonToken == JsonToken.VALUE_NUMBER_INT) || (localJsonToken == JsonToken.VALUE_NUMBER_FLOAT))
    return Short.valueOf(paramJsonParser.getShortValue());
  int i = _parseIntPrimitive(paramJsonParser, paramDeserializationContext);
  if ((i < -32768) || (i > 32767))
    throw paramDeserializationContext.weirdStringException(this._valueClass, "overflow, value can not be represented as 16-bit value");
  return Short.valueOf((short)i);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:13,代码来源:StdDeserializer.java

示例9: deserialize

@Override
public Duration deserialize(final JsonParser parser, final DeserializationContext ctxt)
        throws JsonParseException, IOException
{
    final JsonToken jsonToken = parser.getCurrentToken();

    if (jsonToken == JsonToken.VALUE_NUMBER_INT)
    {
        return new Duration(parser.getLongValue());
    }
    else if (jsonToken == JsonToken.VALUE_STRING)
    {
        final String str = parser.getText().trim();
        if (str.length() == 0)
        {
            return null;
        }
        final PeriodFormatter formatter = ISOPeriodFormat.standard();
        return formatter.parsePeriod(str).toStandardDuration();
    }

    throw ctxt.mappingException(Duration.class);
}
 
开发者ID:NovaOrdis,项目名称:playground,代码行数:23,代码来源:DurationDeserializer.java

示例10: _parseBoolean

protected final Boolean _parseBoolean(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if (localJsonToken == JsonToken.VALUE_TRUE)
    return Boolean.TRUE;
  if (localJsonToken == JsonToken.VALUE_FALSE)
    return Boolean.FALSE;
  if (localJsonToken == JsonToken.VALUE_NULL)
    return null;
  if (localJsonToken == JsonToken.VALUE_NUMBER_INT)
  {
    if (paramJsonParser.getIntValue() == 0)
      return Boolean.FALSE;
    return Boolean.TRUE;
  }
  if (localJsonToken == JsonToken.VALUE_STRING)
  {
    String str = paramJsonParser.getText().trim();
    if ("true".equals(str))
      return Boolean.TRUE;
    if (("false".equals(str)) || (str.length() == 0))
      return Boolean.FALSE;
    throw paramDeserializationContext.weirdStringException(this._valueClass, "only \"true\" or \"false\" recognized");
  }
  throw paramDeserializationContext.mappingException(this._valueClass);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:27,代码来源:StdDeserializer.java

示例11: _parseLong

protected final Long _parseLong(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken1 = paramJsonParser.getCurrentToken();
  Long localLong1;
  if ((localJsonToken1 == JsonToken.VALUE_NUMBER_INT) || (localJsonToken1 == JsonToken.VALUE_NUMBER_FLOAT))
    localLong1 = Long.valueOf(paramJsonParser.getLongValue());
  JsonToken localJsonToken2;
  do
  {
    while (true)
    {
      return localLong1;
      if (localJsonToken1 != JsonToken.VALUE_STRING)
        break;
      String str = paramJsonParser.getText().trim();
      int i = str.length();
      localLong1 = null;
      if (i == 0)
        continue;
      try
      {
        Long localLong2 = Long.valueOf(NumberInput.parseLong(str));
        return localLong2;
      }
      catch (IllegalArgumentException localIllegalArgumentException)
      {
        throw paramDeserializationContext.weirdStringException(this._valueClass, "not a valid Long value");
      }
    }
    localJsonToken2 = JsonToken.VALUE_NULL;
    localLong1 = null;
  }
  while (localJsonToken1 == localJsonToken2);
  throw paramDeserializationContext.mappingException(this._valueClass);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:36,代码来源:StdDeserializer.java

示例12: _parseLongPrimitive

protected final long _parseLongPrimitive(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  long l1 = 0L;
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if ((localJsonToken == JsonToken.VALUE_NUMBER_INT) || (localJsonToken == JsonToken.VALUE_NUMBER_FLOAT))
    l1 = paramJsonParser.getLongValue();
  do
    while (true)
    {
      return l1;
      if (localJsonToken != JsonToken.VALUE_STRING)
        break;
      String str = paramJsonParser.getText().trim();
      if (str.length() == 0)
        continue;
      try
      {
        long l2 = NumberInput.parseLong(str);
        return l2;
      }
      catch (IllegalArgumentException localIllegalArgumentException)
      {
        throw paramDeserializationContext.weirdStringException(this._valueClass, "not a valid long value");
      }
    }
  while (localJsonToken == JsonToken.VALUE_NULL);
  throw paramDeserializationContext.mappingException(this._valueClass);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:29,代码来源:StdDeserializer.java

示例13: handleNonArray

private final byte[] handleNonArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  if (!paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY))
    throw paramDeserializationContext.mappingException(this._valueClass);
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if ((localJsonToken == JsonToken.VALUE_NUMBER_INT) || (localJsonToken == JsonToken.VALUE_NUMBER_FLOAT));
  for (int i = paramJsonParser.getByteValue(); ; i = 0)
  {
    return new byte[] { i };
    if (localJsonToken == JsonToken.VALUE_NULL)
      continue;
    throw paramDeserializationContext.mappingException(this._valueClass.getComponentType());
  }
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:15,代码来源:ArrayDeserializers.java

示例14: getIntValue

public int getIntValue()
  throws IOException, JsonParseException
{
  if (this._currToken == JsonToken.VALUE_NUMBER_INT)
    return ((Number)_currentObject()).intValue();
  return getNumberValue().intValue();
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:7,代码来源:TokenBuffer.java

示例15: _parseDouble

protected final Double _parseDouble(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken1 = paramJsonParser.getCurrentToken();
  Double localDouble1;
  if ((localJsonToken1 == JsonToken.VALUE_NUMBER_INT) || (localJsonToken1 == JsonToken.VALUE_NUMBER_FLOAT))
    localDouble1 = Double.valueOf(paramJsonParser.getDoubleValue());
  JsonToken localJsonToken2;
  do
  {
    while (true)
    {
      return localDouble1;
      if (localJsonToken1 != JsonToken.VALUE_STRING)
        break;
      String str = paramJsonParser.getText().trim();
      int i = str.length();
      localDouble1 = null;
      if (i == 0)
        continue;
      switch (str.charAt(0))
      {
      default:
      case 'I':
      case 'N':
      case '-':
      }
      try
      {
        do
        {
          do
          {
            do
            {
              Double localDouble2 = Double.valueOf(parseDouble(str));
              return localDouble2;
            }
            while ((!"Infinity".equals(str)) && (!"INF".equals(str)));
            return Double.valueOf((1.0D / 0.0D));
          }
          while (!"NaN".equals(str));
          return Double.valueOf((0.0D / 0.0D));
        }
        while ((!"-Infinity".equals(str)) && (!"-INF".equals(str)));
        return Double.valueOf((-1.0D / 0.0D));
      }
      catch (IllegalArgumentException localIllegalArgumentException)
      {
        throw paramDeserializationContext.weirdStringException(this._valueClass, "not a valid Double value");
      }
    }
    localJsonToken2 = JsonToken.VALUE_NULL;
    localDouble1 = null;
  }
  while (localJsonToken1 == localJsonToken2);
  throw paramDeserializationContext.mappingException(this._valueClass);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:58,代码来源:StdDeserializer.java


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