Top Description Inners Constructors Methods
com.fasterxml.jackson.databind.deser.std

public abstract Class FromStringDeserializer<T>

extends StdScalarDeserializer<T>
Class Inheritance
Known Direct Subclasses
com.fasterxml.jackson.databind.deser.std.FromStringDeserializer.Std, com.fasterxml.jackson.databind.deser.std.FromStringDeserializer.StringBuilderDeserializer, com.fasterxml.jackson.databind.deser.std.FromStringDeserializer.StringBufferDeserializer, com.fasterxml.jackson.databind.deser.std.UUIDDeserializer, com.fasterxml.jackson.databind.ext.CoreXMLDeserializers.Std, com.fasterxml.jackson.databind.ext.DOMDeserializer
Annotations
@SuppressWarnings:serial
Imports
java.io.*, java.net.InetAddress, .InetSocketAddress, .MalformedURLException, .URI, .URL, java.nio.charset.Charset, java.util.Currency, .IllformedLocaleException, .Locale, .TimeZone, java.util.regex.Pattern, com.fasterxml.jackson.core.*, com.fasterxml.jackson.core.util.VersionUtil, com.fasterxml.jackson.databind.*, com.fasterxml.jackson.databind.cfg.CoercionAction, .CoercionInputShape, com.fasterxml.jackson.databind.exc.InvalidFormatException, com.fasterxml.jackson.databind.type.LogicalType, com.fasterxml.jackson.databind.util.ClassUtil

Base class for simple deserializers that serialize values from String representation: this includes JSON Strings and other Scalar values that can be coerced into text, like Numbers and Booleans). Simple JSON String values are trimmed using java.lang.String#trim. Partial deserializer implementation will try to first access current token as a String, calls _deserialize(String,DeserializationContext) and returns return value. If this does not work (current token not a simple scalar type), attempts are made so that:

Special handling includes:

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
FromStringDeserializer.Std

"Chameleon" deserializer that works on simple types that are deserialized from a simple String.

pack-priv static class
pack-priv static class

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected abstract T
_deserialize(String value, DeserializationContext ctxt)

Main method from trying to deserialize actual value from non-empty String.

protected T
_deserializeEmbedded(Object ob, DeserializationContext ctxt)

Overridable method to allow coercion from embedded value that is neither null nor directly assignable to target type.

protected final T
protected Object
protected Object
protected Object
protected boolean
public T
deserialize(JsonParser
Parsed used for reading JSON content
p
,
DeserializationContext
Context that can be used to access information about this deserialization activity.
ctxt
)

Implements abstract com.fasterxml.jackson.databind.JsonDeserializer.deserialize.

Method that can be called to ask implementation to deserialize JSON content into the value type this serializer handles.
public static FromStringDeserializer<?>
findDeserializer(Class<?> rawType)

Factory method for trying to find a deserializer for one of supported types that have simple from-String serialization.

public LogicalType
logicalType()

Overrides com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer.logicalType.

Method for accessing logical type of values this deserializer produces.
public static Class<?>[]
Inherited from com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer:
deserializedeserializeWithTypegetEmptyAccessPatterngetNullAccessPatternsupportsUpdate

Constructor Detail

FromStringDeserializerback to summary
protected FromStringDeserializer(Class<?> vc)

Method Detail

_deserializeback to summary
protected abstract T _deserialize(String value, DeserializationContext ctxt) throws IOException

Main method from trying to deserialize actual value from non-empty String.

_deserializeEmbeddedback to summary
protected T _deserializeEmbedded(Object ob, DeserializationContext ctxt) throws IOException

Overridable method to allow coercion from embedded value that is neither null nor directly assignable to target type. Used, for example, by UUIDDeserializer to coerce from byte[].

_deserializeFromEmptyStringback to summary
protected final T _deserializeFromEmptyString() throws IOException

Deprecated

Annotations
@Deprecated
_deserializeFromEmptyStringback to summary
protected Object _deserializeFromEmptyString(DeserializationContext ctxt) throws IOException
Since
2.12
_deserializeFromEmptyStringDefaultback to summary
protected Object _deserializeFromEmptyStringDefault(DeserializationContext ctxt) throws IOException
Since
2.12
_deserializeFromOtherback to summary
protected Object _deserializeFromOther(JsonParser p, DeserializationContext ctxt, JsonToken t) throws IOException
_shouldTrimback to summary
protected boolean _shouldTrim()
deserializeback to summary
public T deserialize(JsonParser p, DeserializationContext ctxt) throws IOException

