本文整理匯總了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;
}
示例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");
}
}
示例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);
}
示例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;
}
示例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");
}
}
示例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());
}
}
示例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);
}
示例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() + ")");
}
示例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();
}
示例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());
}
示例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);
}
示例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());
}
示例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();
}
示例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");
}
}
示例15: skipBytes
@Override
public void skipBytes() throws IOException {
advance(Symbol.BYTES);
if (in.getCurrentToken() == JsonToken.VALUE_STRING) {
in.nextToken();
} else {
throw error("bytes");
}
}