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


Java JsonToken.VALUE_STRING属性代码示例

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


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

示例1: readString

@Override
public String readString() throws IOException {
	advance(Symbol.STRING);
	if (parser.topSymbol() == Symbol.MAP_KEY_MARKER) {
		parser.advance(Symbol.MAP_KEY_MARKER);
		if (in.getCurrentToken() != JsonToken.FIELD_NAME) {
			throw error("map-key");
		}
	} else {
		if (in.getCurrentToken() != JsonToken.VALUE_STRING) {
			throw error("string");
		}
	}
	String result = in.getText();
	in.nextToken();
	return result;
}
 
开发者ID:Celos,项目名称:avro-json-decoder,代码行数:17,代码来源:ExtendedJsonDecoder.java

示例2: readEnum

@Override
public int readEnum() throws IOException {
	advance(Symbol.ENUM);
	Symbol.EnumLabelsAction top = (Symbol.EnumLabelsAction) parser.popSymbol();
	if (in.getCurrentToken() == JsonToken.VALUE_STRING) {
		in.getText();
		int n = top.findLabel(in.getText());
		if (n >= 0) {
			in.nextToken();
			return n;
		}
		throw new AvroTypeException("Unknown symbol in enum " + in.getText());
	} else {
		throw error("fixed");
	}
}
 
开发者ID:Celos,项目名称:avro-json-decoder,代码行数:16,代码来源:ExtendedJsonDecoder.java

示例3: 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

示例4: readString

@Override
public String readString() throws IOException {
  advance(Symbol.STRING);
  if (parser.topSymbol() == Symbol.MAP_KEY_MARKER) {
    parser.advance(Symbol.MAP_KEY_MARKER);
    if (in.getCurrentToken() != JsonToken.FIELD_NAME) {
      throw error("map-key");
    }
  } else {
    if (in.getCurrentToken() != JsonToken.VALUE_STRING) {
      throw error("string");
    }
  }
  String result = in.getText();
  in.nextToken();
  return result;
}
 
开发者ID:openaire,项目名称:iis,代码行数:17,代码来源:HackedJsonDecoder.java

示例5: readEnum

@Override
public int readEnum() throws IOException {
  advance(Symbol.ENUM);
  Symbol.EnumLabelsAction top = (Symbol.EnumLabelsAction) parser.popSymbol();
  if (in.getCurrentToken() == JsonToken.VALUE_STRING) {
    in.getText();
    int n = top.findLabel(in.getText());
    if (n >= 0) {
      in.nextToken();
      return n;
    }
    throw new AvroTypeException("Unknown symbol in enum " + in.getText());
  } else {
    throw error("fixed");
  }
}
 
开发者ID:openaire,项目名称:iis,代码行数:16,代码来源:HackedJsonDecoder.java

示例6: deserialize

@Override
public NodeRef deserialize(JsonParser jp, DeserializationContext ctxt)
		throws IOException, JsonProcessingException
{
       JsonToken curr = jp.getCurrentToken();

       if (curr == JsonToken.VALUE_STRING)
       {
           String nodeRefString = jp.getText();
           NodeRef nodeRef = getNodeRef(nodeRefString);
           return nodeRef;
       }
       else
       {
       	throw new IOException("Unable to deserialize nodeRef: " + curr.asString());
       }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:17,代码来源:NodeRefDeserializer.java

示例7: _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

示例8: _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

示例9: getBinaryValue

public byte[] getBinaryValue(Base64Variant paramBase64Variant)
  throws IOException, JsonParseException
{
  if (this._currToken == JsonToken.VALUE_EMBEDDED_OBJECT)
  {
    Object localObject = _currentObject();
    if ((localObject instanceof byte[]))
      return (byte[])(byte[])localObject;
  }
  if (this._currToken != JsonToken.VALUE_STRING)
    throw _constructError("Current token (" + this._currToken + ") not VALUE_STRING (or VALUE_EMBEDDED_OBJECT with byte[]), can not access as binary");
  String str = getText();
  if (str == null)
    return null;
  ByteArrayBuilder localByteArrayBuilder = this._byteBuilder;
  if (localByteArrayBuilder == null)
  {
    localByteArrayBuilder = new ByteArrayBuilder(100);
    this._byteBuilder = localByteArrayBuilder;
  }
  _decodeBase64(str, localByteArrayBuilder, paramBase64Variant);
  return localByteArrayBuilder.toByteArray();
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:23,代码来源:TokenBuffer.java

示例10: getBinaryValue

public byte[] getBinaryValue(Base64Variant paramBase64Variant)
  throws IOException, JsonParseException
{
  if ((this._currToken != JsonToken.VALUE_STRING) && ((this._currToken != JsonToken.VALUE_EMBEDDED_OBJECT) || (this._binaryValue == null)))
    _reportError("Current token (" + this._currToken + ") not VALUE_STRING or VALUE_EMBEDDED_OBJECT, can not access as binary");
  if (this._tokenIncomplete);
  try
  {
    this._binaryValue = _decodeBase64(paramBase64Variant);
    this._tokenIncomplete = false;
    return this._binaryValue;
  }
  catch (IllegalArgumentException localIllegalArgumentException)
  {
  }
  throw _constructError("Failed to decode VALUE_STRING as base64 (" + paramBase64Variant + "): " + localIllegalArgumentException.getMessage());
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:17,代码来源:ReaderBasedParser.java

示例11: 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

示例12: 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

示例13: skipString

@Override
public void skipString() throws IOException {
	advance(Symbol.STRING);
	if (parser.topSymbol() == Symbol.MAP_KEY_MARKER) {
		parser.advance(Symbol.MAP_KEY_MARKER);
		if (in.getCurrentToken() != JsonToken.FIELD_NAME) {
			throw error("map-key");
		}
	} else {
		if (in.getCurrentToken() != JsonToken.VALUE_STRING) {
			throw error("string");
		}
	}
	in.nextToken();
}
 
开发者ID:Celos,项目名称:avro-json-decoder,代码行数:15,代码来源:ExtendedJsonDecoder.java

示例14: readBytes

@Override
public ByteBuffer readBytes(ByteBuffer old) throws IOException {
	advance(Symbol.BYTES);
	if (in.getCurrentToken() == JsonToken.VALUE_STRING) {
		byte[] result = readByteArray();
		in.nextToken();
		return ByteBuffer.wrap(result);
	} else {
		throw error("bytes");
	}
}
 
开发者ID:Celos,项目名称:avro-json-decoder,代码行数:11,代码来源:ExtendedJsonDecoder.java

示例15: skipBytes

@Override
public void skipBytes() throws IOException {
	advance(Symbol.BYTES);
	if (in.getCurrentToken() == JsonToken.VALUE_STRING) {
		in.nextToken();
	} else {
		throw error("bytes");
	}
}
 
开发者ID:Celos,项目名称:avro-json-decoder,代码行数:9,代码来源:ExtendedJsonDecoder.java


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