Implements abstract com.fasterxml.jackson.databind.JsonDeserializer.deserialize.

Doc from com.fasterxml.jackson.databind.JsonDeserializer.deserialize.

Method that can be called to ask implementation to deserialize JSON content into the value type this serializer handles. Returned instance is to be constructed by method itself.

Pre-condition for this method is that the parser points to the first event that is part of value to deserializer (and which is never JSON 'null' literal, more on this below): for simple types it may be the only value; and for structured types the Object start marker or a FIELD_NAME.

The two possible input conditions for structured types result from polymorphism via fields. In the ordinary case, Jackson calls this method when it has encountered an OBJECT_START, and the method implementation must advance to the next token to see the first field name. If the application configures polymorphism via a field, then the object looks like the following.

      {
          "@class": "class name",
          ...
      }
  
Jackson consumes the two tokens (the @class field name and its value) in order to learn the class and select the deserializer. Thus, the stream is pointing to the FIELD_NAME for the first field after the @class. Thus, if you want your method to work correctly both with and without polymorphism, you must begin your method with:
       if (p.currentToken() == JsonToken.START_OBJECT) {
         p.nextToken();
       }
  
This results in the stream pointing to the field name, so that the two conditions align.

Post-condition is that the parser will point to the last event that is part of deserialized value (or in case deserialization fails, event that was not recognized or usable, which may be the same event as the one it pointed to upon call).

Note that this method is never called for JSON null literal, and thus deserializers need (and should) not check for it.

Parameters
p:JsonParser

Parsed used for reading JSON content

ctxt:DeserializationContext

Context that can be used to access information about this deserialization activity.

Returns:T

Deserialized value

Annotations
@SuppressWarnings:unchecked
@Override
findDeserializerback to summary
public static FromStringDeserializer<?> findDeserializer(Class<?> rawType)

Factory method for trying to find a deserializer for one of supported types that have simple from-String serialization.

logicalTypeback to summary
public LogicalType logicalType()

Overrides com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer.logicalType.

Doc from com.fasterxml.jackson.databind.JsonDeserializer.logicalType.

Method for accessing logical type of values this deserializer produces. Typically used for further configuring handling of values, for example, to find which coercions are legal.

Returns:LogicalType

Logical type of values this deserializer produces, if known; null if not

Annotations
@Override
typesback to summary
public static Class<?>[] types()
com.fasterxml.jackson.databind.deser.std back to summary

public Class FromStringDeserializer.Std

extends FromStringDeserializer<Object>
Class Inheritance

"Chameleon" deserializer that works on simple types that are deserialized from a simple String.
Since
2.4

Field Summary

Modifier and TypeField and Description
protected final int
protected static final String
private static final long
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
protected
Std(Class<?> valueType, int kind)

Method Summary

Modifier and TypeMethod and Description
protected Object
_deserialize(String value, DeserializationContext ctxt)

Implements abstract com.fasterxml.jackson.databind.deser.std.FromStringDeserializer._deserialize.

Main method from trying to deserialize actual value from non-empty String.
private Locale
_deSerializeBCP47Locale(String value, int ix, String first, String second, int extMarkerIx)

protected Object
private Locale
protected int
protected boolean
public Object
getEmptyValue(DeserializationContext ctxt)

Overrides com.fasterxml.jackson.databind.JsonDeserializer.getEmptyValue.

Method called to determine value to be used for "empty" values (most commonly when deserializing from empty JSON Strings).
Inherited from com.fasterxml.jackson.databind.deser.std.FromStringDeserializer:
_deserializeEmbedded_deserializeFromEmptyString_deserializeFromEmptyString_deserializeFromOtherdeserializefindDeserializerlogicalTypetypes

Field Detail

_kindback to summary
protected final int _kind
LOCALE_EXT_MARKERback to summary
protected static final String LOCALE_EXT_MARKER
serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer.serialVersionUID.

