Module tools.jackson.databind
Package tools.jackson.databind.deser.jdk
Class JDKFromStringDeserializer
java.lang.Object
tools.jackson.databind.ValueDeserializer<T>
tools.jackson.databind.deser.std.StdDeserializer<T>
tools.jackson.databind.deser.std.StdScalarDeserializer<T>
tools.jackson.databind.deser.std.FromStringDeserializer<Object>
tools.jackson.databind.deser.jdk.JDKFromStringDeserializer
- All Implemented Interfaces:
NullValueProvider
,ValueInstantiator.Gettable
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
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:
- Embedded values (
JsonToken.VALUE_EMBEDDED_OBJECT
) are returned as-is if they are of compatible type - Arrays may be "unwrapped" if (and only if)
DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS
is enabled, and array contains just a single scalar value that can be deserialized (for example, JSON Array with single JSON String element).
Special handling includes:
- Null values (
JsonToken.VALUE_NULL
) are handled by returning value returned byValueDeserializer.getNullValue(DeserializationContext)
: default implementation simply returns Java `null` but this may be overridden. - Empty String (after trimming) will result in
FromStringDeserializer._deserializeFromEmptyString(tools.jackson.databind.DeserializationContext)
getting called, and return value being returned as deserialization: default implementation simply returns `null`.
-
Nested Class Summary
Nested classes/interfaces inherited from class tools.jackson.databind.ValueDeserializer
ValueDeserializer.None
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
Fields inherited from class tools.jackson.databind.deser.std.StdDeserializer
_valueClass, _valueType, F_MASK_INT_COERCIONS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription_deserialize
(String value, DeserializationContext ctxt) Main method from trying to deserialize actual value from non-empty String.protected Object
protected int
protected boolean
static JDKFromStringDeserializer
findDeserializer
(Class<?> rawType) Factory method for trying to find a deserializer for one of supported types that have simple from-String serialization.Method called to determine value to be used for "empty" values (most commonly when deserializing from empty JSON Strings).static Class<?>[]
types()
Methods inherited from class tools.jackson.databind.deser.std.FromStringDeserializer
_deserializeEmbedded, _deserializeFromEmptyString, _deserializeFromOther, deserialize, logicalType
Methods inherited from class tools.jackson.databind.deser.std.StdScalarDeserializer
deserialize, deserializeWithType, getEmptyAccessPattern, getNullAccessPattern, supportsUpdate
Methods inherited from class tools.jackson.databind.deser.std.StdDeserializer
_byteOverflow, _checkBooleanToStringCoercion, _checkCoercionFail, _checkDoubleSpecialValue, _checkFloatSpecialValue, _checkFloatToIntCoercion, _checkFloatToStringCoercion, _checkFromStringCoercion, _checkFromStringCoercion, _checkIntToFloatCoercion, _checkIntToStringCoercion, _checkTextualNull, _checkToStringCoercion, _coerceBooleanFromInt, _coercedTypeDesc, _coercedTypeDesc, _coerceIntegral, _deserializeFromArray, _deserializeFromEmptyString, _deserializeFromString, _deserializeWrappedValue, _findCoercionFromBlankString, _findCoercionFromEmptyArray, _findCoercionFromEmptyString, _findNullProvider, _hasTextualNull, _intOverflow, _isBlank, _isFalse, _isIntNumber, _isNaN, _isNegInf, _isPosInf, _isTrue, _neitherNull, _nonNullNumber, _parseBoolean, _parseBooleanPrimitive, _parseBytePrimitive, _parseDate, _parseDate, _parseDateFromArray, _parseDouble, _parseDoublePrimitive, _parseDoublePrimitive, _parseFloatPrimitive, _parseFloatPrimitive, _parseInteger, _parseInteger, _parseIntPrimitive, _parseIntPrimitive, _parseLong, _parseLong, _parseLongPrimitive, _parseLongPrimitive, _parseShortPrimitive, _parseString, _reportFailedNullCoerce, _shortOverflow, _verifyEndArrayForSingle, _verifyNullForPrimitive, _verifyNullForPrimitiveCoercion, _wrapIOFailure, findContentNullProvider, findContentNullStyle, findConvertingContentDeserializer, findDeserializer, findFormatFeature, findFormatOverrides, findValueNullProvider, getValueInstantiator, getValueType, getValueType, handledType, handleMissingEndArrayForSingle, handleNestedArrayForSingle, handleUnknownProperty, isDefaultDeserializer, isDefaultKeyDeserializer
Methods inherited from class tools.jackson.databind.ValueDeserializer
createContextual, deserializeWithType, findBackReference, getAbsentValue, getDelegatee, getKnownPropertyNames, getNullValue, getObjectIdReader, isCachable, replaceDelegatee, resolve, unwrappingDeserializer
-
Field Details
-
STD_FILE
public static final int STD_FILE- See Also:
-
STD_URL
public static final int STD_URL- See Also:
-
STD_URI
public static final int STD_URI- See Also:
-
STD_PATH
public static final int STD_PATH- See Also:
-
STD_CLASS
public static final int STD_CLASS- See Also:
-
STD_JAVA_TYPE
public static final int STD_JAVA_TYPE- See Also:
-
STD_CURRENCY
public static final int STD_CURRENCY- See Also:
-
STD_PATTERN
public static final int STD_PATTERN- See Also:
-
STD_LOCALE
public static final int STD_LOCALE- See Also:
-
STD_CHARSET
public static final int STD_CHARSET- See Also:
-
STD_TIME_ZONE
public static final int STD_TIME_ZONE- See Also:
-
STD_INET_ADDRESS
public static final int STD_INET_ADDRESS- See Also:
-
STD_INET_SOCKET_ADDRESS
public static final int STD_INET_SOCKET_ADDRESS- See Also:
-
_kind
protected final int _kind
-
-
Constructor Details
-
JDKFromStringDeserializer
-
-
Method Details
-
types
-
findDeserializer
Factory method for trying to find a deserializer for one of supported types that have simple from-String serialization. -
_deserialize
public Object _deserialize(String value, DeserializationContext ctxt) throws tools.jackson.core.JacksonException, MalformedURLException, UnknownHostException Description copied from class:FromStringDeserializer
Main method from trying to deserialize actual value from non-empty String.- Specified by:
_deserialize
in classFromStringDeserializer<Object>
- Throws:
tools.jackson.core.JacksonException
MalformedURLException
UnknownHostException
-
_shouldTrim
protected boolean _shouldTrim()- Overrides:
_shouldTrim
in classFromStringDeserializer<Object>
-
getEmptyValue
Description copied from class:ValueDeserializer
Method called to determine value to be used for "empty" values (most commonly when deserializing from empty JSON Strings). Usually this is same asValueDeserializer.getNullValue(tools.jackson.databind.DeserializationContext)
(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
ValueDeserializer.getEmptyAccessPattern()
returns.Default implementation simply calls
ValueDeserializer.getNullValue(tools.jackson.databind.DeserializationContext)
and returns value.- Overrides:
getEmptyValue
in classValueDeserializer<Object>
-
_deserializeFromEmptyStringDefault
protected Object _deserializeFromEmptyStringDefault(DeserializationContext ctxt) throws tools.jackson.core.JacksonException - Overrides:
_deserializeFromEmptyStringDefault
in classFromStringDeserializer<Object>
- Throws:
tools.jackson.core.JacksonException
-
_firstHyphenOrUnderscore
-