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


Java JsonParser.getIntValue方法代码示例

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


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

示例1: _parseBooleanPrimitive

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

示例2: deserialize

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
public Character deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if (localJsonToken == JsonToken.VALUE_NUMBER_INT)
  {
    int i = paramJsonParser.getIntValue();
    if ((i >= 0) && (i <= 65535))
      return Character.valueOf((char)i);
  }
  else if (localJsonToken == JsonToken.VALUE_STRING)
  {
    String str = paramJsonParser.getText();
    if (str.length() == 1)
      return Character.valueOf(str.charAt(0));
  }
  throw paramDeserializationContext.mappingException(this._valueClass);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:19,代码来源:StdDeserializer.java

示例3: deserialize

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

示例4: _parseBoolean

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

示例5: deserialize

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
@Override
public DangerLevel deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    int dangerLevel = jp.getIntValue();
    return DangerLevel.valueOf("LEVEL" + dangerLevel);
}
 
开发者ID:JonathanGeoffroy,项目名称:LifeMonitor,代码行数:6,代码来源:DangerLevelDeserializer.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: parseUser

import org.codehaus.jackson.JsonParser; //导入方法依赖的package包/类
private static User parseUser(HipChat origin, ObjectMapper mapper, JsonParser jp) throws JsonParseException, JsonMappingException, IOException
{
    User result = null;

    String userId = null;
    String name = null;
    String email = null;
    String title = null;
    String password = null;
    String photoUrl = null;
    String status = null;
    String statusMessage = null;
    boolean isGroupAdmin = false;

    while (jp.nextToken() != JsonToken.END_OBJECT)
    {
        String tag = jp.getText();
        jp.nextToken();
        if ("user_id".equals(tag))
        {
            userId = UtilParser.parseString(jp);
        } else if ("name".equals(tag))
        {
            name = UtilParser.parseString(jp);
        } else if ("email".equals(tag))
        {
            email = UtilParser.parseString(jp);
        } else if ("title".equals(tag))
        {
            title = UtilParser.parseString(jp);
        } else if ("is_group_admin".equals(tag))
        {
            int admin = jp.getIntValue();
            isGroupAdmin = (admin == 1);
        } else if ("password".equals(tag))
        {
            password = UtilParser.parseString(jp);
        } else if ("photo_url".equals(tag))
        {
            photoUrl = UtilParser.parseString(jp);
        } else if ("status".equals(tag))
        {
            status = UtilParser.parseString(jp);
        } else if ("status_message".equals(tag))
        {
            statusMessage = UtilParser.parseString(jp);
        }
    }

    result = User.create(userId, name, email, title, photoUrl, password, status, statusMessage, isGroupAdmin);

    return result;
}
 
开发者ID:blazsolar,项目名称:gradle-hipchat-plugin,代码行数:54,代码来源:UserParser.java


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