STD_CHARSETback to summary
public static final int STD_CHARSET
STD_CLASSback to summary
public static final int STD_CLASS
STD_CURRENCYback to summary
public static final int STD_CURRENCY
STD_FILEback to summary
public static final int STD_FILE
STD_INET_ADDRESSback to summary
public static final int STD_INET_ADDRESS
STD_INET_SOCKET_ADDRESSback to summary
public static final int STD_INET_SOCKET_ADDRESS
STD_JAVA_TYPEback to summary
public static final int STD_JAVA_TYPE
STD_LOCALEback to summary
public static final int STD_LOCALE
STD_PATTERNback to summary
public static final int STD_PATTERN
STD_TIME_ZONEback to summary
public static final int STD_TIME_ZONE
STD_URIback to summary
public static final int STD_URI
STD_URLback to summary
public static final int STD_URL

Constructor Detail

Stdback to summary
protected Std(Class<?> valueType, int kind)

Method Detail

_deserializeback to summary
protected Object _deserialize(String value, DeserializationContext ctxt) throws IOException

Implements abstract com.fasterxml.jackson.databind.deser.std.FromStringDeserializer._deserialize.

Doc from com.fasterxml.jackson.databind.deser.std.FromStringDeserializer._deserialize.

Main method from trying to deserialize actual value from non-empty String.

Annotations
@Override
_deSerializeBCP47Localeback to summary
private Locale _deSerializeBCP47Locale(String value, int ix, String first, String second, int extMarkerIx)
_deserializeFromEmptyStringDefaultback to summary
protected Object _deserializeFromEmptyStringDefault(DeserializationContext ctxt) throws IOException

Overrides com.fasterxml.jackson.databind.deser.std.FromStringDeserializer._deserializeFromEmptyStringDefault.

Annotations
@Override
_deserializeLocaleback to summary
private Locale _deserializeLocale(String value, DeserializationContext ctxt) throws IOException
_firstHyphenOrUnderscoreback to summary
protected int _firstHyphenOrUnderscore(String str)
_shouldTrimback to summary
protected boolean _shouldTrim()

Overrides com.fasterxml.jackson.databind.deser.std.FromStringDeserializer._shouldTrim.

Annotations
@Override
getEmptyValueback to summary
public Object getEmptyValue(DeserializationContext ctxt) throws JsonMappingException

Overrides com.fasterxml.jackson.databind.JsonDeserializer.getEmptyValue.

Doc from com.fasterxml.jackson.databind.JsonDeserializer.getEmptyValue.

Method called to determine value to be used for "empty" values (most commonly when deserializing from empty JSON Strings). Usually this is same as getNullValue (which in turn is usually simply Java null), but it can be overridden for specific types. Or, if type should never be converted from empty String, method can also throw an exception.

This method may be called once, or multiple times, depending on what getEmptyAccessPattern() returns.

Default implementation simply calls getNullValue and returns value.

Annotations
@Override
com.fasterxml.jackson.databind.deser.std back to summary

pack-priv Class FromStringDeserializer.StringBufferDeserializer

extends FromStringDeserializer<Object>
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected Object
_deserialize(String value, DeserializationContext ctxt)

Implements abstract com.fasterxml.jackson.databind.deser.std.FromStringDeserializer._deserialize.

Main method from trying to deserialize actual value from non-empty String.
public Object
deserialize(JsonParser
Parsed used for reading JSON content
p
,
DeserializationContext
Context that can be used to access information about this deserialization activity.
ctxt
)

Overrides com.fasterxml.jackson.databind.deser.std.FromStringDeserializer.deserialize.

Method that can be called to ask implementation to deserialize JSON content into the value type this serializer handles.
public Object
getEmptyValue(DeserializationContext ctxt)

Overrides com.fasterxml.jackson.databind.JsonDeserializer.getEmptyValue.

Method called to determine value to be used for "empty" values (most commonly when deserializing from empty JSON Strings).
public LogicalType
logicalType()

Overrides com.fasterxml.jackson.databind.deser.std.FromStringDeserializer.logicalType.

