Package org.codehaus.jackson.map.deser
Class StdDeserializationContext
- java.lang.Object
-
- org.codehaus.jackson.map.DeserializationContext
-
- org.codehaus.jackson.map.deser.StdDeserializationContext
-
public class StdDeserializationContext extends DeserializationContext
Default implementation ofDeserializationContext
.
-
-
Field Summary
Fields Modifier and Type Field Description protected ArrayBuilders
_arrayBuilders
protected java.text.DateFormat
_dateFormat
protected DeserializerProvider
_deserProvider
protected InjectableValues
_injectableValues
protected ObjectBuffer
_objectBuffer
protected JsonParser
_parser
Currently active parser used for deserialization.-
Fields inherited from class org.codehaus.jackson.map.DeserializationContext
_config, _featureFlags
-
-
Constructor Summary
Constructors Constructor Description StdDeserializationContext(DeserializationConfig config, JsonParser jp, DeserializerProvider prov, InjectableValues injectableValues)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
_calcName(java.lang.Class<?> cls)
protected java.lang.String
_desc(java.lang.String desc)
protected java.lang.String
_valueDesc()
java.util.Calendar
constructCalendar(java.util.Date d)
Convenience method for constructing Calendar instance set to specified time, to be modified and used by caller.protected java.lang.String
determineClassName(java.lang.Object instance)
java.lang.Object
findInjectableValue(java.lang.Object valueId, BeanProperty forProperty, java.lang.Object beanInstance)
ArrayBuilders
getArrayBuilders()
Method for accessing object useful for building arrays of primitive types (such as int[]).protected java.text.DateFormat
getDateFormat()
DeserializerProvider
getDeserializerProvider()
Returns provider that can be used for dynamically locating other deserializers during runtime.JsonParser
getParser()
Method for accessing the currently active parser.boolean
handleUnknownProperty(JsonParser jp, JsonDeserializer<?> deser, java.lang.Object instanceOrClass, java.lang.String propName)
Method deserializers can call to inform configuredDeserializationProblemHandler
s of an unrecognized property.JsonMappingException
instantiationException(java.lang.Class<?> instClass, java.lang.String msg)
JsonMappingException
instantiationException(java.lang.Class<?> instClass, java.lang.Throwable t)
Helper method for constructing instantiation exception for specified type, to indicate problem with physically constructing instance of specified class (missing constructor, exception from constructor)ObjectBuffer
leaseObjectBuffer()
Method that can be used to get access to a reusable ObjectBuffer, useful for efficiently constructing Object arrays and Lists.JsonMappingException
mappingException(java.lang.Class<?> targetClass)
Helper method for constructing generic mapping exception for specified typeJsonMappingException
mappingException(java.lang.Class<?> targetClass, JsonToken token)
java.util.Date
parseDate(java.lang.String dateStr)
Convenience method for parsing a Date from given String, using currently configured date format (accessed usingMapperConfig.getDateFormat()
).void
returnObjectBuffer(ObjectBuffer buf)
Method to call to return object buffer previously leased withDeserializationContext.leaseObjectBuffer()
.JsonMappingException
unknownFieldException(java.lang.Object instanceOrClass, java.lang.String fieldName)
Helper method for constructing exception to indicate that JSON Object field name did not map to a known property of type being deserialized.JsonMappingException
unknownTypeException(JavaType type, java.lang.String id)
Helper method for constructing exception to indicate that given type id (parsed from JSON) could not be converted to a Java type.JsonMappingException
weirdKeyException(java.lang.Class<?> keyClass, java.lang.String keyValue, java.lang.String msg)
Helper method for constructing exception to indicate that given JSON Object field name was not in format to be able to deserialize specified key type.JsonMappingException
weirdNumberException(java.lang.Class<?> instClass, java.lang.String msg)
Helper method for constructing exception to indicate that input JSON Number was not suitable for deserializing into given type.JsonMappingException
weirdStringException(java.lang.Class<?> instClass, java.lang.String msg)
Method that will construct an exception suitable for throwing when some String values are acceptable, but the one encountered is notJsonMappingException
wrongTokenException(JsonParser jp, JsonToken expToken, java.lang.String msg)
Helper method for indicating that the current token was expected to be another token.-
Methods inherited from class org.codehaus.jackson.map.DeserializationContext
constructType, getBase64Variant, getConfig, getNodeFactory, getTypeFactory, isEnabled, mappingException
-
-
-
-
Field Detail
-
_parser
protected JsonParser _parser
Currently active parser used for deserialization. May be different from the outermost parser when content is buffered.
-
_deserProvider
protected final DeserializerProvider _deserProvider
- Since:
- 1.5
-
_injectableValues
protected final InjectableValues _injectableValues
- Since:
- 1.9
-
_arrayBuilders
protected ArrayBuilders _arrayBuilders
-
_objectBuffer
protected ObjectBuffer _objectBuffer
-
_dateFormat
protected java.text.DateFormat _dateFormat
-
-
Constructor Detail
-
StdDeserializationContext
public StdDeserializationContext(DeserializationConfig config, JsonParser jp, DeserializerProvider prov, InjectableValues injectableValues)
-
-
Method Detail
-
getDeserializerProvider
public DeserializerProvider getDeserializerProvider()
Description copied from class:DeserializationContext
Returns provider that can be used for dynamically locating other deserializers during runtime.- Overrides:
getDeserializerProvider
in classDeserializationContext
-
getParser
public JsonParser getParser()
Method for accessing the currently active parser. May be different from the outermost parser when content is buffered.Use of this method is discouraged: if code has direct access to the active parser, that should be used instead.
- Specified by:
getParser
in classDeserializationContext
-
findInjectableValue
public java.lang.Object findInjectableValue(java.lang.Object valueId, BeanProperty forProperty, java.lang.Object beanInstance)
- Specified by:
findInjectableValue
in classDeserializationContext
-
leaseObjectBuffer
public final ObjectBuffer leaseObjectBuffer()
Description copied from class:DeserializationContext
Method that can be used to get access to a reusable ObjectBuffer, useful for efficiently constructing Object arrays and Lists. Note that leased buffers should be returned once deserializer is done, to allow for reuse during same round of deserialization.- Specified by:
leaseObjectBuffer
in classDeserializationContext
-
returnObjectBuffer
public final void returnObjectBuffer(ObjectBuffer buf)
Description copied from class:DeserializationContext
Method to call to return object buffer previously leased withDeserializationContext.leaseObjectBuffer()
.- Specified by:
returnObjectBuffer
in classDeserializationContext
- Parameters:
buf
- Returned object buffer
-
getArrayBuilders
public final ArrayBuilders getArrayBuilders()
Description copied from class:DeserializationContext
Method for accessing object useful for building arrays of primitive types (such as int[]).- Specified by:
getArrayBuilders
in classDeserializationContext
-
parseDate
public java.util.Date parseDate(java.lang.String dateStr) throws java.lang.IllegalArgumentException
Description copied from class:DeserializationContext
Convenience method for parsing a Date from given String, using currently configured date format (accessed usingMapperConfig.getDateFormat()
).Implementation will handle thread-safety issues related to date formats such that first time this method is called, date format is cloned, and cloned instance will be retained for use during this deserialization round.
- Specified by:
parseDate
in classDeserializationContext
- Throws:
java.lang.IllegalArgumentException
-
constructCalendar
public java.util.Calendar constructCalendar(java.util.Date d)
Description copied from class:DeserializationContext
Convenience method for constructing Calendar instance set to specified time, to be modified and used by caller.- Specified by:
constructCalendar
in classDeserializationContext
-
handleUnknownProperty
public boolean handleUnknownProperty(JsonParser jp, JsonDeserializer<?> deser, java.lang.Object instanceOrClass, java.lang.String propName) throws java.io.IOException, JsonProcessingException
Method deserializers can call to inform configuredDeserializationProblemHandler
s of an unrecognized property.- Specified by:
handleUnknownProperty
in classDeserializationContext
- Returns:
- True if there was a configured problem handler that was able to handle the proble
- Throws:
java.io.IOException
JsonProcessingException
- Since:
- 1.5
-
mappingException
public JsonMappingException mappingException(java.lang.Class<?> targetClass)
Description copied from class:DeserializationContext
Helper method for constructing generic mapping exception for specified type- Specified by:
mappingException
in classDeserializationContext
-
mappingException
public JsonMappingException mappingException(java.lang.Class<?> targetClass, JsonToken token)
- Specified by:
mappingException
in classDeserializationContext
-
instantiationException
public JsonMappingException instantiationException(java.lang.Class<?> instClass, java.lang.Throwable t)
Description copied from class:DeserializationContext
Helper method for constructing instantiation exception for specified type, to indicate problem with physically constructing instance of specified class (missing constructor, exception from constructor)- Specified by:
instantiationException
in classDeserializationContext
-
instantiationException
public JsonMappingException instantiationException(java.lang.Class<?> instClass, java.lang.String msg)
- Specified by:
instantiationException
in classDeserializationContext
-
weirdStringException
public JsonMappingException weirdStringException(java.lang.Class<?> instClass, java.lang.String msg)
Method that will construct an exception suitable for throwing when some String values are acceptable, but the one encountered is not- Specified by:
weirdStringException
in classDeserializationContext
-
weirdNumberException
public JsonMappingException weirdNumberException(java.lang.Class<?> instClass, java.lang.String msg)
Description copied from class:DeserializationContext
Helper method for constructing exception to indicate that input JSON Number was not suitable for deserializing into given type.- Specified by:
weirdNumberException
in classDeserializationContext
-
weirdKeyException
public JsonMappingException weirdKeyException(java.lang.Class<?> keyClass, java.lang.String keyValue, java.lang.String msg)
Description copied from class:DeserializationContext
Helper method for constructing exception to indicate that given JSON Object field name was not in format to be able to deserialize specified key type.- Specified by:
weirdKeyException
in classDeserializationContext
-
wrongTokenException
public JsonMappingException wrongTokenException(JsonParser jp, JsonToken expToken, java.lang.String msg)
Description copied from class:DeserializationContext
Helper method for indicating that the current token was expected to be another token.- Specified by:
wrongTokenException
in classDeserializationContext
-
unknownFieldException
public JsonMappingException unknownFieldException(java.lang.Object instanceOrClass, java.lang.String fieldName)
Description copied from class:DeserializationContext
Helper method for constructing exception to indicate that JSON Object field name did not map to a known property of type being deserialized.- Specified by:
unknownFieldException
in classDeserializationContext
- Parameters:
instanceOrClass
- Either value being populated (if one has been instantiated), or Class that indicates type that would be (or have been) instantiated
-
unknownTypeException
public JsonMappingException unknownTypeException(JavaType type, java.lang.String id)
Description copied from class:DeserializationContext
Helper method for constructing exception to indicate that given type id (parsed from JSON) could not be converted to a Java type.- Specified by:
unknownTypeException
in classDeserializationContext
-
getDateFormat
protected java.text.DateFormat getDateFormat()
-
determineClassName
protected java.lang.String determineClassName(java.lang.Object instance)
-
_calcName
protected java.lang.String _calcName(java.lang.Class<?> cls)
-
_valueDesc
protected java.lang.String _valueDesc()
-
_desc
protected java.lang.String _desc(java.lang.String desc)
-
-