當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。