Method for accessing logical type of values this deserializer produces.
Inherited from com.fasterxml.jackson.databind.deser.std.FromStringDeserializer:
_deserializeEmbedded_deserializeFromEmptyString_deserializeFromEmptyString_deserializeFromEmptyStringDefault_deserializeFromOther_shouldTrimfindDeserializertypes

Constructor Detail

StringBufferDeserializerback to summary
public StringBufferDeserializer()

Method Detail

_deserializeback to summary
protected Object _deserialize(String value, DeserializationContext ctxt) throws IOException

Implements abstract com.fasterxml.jackson.databind.deser.std.FromStringDeserializer._deserialize.

Doc from com.fasterxml.jackson.databind.deser.std.FromStringDeserializer._deserialize.

Main method from trying to deserialize actual value from non-empty String.

Annotations
@Override
deserializeback to summary
public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException

Overrides com.fasterxml.jackson.databind.deser.std.FromStringDeserializer.deserialize.

Doc from com.fasterxml.jackson.databind.JsonDeserializer.deserialize.

Method that can be called to ask implementation to deserialize JSON content into the value type this serializer handles. Returned instance is to be constructed by method itself.

Pre-condition for this method is that the parser points to the first event that is part of value to deserializer (and which is never JSON 'null' literal, more on this below): for simple types it may be the only value; and for structured types the Object start marker or a FIELD_NAME.

The two possible input conditions for structured types result from polymorphism via fields. In the ordinary case, Jackson calls this method when it has encountered an OBJECT_START, and the method implementation must advance to the next token to see the first field name. If the application configures polymorphism via a field, then the object looks like the following.

      {
          "@class": "class name",
          ...
      }
  
Jackson consumes the two tokens (the @class field name and its value) in order to learn the class and select the deserializer. Thus, the stream is pointing to the FIELD_NAME for the first field after the @class. Thus, if you want your method to work correctly both with and without polymorphism, you must begin your method with:
       if (p.currentToken() == JsonToken.START_OBJECT) {
         p.nextToken();
       }
  
This results in the stream pointing to the field name, so that the two conditions align.

Post-condition is that the parser will point to the last event that is part of deserialized value (or in case deserialization fails, event that was not recognized or usable, which may be the same event as the one it pointed to upon call).

Note that this method is never called for JSON null literal, and thus deserializers need (and should) not check for it.

Parameters
p:JsonParser

Parsed used for reading JSON content

ctxt:DeserializationContext

Context that can be used to access information about this deserialization activity.

Returns:Object

Deserialized value

Annotations
@Override
getEmptyValueback to summary
public Object getEmptyValue(DeserializationContext ctxt)

Overrides com.fasterxml.jackson.databind.JsonDeserializer.getEmptyValue.

Doc from com.fasterxml.jackson.databind.JsonDeserializer.getEmptyValue.

Method called to determine value to be used for "empty" values (most commonly when deserializing from empty JSON Strings). Usually this is same as getNullValue (which in turn is usually simply Java null), but it can be overridden for specific types. Or, if type should never be converted from empty String, method can also throw an exception.

This method may be called once, or multiple times, depending on what getEmptyAccessPattern() returns.

Default implementation simply calls getNullValue and returns value.

Annotations
@Override
logicalTypeback to summary
public LogicalType logicalType()

Overrides com.fasterxml.jackson.databind.deser.std.FromStringDeserializer.logicalType.

Doc from com.fasterxml.jackson.databind.JsonDeserializer.logicalType.

Method for accessing logical type of values this deserializer produces. Typically used for further configuring handling of values, for example, to find which coercions are legal.

Returns:LogicalType

Logical type of values this deserializer produces, if known; null if not

Annotations
@Override
com.fasterxml.jackson.databind.deser.std back to summary

pack-priv Class FromStringDeserializer.StringBuilderDeserializer

extends FromStringDeserializer<Object>
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected Object
_deserialize(String value, DeserializationContext ctxt)

Implements abstract com.fasterxml.jackson.databind.deser.std.FromStringDeserializer._deserialize.

Main method from trying to deserialize actual value from non-empty String.
public Object
deserialize(JsonParser
Parsed used for reading JSON content
p
,
DeserializationContext
Context that can be used to access information about this deserialization activity.
ctxt
)

Overrides com.fasterxml.jackson.databind.deser.std.FromStringDeserializer.deserialize.

