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


Java JsonParser.getLongValue方法代码示例

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


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

示例1: deserialize

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
@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,代码行数:26,代码来源:InstantDeserializer.java

示例2: _parseDate

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
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,代码行数:23,代码来源:StdDeserializer.java

示例3: deserialize

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
@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,代码行数:24,代码来源:DurationDeserializer.java

示例4: _parseLongPrimitive

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
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,代码行数:30,代码来源:StdDeserializer.java

示例5: deserialize

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
public T deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if (localJsonToken == JsonToken.VALUE_NUMBER_INT)
    return new DateTime(paramJsonParser.getLongValue(), DateTimeZone.UTC);
  if (localJsonToken == JsonToken.VALUE_STRING)
  {
    String str = paramJsonParser.getText().trim();
    if (str.length() == 0)
      return null;
    return new DateTime(str, DateTimeZone.UTC);
  }
  throw paramDeserializationContext.mappingException(getValueClass());
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:16,代码来源:JodaDeserializers.java

示例6: parseBackendResponse

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
private static BackendResponse parseBackendResponse(JsonParser parser) throws IOException {
    try {
        // Sanity check: verify that we got "Json Object":
        if (parser.nextToken() != JsonToken.START_OBJECT) {
            throw new IOException("Expected data to start with an Object");
        }
        long responseKey = 0;
        int delay = 0;
        int numItems = 0;
        int itemSize = 0;
        String[] items = null;
        JsonToken current;

        while (parser.nextToken() != JsonToken.END_OBJECT) {
            String fieldName = parser.getCurrentName();
            // advance
            current = parser.nextToken();
            if (fieldName.equals("responseKey")) {
                responseKey = parser.getLongValue();
            } else if (fieldName.equals("delay")) {
                delay = parser.getIntValue();
            } else if (fieldName.equals("itemSize")) {
                itemSize = parser.getIntValue();
            } else if (fieldName.equals("numItems")) {
                numItems = parser.getIntValue();
            } else if (fieldName.equals("items")) {
                // expect numItems to be populated before hitting this
                if (numItems == 0) {
                    throw new IllegalStateException("Expected numItems > 0");
                }
                items = new String[numItems];
                if (current == JsonToken.START_ARRAY) {
                    int j = 0;
                    // For each of the records in the array
                    while (parser.nextToken() != JsonToken.END_ARRAY) {
                        items[j++] = parser.getText();
                    }
                } else {
                    //                            System.out.println("Error: items should be an array: skipping.");
                    parser.skipChildren();
                }

            }
        }
        return new BackendResponse(responseKey, delay, numItems, itemSize, items);
    } finally {
        parser.close();
    }
}
 
开发者ID:Netflix,项目名称:ReactiveLab,代码行数:50,代码来源:BackendResponse.java

示例7: deserialize

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
@Override
public OAuth2AccessToken deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException,
		JsonProcessingException {

	String tokenValue = null;
	String tokenType = null;
	String refreshToken = null;
	Long expiresIn = null;
	Set<String> scope = null;
	Map<String, Object> additionalInformation = new LinkedHashMap<String, Object>();

	// TODO What should occur if a parameter exists twice
	while (jp.nextToken() != JsonToken.END_OBJECT) {
		String name = jp.getCurrentName();
		jp.nextToken();
		if (OAuth2AccessToken.ACCESS_TOKEN.equals(name)) {
			tokenValue = jp.getText();
		}
		else if (OAuth2AccessToken.TOKEN_TYPE.equals(name)) {
			tokenType = jp.getText();
		}
		else if (OAuth2AccessToken.REFRESH_TOKEN.equals(name)) {
			refreshToken = jp.getText();
		}
		else if (OAuth2AccessToken.EXPIRES_IN.equals(name)) {
			try {
				expiresIn = jp.getLongValue();
			} catch (JsonParseException e) {
				expiresIn = Long.valueOf(jp.getText());
			}
		}
		else if (OAuth2AccessToken.SCOPE.equals(name)) {
			String text = jp.getText();
			scope = OAuth2Utils.parseParameterList(text);
		} else {
			additionalInformation.put(name, jp.readValueAs(Object.class));
		}
	}

	// TODO What should occur if a required parameter (tokenValue or tokenType) is missing?

	DefaultOAuth2AccessToken accessToken = new DefaultOAuth2AccessToken(tokenValue);
	accessToken.setTokenType(tokenType);
	if (expiresIn != null) {
		accessToken.setExpiration(new Date(System.currentTimeMillis() + (expiresIn * 1000)));
	}
	if (refreshToken != null) {
		accessToken.setRefreshToken(new DefaultOAuth2RefreshToken(refreshToken));
	}
	accessToken.setScope(scope);
	accessToken.setAdditionalInformation(additionalInformation);

	return accessToken;
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:55,代码来源:OAuth2AccessTokenJackson1Deserializer.java


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