Method that can be called to ask implementation to deserialize JSON content into the value type this serializer handles.
public Object
getEmptyValue(DeserializationContext ctxt)

Overrides com.fasterxml.jackson.databind.JsonDeserializer.getEmptyValue.

Method called to determine value to be used for "empty" values (most commonly when deserializing from empty JSON Strings).
public LogicalType
logicalType()

Overrides com.fasterxml.jackson.databind.deser.std.FromStringDeserializer.logicalType.

Method for accessing logical type of values this deserializer produces.
Inherited from com.fasterxml.jackson.databind.deser.std.FromStringDeserializer:
_deserializeEmbedded_deserializeFromEmptyString_deserializeFromEmptyString_deserializeFromEmptyStringDefault_deserializeFromOther_shouldTrimfindDeserializertypes

Constructor Detail

StringBuilderDeserializerback to summary
public StringBuilderDeserializer()

Method Detail

_deserializeback to summary
protected Object _deserialize(String value, DeserializationContext ctxt) throws IOException

Implements abstract com.fasterxml.jackson.databind.deser.std.FromStringDeserializer._deserialize.

Doc from com.fasterxml.jackson.databind.deser.std.FromStringDeserializer._deserialize.

Main method from trying to deserialize actual value from non-empty String.

Annotations
@Override
deserializeback to summary
public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException

Overrides com.fasterxml.jackson.databind.deser.std.FromStringDeserializer.deserialize.

Doc from com.fasterxml.jackson.databind.JsonDeserializer.deserialize.

Method that can be called to ask implementation to deserialize JSON content into the value type this serializer handles. Returned instance is to be constructed by method itself.

Pre-condition for this method is that the parser points to the first event that is part of value to deserializer (and which is never JSON 'null' literal, more on this below): for simple types it may be the only value; and for structured types the Object start marker or a FIELD_NAME.

The two possible input conditions for structured types result from polymorphism via fields. In the ordinary case, Jackson calls this method when it has encountered an OBJECT_START, and the method implementation must advance to the next token to see the first field name. If the application configures polymorphism via a field, then the object looks like the following.

      {
          "@class": "class name",
          ...
      }
  
Jackson consumes the two tokens (the @class field name and its value) in order to learn the class and select the deserializer. Thus, the stream is pointing to the FIELD_NAME for the first field after the @class. Thus, if you want your method to work correctly both with and without polymorphism, you must begin your method with:
       if (p.currentToken() == JsonToken.START_OBJECT) {
         p.nextToken();
       }
  
This results in the stream pointing to the field name, so that the two conditions align.

Post-condition is that the parser will point to the last event that is part of deserialized value (or in case deserialization fails, event that was not recognized or usable, which may be the same event as the one it pointed to upon call).

Note that this method is never called for JSON null literal, and thus deserializers need (and should) not check for it.

Parameters
p:JsonParser

Parsed used for reading JSON content

ctxt:DeserializationContext

Context that can be used to access information about this deserialization activity.

Returns:Object

Deserialized value

Annotations
@Override
getEmptyValueback to summary
public Object getEmptyValue(DeserializationContext ctxt) throws JsonMappingException

Overrides com.fasterxml.jackson.databind.JsonDeserializer.getEmptyValue.

Doc from com.fasterxml.jackson.databind.JsonDeserializer.getEmptyValue.

Method called to determine value to be used for "empty" values (most commonly when deserializing from empty JSON Strings). Usually this is same as getNullValue (which in turn is usually simply Java null), but it can be overridden for specific types. Or, if type should never be converted from empty String, method can also throw an exception.

This method may be called once, or multiple times, depending on what getEmptyAccessPattern() returns.

Default implementation simply calls getNullValue and returns value.

Annotations
@Override
logicalTypeback to summary
public LogicalType logicalType()

Overrides com.fasterxml.jackson.databind.deser.std.FromStringDeserializer.logicalType.

Doc from com.fasterxml.jackson.databind.JsonDeserializer.logicalType.

Method for accessing logical type of values this deserializer produces. Typically used for further configuring handling of values, for example, to find which coercions are legal.

Returns:LogicalType

Logical type of values this deserializer produces, if known; null if not

Annotations
@Override