Class ObjectReader
- java.lang.Object
-
- com.fasterxml.jackson.core.TreeCodec
-
- com.fasterxml.jackson.core.ObjectCodec
-
- com.fasterxml.jackson.databind.ObjectReader
-
- All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned
,java.io.Serializable
public class ObjectReader extends com.fasterxml.jackson.core.ObjectCodec implements com.fasterxml.jackson.core.Versioned, java.io.Serializable
Builder object that can be used for per-serialization configuration of deserialization parameters, such as root type to use or object to update (instead of constructing new instance).Uses "mutant factory" pattern so that instances are immutable (and thus fully thread-safe with no external synchronization); new instances are constructed for different configurations. Instances are initially constructed by
ObjectMapper
and can be reused, shared, cached; both because of thread-safety and because instances are relatively light-weight.NOTE: this class is NOT meant as sub-classable (with Jackson 2.8 and above) by users. It is left as non-final mostly to allow frameworks that require bytecode generation for proxying and similar use cases, but there is no expecation that functionality should be extended by sub-classing.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected DeserializationConfig
_config
General serialization configuration settings; while immutable, can use copy-constructor to create modified instances as necessary.protected DefaultDeserializationContext
_context
Blueprint instance of deserialization context; used for creating actual instance when needed.protected DataFormatReaders
_dataFormatReaders
Optional detector used for auto-detecting data format that byte-based input uses.protected InjectableValues
_injectableValues
Values that can be injected during deserialization, if any.protected JavaType
_jsonNodeType
protected com.fasterxml.jackson.core.JsonFactory
_parserFactory
Factory used for constructingJsonGenerator
sprotected JsonDeserializer<java.lang.Object>
_rootDeserializer
We may pre-fetch deserializer as soon as_valueType
is known, and if so, reuse it afterwards.protected java.util.concurrent.ConcurrentHashMap<JavaType,JsonDeserializer<java.lang.Object>>
_rootDeserializers
Root-level cached deserializers.protected com.fasterxml.jackson.core.FormatSchema
_schema
When using data format that uses a schema, schema is passed to parser.protected boolean
_unwrapRoot
Flag that indicates whether root values are expected to be unwrapped or notprotected java.lang.Object
_valueToUpdate
Instance to update with data binding; if any.protected JavaType
_valueType
Declared type of value to instantiate during deserialization.
-
Constructor Summary
Constructors Modifier Constructor Description protected
ObjectReader(ObjectMapper mapper, DeserializationConfig config)
Constructor used byObjectMapper
for initial instantiationprotected
ObjectReader(ObjectMapper mapper, DeserializationConfig config, JavaType valueType, java.lang.Object valueToUpdate, com.fasterxml.jackson.core.FormatSchema schema, InjectableValues injectableValues)
Constructor called when a root deserializer should be fetched based on other configuration.protected
ObjectReader(ObjectReader base, com.fasterxml.jackson.core.filter.TokenFilter filter)
protected
ObjectReader(ObjectReader base, com.fasterxml.jackson.core.JsonFactory f)
protected
ObjectReader(ObjectReader base, DeserializationConfig config)
Copy constructor used when modifying simple feature flagsprotected
ObjectReader(ObjectReader base, DeserializationConfig config, JavaType valueType, JsonDeserializer<java.lang.Object> rootDeser, java.lang.Object valueToUpdate, com.fasterxml.jackson.core.FormatSchema schema, InjectableValues injectableValues, DataFormatReaders dataFormatReaders)
Copy constructor used for building variations.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
_assertNotNull(java.lang.String paramName, java.lang.Object src)
protected java.lang.Object
_bind(com.fasterxml.jackson.core.JsonParser p, java.lang.Object valueToUpdate)
Actual implementation of value reading+binding operation.protected java.lang.Object
_bindAndClose(com.fasterxml.jackson.core.JsonParser p0)
protected JsonNode
_bindAndCloseAsTree(com.fasterxml.jackson.core.JsonParser p0)
protected <T> MappingIterator<T>
_bindAndReadValues(com.fasterxml.jackson.core.JsonParser p)
protected JsonNode
_bindAsTree(com.fasterxml.jackson.core.JsonParser p)
protected JsonNode
_bindAsTreeOrNull(com.fasterxml.jackson.core.JsonParser p)
Same as_bindAsTree(com.fasterxml.jackson.core.JsonParser)
except end-of-input is reported by returningnull
, not "missing node"protected com.fasterxml.jackson.core.JsonParser
_considerFilter(com.fasterxml.jackson.core.JsonParser p, boolean multiValue)
Consider filter when creating JsonParser.protected java.lang.Object
_detectBindAndClose(byte[] src, int offset, int length)
protected java.lang.Object
_detectBindAndClose(DataFormatReaders.Match match, boolean forceClosing)
protected JsonNode
_detectBindAndCloseAsTree(java.io.InputStream in)
protected <T> MappingIterator<T>
_detectBindAndReadValues(DataFormatReaders.Match match, boolean forceClosing)
protected JsonDeserializer<java.lang.Object>
_findRootDeserializer(DeserializationContext ctxt)
Method called to locate deserializer for the passed root-level value.protected JsonDeserializer<java.lang.Object>
_findTreeDeserializer(DeserializationContext ctxt)
protected void
_initForMultiRead(DeserializationContext ctxt, com.fasterxml.jackson.core.JsonParser p)
Alternative to_initForReading(com.fasterxml.jackson.databind.DeserializationContext, com.fasterxml.jackson.core.JsonParser)
used in cases where reading of multiple values means that we may or may not want to advance the stream, but need to do other initialization.protected com.fasterxml.jackson.core.JsonToken
_initForReading(DeserializationContext ctxt, com.fasterxml.jackson.core.JsonParser p)
protected java.io.InputStream
_inputStream(java.io.File f)
protected java.io.InputStream
_inputStream(java.net.URL src)
protected JavaType
_jsonNodeType()
protected ObjectReader
_new(ObjectReader base, com.fasterxml.jackson.core.JsonFactory f)
Overridable factory method called by various "withXxx()" methodsprotected ObjectReader
_new(ObjectReader base, DeserializationConfig config)
Overridable factory method called by various "withXxx()" methodsprotected ObjectReader
_new(ObjectReader base, DeserializationConfig config, JavaType valueType, JsonDeserializer<java.lang.Object> rootDeser, java.lang.Object valueToUpdate, com.fasterxml.jackson.core.FormatSchema schema, InjectableValues injectableValues, DataFormatReaders dataFormatReaders)
Overridable factory method called by various "withXxx()" methodsprotected <T> MappingIterator<T>
_newIterator(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, JsonDeserializer<?> deser, boolean parserManaged)
Factory method used to createMappingIterator
instances; either default, or custom subtype.protected JsonDeserializer<java.lang.Object>
_prefetchRootDeserializer(JavaType valueType)
Method called to locate deserializer ahead of time, if permitted by configuration.protected void
_reportUndetectableSource(java.lang.Object src)
protected void
_reportUnkownFormat(DataFormatReaders detector, DataFormatReaders.Match match)
Method called to indicate that format detection failed to detect format of given inputprotected void
_verifyNoTrailingTokens(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, JavaType bindType)
protected void
_verifySchemaType(com.fasterxml.jackson.core.FormatSchema schema)
protected ObjectReader
_with(DeserializationConfig newConfig)
ObjectReader
at(com.fasterxml.jackson.core.JsonPointer pointer)
Convenience method to bind fromJsonPointer
JsonPointerBasedFilter
is registered and will be used for parsing later.ObjectReader
at(java.lang.String pointerExpr)
Convenience method to bind fromJsonPointer
.JsonNode
createArrayNode()
protected DefaultDeserializationContext
createDeserializationContext(com.fasterxml.jackson.core.JsonParser p)
Internal helper method called to create an instance ofDeserializationContext
for deserializing a single root value.protected DefaultDeserializationContext
createDummyDeserializationContext()
com.fasterxml.jackson.core.JsonParser
createNonBlockingByteArrayParser()
Factory method for constructing properly initializedJsonParser
to read content using non-blocking (asynchronous) mode.JsonNode
createObjectNode()
com.fasterxml.jackson.core.JsonParser
createParser(byte[] content)
Factory method for constructing properly initializedJsonParser
to read content from specified byte array.com.fasterxml.jackson.core.JsonParser
createParser(byte[] content, int offset, int len)
Factory method for constructing properly initializedJsonParser
to read content from specified byte array.com.fasterxml.jackson.core.JsonParser
createParser(char[] content)
Factory method for constructing properly initializedJsonParser
to read content from specified character array Parser is not managed (or "owned") by ObjectReader: caller is responsible for properly closing it once content reading is complete.com.fasterxml.jackson.core.JsonParser
createParser(char[] content, int offset, int len)
Factory method for constructing properly initializedJsonParser
to read content from specified character array.com.fasterxml.jackson.core.JsonParser
createParser(java.io.DataInput content)
Factory method for constructing properly initializedJsonParser
to read content using specifiedDataInput
.com.fasterxml.jackson.core.JsonParser
createParser(java.io.File src)
Factory method for constructing properly initializedJsonParser
to read content from specifiedFile
.com.fasterxml.jackson.core.JsonParser
createParser(java.io.InputStream in)
Factory method for constructing properly initializedJsonParser
to read content using specifiedInputStream
.com.fasterxml.jackson.core.JsonParser
createParser(java.io.Reader r)
Factory method for constructing properly initializedJsonParser
to read content using specifiedReader
.com.fasterxml.jackson.core.JsonParser
createParser(java.lang.String content)
Factory method for constructing properly initializedJsonParser
to read content from specified String.com.fasterxml.jackson.core.JsonParser
createParser(java.net.URL src)
Factory method for constructing properly initializedJsonParser
to read content from specifiedFile
.ObjectReader
forType(com.fasterxml.jackson.core.type.TypeReference<?> valueTypeRef)
Method for constructing a new reader instance that is configured to data bind into specified type.ObjectReader
forType(JavaType valueType)
Method for constructing a new reader instance that is configured to data bind into specified type.ObjectReader
forType(java.lang.Class<?> valueType)
Method for constructing a new reader instance that is configured to data bind into specified type.ContextAttributes
getAttributes()
DeserializationConfig
getConfig()
com.fasterxml.jackson.core.JsonFactory
getFactory()
InjectableValues
getInjectableValues()
TypeFactory
getTypeFactory()
JavaType
getValueType()
boolean
isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f)
boolean
isEnabled(com.fasterxml.jackson.core.StreamReadFeature f)
boolean
isEnabled(DeserializationFeature f)
boolean
isEnabled(MapperFeature f)
JsonNode
missingNode()
JsonNode
nullNode()
JsonNode
readTree(byte[] json)
Same asreadTree(InputStream)
except content read from passed-in byte array.JsonNode
readTree(byte[] json, int offset, int len)
Same asreadTree(InputStream)
except content read from passed-in byte array.<T extends com.fasterxml.jackson.core.TreeNode>
TreadTree(com.fasterxml.jackson.core.JsonParser p)
Convenience method that binds content read using given parser, using configuration of this reader, except that content is bound as JSON tree instead of configured root value type.JsonNode
readTree(java.io.DataInput src)
Same asreadTree(InputStream)
except content read using passed-inDataInput
.JsonNode
readTree(java.io.InputStream src)
Method that reads content from given input source, using configuration of this reader, and binds it as JSON Tree.JsonNode
readTree(java.io.Reader src)
Same asreadTree(InputStream)
except content accessed through passed-inReader
JsonNode
readTree(java.lang.String json)
Same asreadTree(InputStream)
except content read from passed-inString
<T> T
readValue(byte[] content)
Method that binds content read from given byte array, using configuration of this reader.<T> T
readValue(byte[] buffer, int offset, int length)
Method that binds content read from given byte array, using configuration of this reader.<T> T
readValue(byte[] buffer, int offset, int length, java.lang.Class<T> valueType)
Same asreadValue(byte[],int,int)
except that target value type overridden asvalueType
<T> T
readValue(byte[] content, java.lang.Class<T> valueType)
Same asreadValue(byte[])
except that target value type overridden asvalueType
<T> T
readValue(com.fasterxml.jackson.core.JsonParser p)
Method that binds content read using given parser, using configuration of this reader, including expected result type.<T> T
readValue(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.core.type.ResolvedType valueType)
Convenience method that binds content read using given parser, using configuration of this reader, except that expected value type is specified with the call (instead of currently configured root type).<T> T
readValue(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.core.type.TypeReference<T> valueTypeRef)
Convenience method that binds content read using given parser, using configuration of this reader, except that expected value type is specified with the call (instead of currently configured root type).<T> T
readValue(com.fasterxml.jackson.core.JsonParser p, JavaType valueType)
Type-safe overloaded method, basically alias forreadValue(JsonParser, ResolvedType)
.<T> T
readValue(com.fasterxml.jackson.core.JsonParser p, java.lang.Class<T> valueType)
Convenience method that binds content read using given parser, using configuration of this reader, except that expected value type is specified with the call (instead of currently configured root type).<T> T
readValue(JsonNode content)
Convenience method for converting results from given JSON tree into given value type.<T> T
readValue(JsonNode content, java.lang.Class<T> valueType)
Same asreadValue(JsonNode)
except that target value type overridden asvalueType
<T> T
readValue(java.io.DataInput src)
<T> T
readValue(java.io.DataInput content, java.lang.Class<T> valueType)
Same asreadValue(DataInput)
except that target value type overridden asvalueType
<T> T
readValue(java.io.File src)
Method that binds content read from givenFile
using configuration of this reader.<T> T
readValue(java.io.File src, java.lang.Class<T> valueType)
Same asreadValue(File)
except that target value type overridden asvalueType
<T> T
readValue(java.io.InputStream src)
Method that binds content read from given input source, using configuration of this reader.<T> T
readValue(java.io.InputStream src, java.lang.Class<T> valueType)
Same asreadValue(InputStream)
except that target value type overridden asvalueType
<T> T
readValue(java.io.Reader src)
Method that binds content read from given input source, using configuration of this reader.<T> T
readValue(java.io.Reader src, java.lang.Class<T> valueType)
Same asreadValue(Reader)
except that target value type overridden asvalueType
<T> T
readValue(java.lang.String src)
Method that binds content read from given JSON string, using configuration of this reader.<T> T
readValue(java.lang.String src, java.lang.Class<T> valueType)
Same asreadValue(String)
except that target value type overridden asvalueType
<T> T
readValue(java.net.URL src)
Method that binds content read from given input source, using configuration of this reader.<T> T
readValue(java.net.URL src, java.lang.Class<T> valueType)
Same asreadValue(URL)
except that target value type overridden asvalueType
<T> MappingIterator<T>
readValues(byte[] src)
Overloaded version ofreadValue(InputStream)
.<T> MappingIterator<T>
readValues(byte[] src, int offset, int length)
Overloaded version ofreadValue(InputStream)
.<T> MappingIterator<T>
readValues(com.fasterxml.jackson.core.JsonParser p)
Method for reading sequence of Objects from parser stream.<T> java.util.Iterator<T>
readValues(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.core.type.ResolvedType valueType)
Convenience method that is equivalent to:<T> java.util.Iterator<T>
readValues(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.core.type.TypeReference<T> valueTypeRef)
Convenience method that is equivalent to:<T> java.util.Iterator<T>
readValues(com.fasterxml.jackson.core.JsonParser p, JavaType valueType)
Convenience method that is equivalent to:<T> java.util.Iterator<T>
readValues(com.fasterxml.jackson.core.JsonParser p, java.lang.Class<T> valueType)
Convenience method that is equivalent to:<T> MappingIterator<T>
readValues(java.io.DataInput src)
<T> MappingIterator<T>
readValues(java.io.File src)
Overloaded version ofreadValue(InputStream)
.<T> MappingIterator<T>
readValues(java.io.InputStream src)
Method for reading sequence of Objects from parser stream.<T> MappingIterator<T>
readValues(java.io.Reader src)
Overloaded version ofreadValue(InputStream)
.<T> MappingIterator<T>
readValues(java.lang.String json)
Overloaded version ofreadValue(InputStream)
.<T> MappingIterator<T>
readValues(java.net.URL src)
Overloaded version ofreadValue(InputStream)
.com.fasterxml.jackson.core.JsonParser
treeAsTokens(com.fasterxml.jackson.core.TreeNode n)
<T> T
treeToValue(com.fasterxml.jackson.core.TreeNode n, java.lang.Class<T> valueType)
com.fasterxml.jackson.core.Version
version()
Method that will return version information stored in and read from jar that contains this class.ObjectReader
with(com.fasterxml.jackson.core.Base64Variant defaultBase64)
ObjectReader
with(com.fasterxml.jackson.core.FormatFeature feature)
Method for constructing a new reader instance that is configured with specified feature enabled.ObjectReader
with(com.fasterxml.jackson.core.FormatSchema schema)
Method for constructing a new instance with configuration that passes specifiedFormatSchema
toJsonParser
that is constructed for parsing content.ObjectReader
with(com.fasterxml.jackson.core.JsonFactory f)
Method for constructing a new reader instance with configuration that uses passedJsonFactory
for constructing underlying Readers.ObjectReader
with(com.fasterxml.jackson.core.JsonParser.Feature feature)
Method for constructing a new reader instance that is configured with specified feature enabled.ObjectReader
with(com.fasterxml.jackson.core.StreamReadFeature feature)
Method for constructing a new reader instance that is configured with specified feature enabled.ObjectReader
with(ContextAttributes attrs)
ObjectReader
with(DeserializationConfig config)
Mutant factory method that will construct a new instance that has specified underlyingDeserializationConfig
.ObjectReader
with(DeserializationFeature feature)
Method for constructing a new reader instance that is configured with specified feature enabled.ObjectReader
with(DeserializationFeature first, DeserializationFeature... other)
Method for constructing a new reader instance that is configured with specified features enabled.ObjectReader
with(InjectableValues injectableValues)
Method for constructing a new instance with configuration that uses passedInjectableValues
to provide injectable values.ObjectReader
with(JsonNodeFactory f)
Method for constructing a new reader instance with configuration that uses passedJsonNodeFactory
for constructingJsonNode
instances.ObjectReader
with(java.util.Locale l)
ObjectReader
with(java.util.TimeZone tz)
ObjectReader
withAttribute(java.lang.Object key, java.lang.Object value)
ObjectReader
withAttributes(java.util.Map<?,?> attrs)
ObjectReader
withFeatures(com.fasterxml.jackson.core.FormatFeature... features)
Method for constructing a new reader instance that is configured with specified features enabled.ObjectReader
withFeatures(com.fasterxml.jackson.core.JsonParser.Feature... features)
Method for constructing a new reader instance that is configured with specified features enabled.ObjectReader
withFeatures(DeserializationFeature... features)
Method for constructing a new reader instance that is configured with specified features enabled.ObjectReader
withFormatDetection(DataFormatReaders readers)
Fluent factory method for constructing a reader that will try to auto-detect underlying data format, using specifiedDataFormatReaders
.ObjectReader
withFormatDetection(ObjectReader... readers)
Fluent factory method for constructing a reader that will try to auto-detect underlying data format, using specified list ofJsonFactory
instances, and defaultDataFormatReaders
settings (for customizedDataFormatReaders
, you can construct instance yourself).ObjectReader
withHandler(DeserializationProblemHandler h)
ObjectReader
without(com.fasterxml.jackson.core.FormatFeature feature)
Method for constructing a new reader instance that is configured with specified feature disabled.ObjectReader
without(com.fasterxml.jackson.core.JsonParser.Feature feature)
Method for constructing a new reader instance that is configured with specified feature disabled.ObjectReader
without(com.fasterxml.jackson.core.StreamReadFeature feature)
Method for constructing a new reader instance that is configured with specified feature disabled.ObjectReader
without(DeserializationFeature feature)
Method for constructing a new reader instance that is configured with specified feature disabled.ObjectReader
without(DeserializationFeature first, DeserializationFeature... other)
Method for constructing a new reader instance that is configured with specified features disabled.ObjectReader
withoutAttribute(java.lang.Object key)
ObjectReader
withoutFeatures(com.fasterxml.jackson.core.FormatFeature... features)
Method for constructing a new reader instance that is configured with specified features disabled.ObjectReader
withoutFeatures(com.fasterxml.jackson.core.JsonParser.Feature... features)
Method for constructing a new reader instance that is configured with specified features disabled.ObjectReader
withoutFeatures(DeserializationFeature... features)
Method for constructing a new reader instance that is configured with specified features disabled.ObjectReader
withoutRootName()
Convenience method that is same as calling:withRootName("")
which will forcibly prevent use of root name wrapping when writing values with thisObjectReader
.ObjectReader
withRootName(PropertyName rootName)
ObjectReader
withRootName(java.lang.String rootName)
Method for constructing a new instance with configuration that specifies what root name to expect for "root name unwrapping".ObjectReader
withType(com.fasterxml.jackson.core.type.TypeReference<?> valueTypeRef)
Deprecated.since 2.5 UseforType(TypeReference)
insteadObjectReader
withType(JavaType valueType)
Deprecated.since 2.5 UseforType(JavaType)
insteadObjectReader
withType(java.lang.Class<?> valueType)
Deprecated.since 2.5 UseforType(Class)
insteadObjectReader
withType(java.lang.reflect.Type valueType)
Deprecated.since 2.5 UseforType(Class)
insteadObjectReader
withValueToUpdate(java.lang.Object value)
Method for constructing a new instance with configuration that updates passed Object (as root value), instead of constructing a new value.ObjectReader
withView(java.lang.Class<?> activeView)
Method for constructing a new instance with configuration that uses specified View for filtering.void
writeTree(com.fasterxml.jackson.core.JsonGenerator g, com.fasterxml.jackson.core.TreeNode rootNode)
void
writeValue(com.fasterxml.jackson.core.JsonGenerator gen, java.lang.Object value)
-
-
-
Field Detail
-
_config
protected final DeserializationConfig _config
General serialization configuration settings; while immutable, can use copy-constructor to create modified instances as necessary.
-
_context
protected final DefaultDeserializationContext _context
Blueprint instance of deserialization context; used for creating actual instance when needed.
-
_parserFactory
protected final com.fasterxml.jackson.core.JsonFactory _parserFactory
Factory used for constructingJsonGenerator
s
-
_unwrapRoot
protected final boolean _unwrapRoot
Flag that indicates whether root values are expected to be unwrapped or not
-
_valueType
protected final JavaType _valueType
Declared type of value to instantiate during deserialization. Defines which deserializer to use; as well as base type of instance to construct if an updatable value is not configured to be used (subject to changes by embedded type information, for polymorphic types). If_valueToUpdate
is non-null, only used for locating deserializer.
-
_rootDeserializer
protected final JsonDeserializer<java.lang.Object> _rootDeserializer
We may pre-fetch deserializer as soon as_valueType
is known, and if so, reuse it afterwards. This allows avoiding further deserializer lookups and increases performance a bit on cases where readers are reused.- Since:
- 2.1
-
_valueToUpdate
protected final java.lang.Object _valueToUpdate
Instance to update with data binding; if any. If null, a new instance is created, if non-null, properties of this value object will be updated instead. Note that value can be of almost any type, except notArrayType
; array types cannot be modified because array size is immutable.
-
_schema
protected final com.fasterxml.jackson.core.FormatSchema _schema
When using data format that uses a schema, schema is passed to parser.
-
_injectableValues
protected final InjectableValues _injectableValues
Values that can be injected during deserialization, if any.
-
_dataFormatReaders
protected final DataFormatReaders _dataFormatReaders
Optional detector used for auto-detecting data format that byte-based input uses.NOTE: If defined non-null,
readValue()
methods that takeReader
orString
input will fail with exception, because format-detection only works on byte-sources. Also, if format cannot be detect reliably (as per detector settings), aJsonParseException
will be thrown).- Since:
- 2.1
-
_rootDeserializers
protected final java.util.concurrent.ConcurrentHashMap<JavaType,JsonDeserializer<java.lang.Object>> _rootDeserializers
Root-level cached deserializers. Passed byObjectMapper
, shared with it.
-
_jsonNodeType
protected transient JavaType _jsonNodeType
-
-
Constructor Detail
-
ObjectReader
protected ObjectReader(ObjectMapper mapper, DeserializationConfig config)
Constructor used byObjectMapper
for initial instantiation
-
ObjectReader
protected ObjectReader(ObjectMapper mapper, DeserializationConfig config, JavaType valueType, java.lang.Object valueToUpdate, com.fasterxml.jackson.core.FormatSchema schema, InjectableValues injectableValues)
Constructor called when a root deserializer should be fetched based on other configuration.
-
ObjectReader
protected ObjectReader(ObjectReader base, DeserializationConfig config, JavaType valueType, JsonDeserializer<java.lang.Object> rootDeser, java.lang.Object valueToUpdate, com.fasterxml.jackson.core.FormatSchema schema, InjectableValues injectableValues, DataFormatReaders dataFormatReaders)
Copy constructor used for building variations.
-
ObjectReader
protected ObjectReader(ObjectReader base, DeserializationConfig config)
Copy constructor used when modifying simple feature flags
-
ObjectReader
protected ObjectReader(ObjectReader base, com.fasterxml.jackson.core.JsonFactory f)
-
ObjectReader
protected ObjectReader(ObjectReader base, com.fasterxml.jackson.core.filter.TokenFilter filter)
-
-
Method Detail
-
version
public com.fasterxml.jackson.core.Version version()
Method that will return version information stored in and read from jar that contains this class.- Specified by:
version
in interfacecom.fasterxml.jackson.core.Versioned
- Specified by:
version
in classcom.fasterxml.jackson.core.ObjectCodec
-
_new
protected ObjectReader _new(ObjectReader base, com.fasterxml.jackson.core.JsonFactory f)
Overridable factory method called by various "withXxx()" methods- Since:
- 2.5
-
_new
protected ObjectReader _new(ObjectReader base, DeserializationConfig config)
Overridable factory method called by various "withXxx()" methods- Since:
- 2.5
-
_new
protected ObjectReader _new(ObjectReader base, DeserializationConfig config, JavaType valueType, JsonDeserializer<java.lang.Object> rootDeser, java.lang.Object valueToUpdate, com.fasterxml.jackson.core.FormatSchema schema, InjectableValues injectableValues, DataFormatReaders dataFormatReaders)
Overridable factory method called by various "withXxx()" methods- Since:
- 2.5
-
_newIterator
protected <T> MappingIterator<T> _newIterator(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, JsonDeserializer<?> deser, boolean parserManaged)
Factory method used to createMappingIterator
instances; either default, or custom subtype.- Since:
- 2.5
-
_initForReading
protected com.fasterxml.jackson.core.JsonToken _initForReading(DeserializationContext ctxt, com.fasterxml.jackson.core.JsonParser p) throws java.io.IOException
- Throws:
java.io.IOException
-
_initForMultiRead
protected void _initForMultiRead(DeserializationContext ctxt, com.fasterxml.jackson.core.JsonParser p) throws java.io.IOException
Alternative to_initForReading(com.fasterxml.jackson.databind.DeserializationContext, com.fasterxml.jackson.core.JsonParser)
used in cases where reading of multiple values means that we may or may not want to advance the stream, but need to do other initialization.Base implementation only sets configured
FormatSchema
, if any, on parser.- Throws:
java.io.IOException
- Since:
- 2.8
-
with
public ObjectReader with(DeserializationFeature feature)
Method for constructing a new reader instance that is configured with specified feature enabled.
-
with
public ObjectReader with(DeserializationFeature first, DeserializationFeature... other)
Method for constructing a new reader instance that is configured with specified features enabled.
-
withFeatures
public ObjectReader withFeatures(DeserializationFeature... features)
Method for constructing a new reader instance that is configured with specified features enabled.
-
without
public ObjectReader without(DeserializationFeature feature)
Method for constructing a new reader instance that is configured with specified feature disabled.
-
without
public ObjectReader without(DeserializationFeature first, DeserializationFeature... other)
Method for constructing a new reader instance that is configured with specified features disabled.
-
withoutFeatures
public ObjectReader withoutFeatures(DeserializationFeature... features)
Method for constructing a new reader instance that is configured with specified features disabled.
-
with
public ObjectReader with(com.fasterxml.jackson.core.JsonParser.Feature feature)
Method for constructing a new reader instance that is configured with specified feature enabled.- Parameters:
feature
- Feature to enable- Returns:
- Reader instance with specified feature enabled
-
withFeatures
public ObjectReader withFeatures(com.fasterxml.jackson.core.JsonParser.Feature... features)
Method for constructing a new reader instance that is configured with specified features enabled.- Parameters:
features
- Features to enable- Returns:
- Reader instance with specified features enabled
-
without
public ObjectReader without(com.fasterxml.jackson.core.JsonParser.Feature feature)
Method for constructing a new reader instance that is configured with specified feature disabled.- Parameters:
feature
- Feature to disable- Returns:
- Reader instance with specified feature disabled
-
withoutFeatures
public ObjectReader withoutFeatures(com.fasterxml.jackson.core.JsonParser.Feature... features)
Method for constructing a new reader instance that is configured with specified features disabled.- Parameters:
features
- Features to disable- Returns:
- Reader instance with specified features disabled
-
with
public ObjectReader with(com.fasterxml.jackson.core.StreamReadFeature feature)
Method for constructing a new reader instance that is configured with specified feature enabled.- Returns:
- Reader instance with specified feature enabled
- Since:
- 2.11
-
without
public ObjectReader without(com.fasterxml.jackson.core.StreamReadFeature feature)
Method for constructing a new reader instance that is configured with specified feature disabled.- Returns:
- Reader instance with specified feature enabled
- Since:
- 2.11
-
with
public ObjectReader with(com.fasterxml.jackson.core.FormatFeature feature)
Method for constructing a new reader instance that is configured with specified feature enabled.- Since:
- 2.7
-
withFeatures
public ObjectReader withFeatures(com.fasterxml.jackson.core.FormatFeature... features)
Method for constructing a new reader instance that is configured with specified features enabled.- Since:
- 2.7
-
without
public ObjectReader without(com.fasterxml.jackson.core.FormatFeature feature)
Method for constructing a new reader instance that is configured with specified feature disabled.- Since:
- 2.7
-
withoutFeatures
public ObjectReader withoutFeatures(com.fasterxml.jackson.core.FormatFeature... features)
Method for constructing a new reader instance that is configured with specified features disabled.- Since:
- 2.7
-
at
public ObjectReader at(java.lang.String pointerExpr)
Convenience method to bind fromJsonPointer
.JsonPointerBasedFilter
is registered and will be used for parsing later.- Since:
- 2.6
-
at
public ObjectReader at(com.fasterxml.jackson.core.JsonPointer pointer)
Convenience method to bind fromJsonPointer
JsonPointerBasedFilter
is registered and will be used for parsing later.- Since:
- 2.6
-
with
public ObjectReader with(DeserializationConfig config)
Mutant factory method that will construct a new instance that has specified underlyingDeserializationConfig
.NOTE: use of this method is not recommended, as there are many other re-configuration methods available.
-
with
public ObjectReader with(InjectableValues injectableValues)
Method for constructing a new instance with configuration that uses passedInjectableValues
to provide injectable values.Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
-
with
public ObjectReader with(JsonNodeFactory f)
Method for constructing a new reader instance with configuration that uses passedJsonNodeFactory
for constructingJsonNode
instances.Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
-
with
public ObjectReader with(com.fasterxml.jackson.core.JsonFactory f)
Method for constructing a new reader instance with configuration that uses passedJsonFactory
for constructing underlying Readers.NOTE: only factories that DO NOT REQUIRE SPECIAL MAPPERS (that is, ones that return
false
forJsonFactory.requiresCustomCodec()
) can be used: trying to use one that requires custom codec will throw exception- Since:
- 2.1
-
withRootName
public ObjectReader withRootName(java.lang.String rootName)
Method for constructing a new instance with configuration that specifies what root name to expect for "root name unwrapping". SeeMapperConfigBase.withRootName(String)
for details.Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
-
withRootName
public ObjectReader withRootName(PropertyName rootName)
- Since:
- 2.6
-
withoutRootName
public ObjectReader withoutRootName()
Convenience method that is same as calling:withRootName("")
which will forcibly prevent use of root name wrapping when writing values with thisObjectReader
.- Since:
- 2.6
-
with
public ObjectReader with(com.fasterxml.jackson.core.FormatSchema schema)
Method for constructing a new instance with configuration that passes specifiedFormatSchema
toJsonParser
that is constructed for parsing content.Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
-
forType
public ObjectReader forType(JavaType valueType)
Method for constructing a new reader instance that is configured to data bind into specified type.Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
- Since:
- 2.5
-
forType
public ObjectReader forType(java.lang.Class<?> valueType)
Method for constructing a new reader instance that is configured to data bind into specified type.Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
- Since:
- 2.5
-
forType
public ObjectReader forType(com.fasterxml.jackson.core.type.TypeReference<?> valueTypeRef)
Method for constructing a new reader instance that is configured to data bind into specified type.Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
- Since:
- 2.5
-
withType
@Deprecated public ObjectReader withType(JavaType valueType)
Deprecated.since 2.5 UseforType(JavaType)
instead
-
withType
@Deprecated public ObjectReader withType(java.lang.Class<?> valueType)
Deprecated.since 2.5 UseforType(Class)
instead
-
withType
@Deprecated public ObjectReader withType(java.lang.reflect.Type valueType)
Deprecated.since 2.5 UseforType(Class)
instead
-
withType
@Deprecated public ObjectReader withType(com.fasterxml.jackson.core.type.TypeReference<?> valueTypeRef)
Deprecated.since 2.5 UseforType(TypeReference)
instead
-
withValueToUpdate
public ObjectReader withValueToUpdate(java.lang.Object value)
Method for constructing a new instance with configuration that updates passed Object (as root value), instead of constructing a new value.Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
-
withView
public ObjectReader withView(java.lang.Class<?> activeView)
Method for constructing a new instance with configuration that uses specified View for filtering.Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
-
with
public ObjectReader with(java.util.Locale l)
-
with
public ObjectReader with(java.util.TimeZone tz)
-
withHandler
public ObjectReader withHandler(DeserializationProblemHandler h)
-
with
public ObjectReader with(com.fasterxml.jackson.core.Base64Variant defaultBase64)
-
withFormatDetection
public ObjectReader withFormatDetection(ObjectReader... readers)
Fluent factory method for constructing a reader that will try to auto-detect underlying data format, using specified list ofJsonFactory
instances, and defaultDataFormatReaders
settings (for customizedDataFormatReaders
, you can construct instance yourself). to construct appropriateJsonParser
for actual parsing.Note: since format detection only works with byte sources, it is possible to get a failure from some 'readValue()' methods. Also, if input cannot be reliably (enough) detected as one of specified types, an exception will be thrown.
Note: not all
JsonFactory
types can be passed: specifically, ones that require "custom codec" (like XML factory) will not work. Instead, use method that takesObjectReader
instances instead of factories.- Parameters:
readers
- Data formats accepted, in decreasing order of priority (that is, matches checked in listed order, first match wins)- Returns:
- Newly configured writer instance
- Since:
- 2.1
-
withFormatDetection
public ObjectReader withFormatDetection(DataFormatReaders readers)
Fluent factory method for constructing a reader that will try to auto-detect underlying data format, using specifiedDataFormatReaders
.NOTE: since format detection only works with byte sources, it is possible to get a failure from some 'readValue()' methods. Also, if input cannot be reliably (enough) detected as one of specified types, an exception will be thrown.
- Parameters:
readers
- DataFormatReaders to use for detecting underlying format.- Returns:
- Newly configured writer instance
- Since:
- 2.1
-
with
public ObjectReader with(ContextAttributes attrs)
- Since:
- 2.3
-
withAttributes
public ObjectReader withAttributes(java.util.Map<?,?> attrs)
- Since:
- 2.3
-
withAttribute
public ObjectReader withAttribute(java.lang.Object key, java.lang.Object value)
- Since:
- 2.3
-
withoutAttribute
public ObjectReader withoutAttribute(java.lang.Object key)
- Since:
- 2.3
-
_with
protected ObjectReader _with(DeserializationConfig newConfig)
-
isEnabled
public boolean isEnabled(DeserializationFeature f)
-
isEnabled
public boolean isEnabled(MapperFeature f)
-
isEnabled
public boolean isEnabled(com.fasterxml.jackson.core.JsonParser.Feature f)
-
isEnabled
public boolean isEnabled(com.fasterxml.jackson.core.StreamReadFeature f)
- Since:
- 2.11
-
getConfig
public DeserializationConfig getConfig()
- Since:
- 2.2
-
getFactory
public com.fasterxml.jackson.core.JsonFactory getFactory()
- Overrides:
getFactory
in classcom.fasterxml.jackson.core.ObjectCodec
- Since:
- 2.1
-
getTypeFactory
public TypeFactory getTypeFactory()
-
getAttributes
public ContextAttributes getAttributes()
- Since:
- 2.3
-
getInjectableValues
public InjectableValues getInjectableValues()
- Since:
- 2.6
-
getValueType
public JavaType getValueType()
- Since:
- 2.10
-
createParser
public com.fasterxml.jackson.core.JsonParser createParser(java.io.File src) throws java.io.IOException
Factory method for constructing properly initializedJsonParser
to read content from specifiedFile
. Parser is not managed (or "owned") by ObjectReader: caller is responsible for properly closing it once content reading is complete.- Throws:
java.io.IOException
- Since:
- 2.11
-
createParser
public com.fasterxml.jackson.core.JsonParser createParser(java.net.URL src) throws java.io.IOException
Factory method for constructing properly initializedJsonParser
to read content from specifiedFile
. Parser is not managed (or "owned") by ObjectReader: caller is responsible for properly closing it once content reading is complete.- Throws:
java.io.IOException
- Since:
- 2.11
-
createParser
public com.fasterxml.jackson.core.JsonParser createParser(java.io.InputStream in) throws java.io.IOException
Factory method for constructing properly initializedJsonParser
to read content using specifiedInputStream
. Parser is not managed (or "owned") by ObjectReader: caller is responsible for properly closing it once content reading is complete.- Throws:
java.io.IOException
- Since:
- 2.11
-
createParser
public com.fasterxml.jackson.core.JsonParser createParser(java.io.Reader r) throws java.io.IOException
Factory method for constructing properly initializedJsonParser
to read content using specifiedReader
. Parser is not managed (or "owned") by ObjectReader: caller is responsible for properly closing it once content reading is complete.- Throws:
java.io.IOException
- Since:
- 2.11
-
createParser
public com.fasterxml.jackson.core.JsonParser createParser(byte[] content) throws java.io.IOException
Factory method for constructing properly initializedJsonParser
to read content from specified byte array. Parser is not managed (or "owned") by ObjectReader: caller is responsible for properly closing it once content reading is complete.- Throws:
java.io.IOException
- Since:
- 2.11
-
createParser
public com.fasterxml.jackson.core.JsonParser createParser(byte[] content, int offset, int len) throws java.io.IOException
Factory method for constructing properly initializedJsonParser
to read content from specified byte array. Parser is not managed (or "owned") by ObjectReader: caller is responsible for properly closing it once content reading is complete.- Throws:
java.io.IOException
- Since:
- 2.11
-
createParser
public com.fasterxml.jackson.core.JsonParser createParser(java.lang.String content) throws java.io.IOException
Factory method for constructing properly initializedJsonParser
to read content from specified String. Parser is not managed (or "owned") by ObjectReader: caller is responsible for properly closing it once content reading is complete.- Throws:
java.io.IOException
- Since:
- 2.11
-
createParser
public com.fasterxml.jackson.core.JsonParser createParser(char[] content) throws java.io.IOException
Factory method for constructing properly initializedJsonParser
to read content from specified character array Parser is not managed (or "owned") by ObjectReader: caller is responsible for properly closing it once content reading is complete.- Throws:
java.io.IOException
- Since:
- 2.11
-
createParser
public com.fasterxml.jackson.core.JsonParser createParser(char[] content, int offset, int len) throws java.io.IOException
Factory method for constructing properly initializedJsonParser
to read content from specified character array. Parser is not managed (or "owned") by ObjectReader: caller is responsible for properly closing it once content reading is complete.- Throws:
java.io.IOException
- Since:
- 2.11
-
createParser
public com.fasterxml.jackson.core.JsonParser createParser(java.io.DataInput content) throws java.io.IOException
Factory method for constructing properly initializedJsonParser
to read content using specifiedDataInput
. Parser is not managed (or "owned") by ObjectReader: caller is responsible for properly closing it once content reading is complete.- Throws:
java.io.IOException
- Since:
- 2.11
-
createNonBlockingByteArrayParser
public com.fasterxml.jackson.core.JsonParser createNonBlockingByteArrayParser() throws java.io.IOException
Factory method for constructing properly initializedJsonParser
to read content using non-blocking (asynchronous) mode. Parser is not managed (or "owned") by ObjectReader: caller is responsible for properly closing it once content reading is complete.- Throws:
java.io.IOException
- Since:
- 2.11
-
readValue
public <T> T readValue(com.fasterxml.jackson.core.JsonParser p) throws java.io.IOException
Method that binds content read using given parser, using configuration of this reader, including expected result type. Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
- Throws:
java.io.IOException
-
readValue
public <T> T readValue(com.fasterxml.jackson.core.JsonParser p, java.lang.Class<T> valueType) throws java.io.IOException
Convenience method that binds content read using given parser, using configuration of this reader, except that expected value type is specified with the call (instead of currently configured root type). Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
- Specified by:
readValue
in classcom.fasterxml.jackson.core.ObjectCodec
- Throws:
java.io.IOException
-
readValue
public <T> T readValue(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.core.type.TypeReference<T> valueTypeRef) throws java.io.IOException
Convenience method that binds content read using given parser, using configuration of this reader, except that expected value type is specified with the call (instead of currently configured root type). Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
- Specified by:
readValue
in classcom.fasterxml.jackson.core.ObjectCodec
- Throws:
java.io.IOException
-
readValue
public <T> T readValue(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.core.type.ResolvedType valueType) throws java.io.IOException
Convenience method that binds content read using given parser, using configuration of this reader, except that expected value type is specified with the call (instead of currently configured root type). Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
- Specified by:
readValue
in classcom.fasterxml.jackson.core.ObjectCodec
- Throws:
java.io.IOException
-
readValue
public <T> T readValue(com.fasterxml.jackson.core.JsonParser p, JavaType valueType) throws java.io.IOException
Type-safe overloaded method, basically alias forreadValue(JsonParser, ResolvedType)
.NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
- Throws:
java.io.IOException
-
readValues
public <T> java.util.Iterator<T> readValues(com.fasterxml.jackson.core.JsonParser p, java.lang.Class<T> valueType) throws java.io.IOException
Convenience method that is equivalent to:withType(valueType).readValues(p);
Method reads a sequence of Objects from parser stream. Sequence can be either root-level "unwrapped" sequence (without surrounding JSON array), or a sequence contained in a JSON Array. In either case
JsonParser
MUST point to the first token of the first element, OR not point to any token (in which case it is advanced to the next token). This means, specifically, that for wrapped sequences, parser MUST NOT point to the surroundingSTART_ARRAY
(one that contains values to read) but rather to the token following it which is the first token of the first value to read.NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
- Specified by:
readValues
in classcom.fasterxml.jackson.core.ObjectCodec
- Throws:
java.io.IOException
-
readValues
public <T> java.util.Iterator<T> readValues(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.core.type.TypeReference<T> valueTypeRef) throws java.io.IOException
Convenience method that is equivalent to:withType(valueTypeRef).readValues(p);
Method reads a sequence of Objects from parser stream. Sequence can be either root-level "unwrapped" sequence (without surrounding JSON array), or a sequence contained in a JSON Array. In either case
JsonParser
MUST point to the first token of the first element, OR not point to any token (in which case it is advanced to the next token). This means, specifically, that for wrapped sequences, parser MUST NOT point to the surroundingSTART_ARRAY
(one that contains values to read) but rather to the token following it which is the first token of the first value to read.NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
- Specified by:
readValues
in classcom.fasterxml.jackson.core.ObjectCodec
- Throws:
java.io.IOException
-
readValues
public <T> java.util.Iterator<T> readValues(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.core.type.ResolvedType valueType) throws java.io.IOException
Convenience method that is equivalent to:withType(valueType).readValues(p);
Method reads a sequence of Objects from parser stream. Sequence can be either root-level "unwrapped" sequence (without surrounding JSON array), or a sequence contained in a JSON Array. In either case
JsonParser
MUST point to the first token of the first element, OR not point to any token (in which case it is advanced to the next token). This means, specifically, that for wrapped sequences, parser MUST NOT point to the surroundingSTART_ARRAY
(one that contains values to read) but rather to the token following it which is the first token of the first value to read.NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
- Specified by:
readValues
in classcom.fasterxml.jackson.core.ObjectCodec
- Throws:
java.io.IOException
-
readValues
public <T> java.util.Iterator<T> readValues(com.fasterxml.jackson.core.JsonParser p, JavaType valueType) throws java.io.IOException
Convenience method that is equivalent to:withType(valueType).readValues(p);
Method reads a sequence of Objects from parser stream. Sequence can be either root-level "unwrapped" sequence (without surrounding JSON array), or a sequence contained in a JSON Array. In either case
JsonParser
MUST point to the first token of the first element, OR not point to any token (in which case it is advanced to the next token). This means, specifically, that for wrapped sequences, parser MUST NOT point to the surroundingSTART_ARRAY
(one that contains values to read) but rather to the token following it which is the first token of the first value to read.NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
- Throws:
java.io.IOException
-
createArrayNode
public JsonNode createArrayNode()
- Specified by:
createArrayNode
in classcom.fasterxml.jackson.core.ObjectCodec
-
createObjectNode
public JsonNode createObjectNode()
- Specified by:
createObjectNode
in classcom.fasterxml.jackson.core.ObjectCodec
-
missingNode
public JsonNode missingNode()
- Overrides:
missingNode
in classcom.fasterxml.jackson.core.TreeCodec
-
nullNode
public JsonNode nullNode()
- Overrides:
nullNode
in classcom.fasterxml.jackson.core.TreeCodec
-
treeAsTokens
public com.fasterxml.jackson.core.JsonParser treeAsTokens(com.fasterxml.jackson.core.TreeNode n)
- Specified by:
treeAsTokens
in classcom.fasterxml.jackson.core.ObjectCodec
-
readTree
public <T extends com.fasterxml.jackson.core.TreeNode> T readTree(com.fasterxml.jackson.core.JsonParser p) throws java.io.IOException
Convenience method that binds content read using given parser, using configuration of this reader, except that content is bound as JSON tree instead of configured root value type. ReturnsJsonNode
that represents the root of the resulting tree, if there was content to read, ornull
if no more content is accessible via passedJsonParser
.NOTE! Behavior with end-of-input (no more content) differs between this
readTree
method, and all other methods that take input source: latter will return "missing node", NOTnull
Note: if an object was specified with
withValueToUpdate(java.lang.Object)
, it will be ignored.NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.
- Specified by:
readTree
in classcom.fasterxml.jackson.core.ObjectCodec
- Throws:
java.io.IOException
-
writeTree
public void writeTree(com.fasterxml.jackson.core.JsonGenerator g, com.fasterxml.jackson.core.TreeNode rootNode)
- Specified by:
writeTree
in classcom.fasterxml.jackson.core.ObjectCodec
-
readValue
public <T> T readValue(java.io.InputStream src) throws java.io.IOException
Method that binds content read from given input source, using configuration of this reader. Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.- Parameters:
src
- Source to read content from- Throws:
java.io.IOException
-
readValue
public <T> T readValue(java.io.InputStream src, java.lang.Class<T> valueType) throws java.io.IOException
Same asreadValue(InputStream)
except that target value type overridden asvalueType
- Parameters:
src
- Source to read content fromvalueType
- Target type to bind content to- Throws:
java.io.IOException
- Since:
- 2.11
-
readValue
public <T> T readValue(java.io.Reader src) throws java.io.IOException
Method that binds content read from given input source, using configuration of this reader. Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.- Parameters:
src
- Source to read content from- Throws:
java.io.IOException
-
readValue
public <T> T readValue(java.io.Reader src, java.lang.Class<T> valueType) throws java.io.IOException
Same asreadValue(Reader)
except that target value type overridden asvalueType
- Parameters:
src
- Source to read content fromvalueType
- Target type to bind content to- Throws:
java.io.IOException
- Since:
- 2.11
-
readValue
public <T> T readValue(java.lang.String src) throws com.fasterxml.jackson.core.JsonProcessingException, JsonMappingException
Method that binds content read from given JSON string, using configuration of this reader. Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.- Parameters:
src
- String that contains content to read- Throws:
com.fasterxml.jackson.core.JsonProcessingException
JsonMappingException
-
readValue
public <T> T readValue(java.lang.String src, java.lang.Class<T> valueType) throws java.io.IOException
Same asreadValue(String)
except that target value type overridden asvalueType
- Parameters:
src
- String that contains content to readvalueType
- Target type to bind content to- Throws:
java.io.IOException
- Since:
- 2.11
-
readValue
public <T> T readValue(byte[] content) throws java.io.IOException
Method that binds content read from given byte array, using configuration of this reader. Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.- Parameters:
content
- Byte array that contains encoded content to read- Throws:
java.io.IOException
-
readValue
public <T> T readValue(byte[] content, java.lang.Class<T> valueType) throws java.io.IOException
Same asreadValue(byte[])
except that target value type overridden asvalueType
- Parameters:
content
- Byte array that contains encoded content to readvalueType
- Target type to bind content to- Throws:
java.io.IOException
- Since:
- 2.11
-
readValue
public <T> T readValue(byte[] buffer, int offset, int length) throws java.io.IOException
Method that binds content read from given byte array, using configuration of this reader. Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.- Parameters:
buffer
- Byte array that contains encoded content to readoffset
- Offset of the first content byte inbuffer
length
- Length of content inbuffer
, in bytes- Throws:
java.io.IOException
-
readValue
public <T> T readValue(byte[] buffer, int offset, int length, java.lang.Class<T> valueType) throws java.io.IOException
Same asreadValue(byte[],int,int)
except that target value type overridden asvalueType
- Parameters:
buffer
- Byte array that contains encoded content to readoffset
- Offset of the first content byte inbuffer
length
- Length of content inbuffer
, in bytesvalueType
- Target type to bind content to- Throws:
java.io.IOException
- Since:
- 2.11
-
readValue
public <T> T readValue(java.io.File src) throws java.io.IOException
Method that binds content read from givenFile
using configuration of this reader. Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.- Parameters:
src
- File that contains content to read- Throws:
java.io.IOException
-
readValue
public <T> T readValue(java.io.File src, java.lang.Class<T> valueType) throws java.io.IOException
Same asreadValue(File)
except that target value type overridden asvalueType
- Parameters:
src
- File that contains content to readvalueType
- Target type to bind content to- Throws:
java.io.IOException
- Since:
- 2.11
-
readValue
public <T> T readValue(java.net.URL src) throws java.io.IOException
Method that binds content read from given input source, using configuration of this reader. Value return is either newly constructed, or root value that was specified withwithValueToUpdate(Object)
.NOTE: handling of
URL
is delegated toJsonFactory.createParser(java.net.URL)
and usually simply callsURL.openStream()
, meaning no special handling is done. If different HTTP connection options are needed you will need to createInputStream
separately.- Throws:
java.io.IOException
-
readValue
public <T> T readValue(java.net.URL src, java.lang.Class<T> valueType) throws java.io.IOException
Same asreadValue(URL)
except that target value type overridden asvalueType
- Parameters:
src
- URL pointing to resource that contains content to readvalueType
- Target type to bind content to- Throws:
java.io.IOException
- Since:
- 2.11
-
readValue
public <T> T readValue(JsonNode content) throws java.io.IOException
Convenience method for converting results from given JSON tree into given value type. Basically short-cut for:objectReader.readValue(src.traverse())
- Parameters:
content
- Tree that contains content to convert- Throws:
java.io.IOException
-
readValue
public <T> T readValue(JsonNode content, java.lang.Class<T> valueType) throws java.io.IOException
Same asreadValue(JsonNode)
except that target value type overridden asvalueType
- Parameters:
content
- Tree that contains content to convertvalueType
- Target type to convert content to- Throws:
java.io.IOException
- Since:
- 2.11
-
readValue
public <T> T readValue(java.io.DataInput src) throws java.io.IOException
- Throws:
java.io.IOException
-
readValue
public <T> T readValue(java.io.DataInput content, java.lang.Class<T> valueType) throws java.io.IOException
Same asreadValue(DataInput)
except that target value type overridden asvalueType
- Parameters:
content
- DataInput that contains content to readvalueType
- Target type to bind content to- Throws:
java.io.IOException
- Since:
- 2.11
-
readTree
public JsonNode readTree(java.io.InputStream src) throws java.io.IOException
Method that reads content from given input source, using configuration of this reader, and binds it as JSON Tree. ReturnsJsonNode
that represents the root of the resulting tree, if there was content to read, or "missing node" (instance ofJsonNode
for whichJsonNode.isMissingNode()
returns true, and behaves otherwise similar to "null node") if no more content is accessible through passed-in input source.NOTE! Behavior with end-of-input (no more content) differs between this
readTree
method, andreadTree(JsonParser)
-- latter returnsnull
for "no content" case.Note that if an object was specified with a call to
withValueToUpdate(Object)
it will just be ignored; result is always a newly constructedJsonNode
instance.- Throws:
java.io.IOException
-
readTree
public JsonNode readTree(java.io.Reader src) throws java.io.IOException
Same asreadTree(InputStream)
except content accessed through passed-inReader
- Throws:
java.io.IOException
-
readTree
public JsonNode readTree(java.lang.String json) throws com.fasterxml.jackson.core.JsonProcessingException, JsonMappingException
Same asreadTree(InputStream)
except content read from passed-inString
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
JsonMappingException
-
readTree
public JsonNode readTree(byte[] json) throws java.io.IOException
Same asreadTree(InputStream)
except content read from passed-in byte array.- Throws:
java.io.IOException
-
readTree
public JsonNode readTree(byte[] json, int offset, int len) throws java.io.IOException
Same asreadTree(InputStream)
except content read from passed-in byte array.- Throws:
java.io.IOException
-
readTree
public JsonNode readTree(java.io.DataInput src) throws java.io.IOException
Same asreadTree(InputStream)
except content read using passed-inDataInput
.- Throws:
java.io.IOException
-
readValues
public <T> MappingIterator<T> readValues(com.fasterxml.jackson.core.JsonParser p) throws java.io.IOException
Method for reading sequence of Objects from parser stream.Sequence can be either root-level "unwrapped" sequence (without surrounding JSON array), or a sequence contained in a JSON Array. In either case
JsonParser
must point to the first token of the first element, OR not point to any token (in which case it is advanced to the next token). This means, specifically, that for wrapped sequences, parser MUST NOT point to the surroundingSTART_ARRAY
but rather to the token following it.- Throws:
java.io.IOException
-
readValues
public <T> MappingIterator<T> readValues(java.io.InputStream src) throws java.io.IOException
Method for reading sequence of Objects from parser stream.Sequence can be either wrapped or unwrapped root-level sequence: wrapped means that the elements are enclosed in JSON Array; and unwrapped that elements are directly accessed at main level. Assumption is that iff the first token of the document is
START_ARRAY
, we have a wrapped sequence; otherwise unwrapped. For wrapped sequences, leadingSTART_ARRAY
is skipped, so that for both cases, underlyingJsonParser
will point to what is expected to be the first token of the first element.Note that the wrapped vs unwrapped logic means that it is NOT possible to use this method for reading an unwrapped sequence of elements written as JSON Arrays: to read such sequences, one has to use
readValues(JsonParser)
, making sure parser points to the first token of the first element (i.e. the secondSTART_ARRAY
which is part of the first element).- Throws:
java.io.IOException
-
readValues
public <T> MappingIterator<T> readValues(java.io.Reader src) throws java.io.IOException
Overloaded version ofreadValue(InputStream)
.- Throws:
java.io.IOException
-
readValues
public <T> MappingIterator<T> readValues(java.lang.String json) throws java.io.IOException
Overloaded version ofreadValue(InputStream)
.- Parameters:
json
- String that contains JSON content to parse- Throws:
java.io.IOException
-
readValues
public <T> MappingIterator<T> readValues(byte[] src, int offset, int length) throws java.io.IOException
Overloaded version ofreadValue(InputStream)
.- Throws:
java.io.IOException
-
readValues
public final <T> MappingIterator<T> readValues(byte[] src) throws java.io.IOException
Overloaded version ofreadValue(InputStream)
.- Throws:
java.io.IOException
-
readValues
public <T> MappingIterator<T> readValues(java.io.File src) throws java.io.IOException
Overloaded version ofreadValue(InputStream)
.- Throws:
java.io.IOException
-
readValues
public <T> MappingIterator<T> readValues(java.net.URL src) throws java.io.IOException
Overloaded version ofreadValue(InputStream)
.NOTE: handling of
URL
is delegated toJsonFactory.createParser(java.net.URL)
and usually simply callsURL.openStream()
, meaning no special handling is done. If different HTTP connection options are needed you will need to createInputStream
separately.- Parameters:
src
- URL to read to access JSON content to parse.- Throws:
java.io.IOException
-
readValues
public <T> MappingIterator<T> readValues(java.io.DataInput src) throws java.io.IOException
- Throws:
java.io.IOException
- Since:
- 2.8
-
treeToValue
public <T> T treeToValue(com.fasterxml.jackson.core.TreeNode n, java.lang.Class<T> valueType) throws com.fasterxml.jackson.core.JsonProcessingException
- Specified by:
treeToValue
in classcom.fasterxml.jackson.core.ObjectCodec
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
writeValue
public void writeValue(com.fasterxml.jackson.core.JsonGenerator gen, java.lang.Object value) throws java.io.IOException
- Specified by:
writeValue
in classcom.fasterxml.jackson.core.ObjectCodec
- Throws:
java.io.IOException
-
_bind
protected java.lang.Object _bind(com.fasterxml.jackson.core.JsonParser p, java.lang.Object valueToUpdate) throws java.io.IOException
Actual implementation of value reading+binding operation.- Throws:
java.io.IOException
-
_bindAndClose
protected java.lang.Object _bindAndClose(com.fasterxml.jackson.core.JsonParser p0) throws java.io.IOException
- Throws:
java.io.IOException
-
_bindAndCloseAsTree
protected final JsonNode _bindAndCloseAsTree(com.fasterxml.jackson.core.JsonParser p0) throws java.io.IOException
- Throws:
java.io.IOException
-
_bindAsTree
protected final JsonNode _bindAsTree(com.fasterxml.jackson.core.JsonParser p) throws java.io.IOException
- Throws:
java.io.IOException
-
_bindAsTreeOrNull
protected final JsonNode _bindAsTreeOrNull(com.fasterxml.jackson.core.JsonParser p) throws java.io.IOException
Same as_bindAsTree(com.fasterxml.jackson.core.JsonParser)
except end-of-input is reported by returningnull
, not "missing node"- Throws:
java.io.IOException
-
_bindAndReadValues
protected <T> MappingIterator<T> _bindAndReadValues(com.fasterxml.jackson.core.JsonParser p) throws java.io.IOException
- Throws:
java.io.IOException
- Since:
- 2.1
-
_considerFilter
protected com.fasterxml.jackson.core.JsonParser _considerFilter(com.fasterxml.jackson.core.JsonParser p, boolean multiValue)
Consider filter when creating JsonParser.
-
_verifyNoTrailingTokens
protected final void _verifyNoTrailingTokens(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, JavaType bindType) throws java.io.IOException
- Throws:
java.io.IOException
- Since:
- 2.9
-
_detectBindAndClose
protected java.lang.Object _detectBindAndClose(byte[] src, int offset, int length) throws java.io.IOException
- Throws:
java.io.IOException
-
_detectBindAndClose
protected java.lang.Object _detectBindAndClose(DataFormatReaders.Match match, boolean forceClosing) throws java.io.IOException
- Throws:
java.io.IOException
-
_detectBindAndReadValues
protected <T> MappingIterator<T> _detectBindAndReadValues(DataFormatReaders.Match match, boolean forceClosing) throws java.io.IOException
- Throws:
java.io.IOException
-
_detectBindAndCloseAsTree
protected JsonNode _detectBindAndCloseAsTree(java.io.InputStream in) throws java.io.IOException
- Throws:
java.io.IOException
-
_reportUnkownFormat
protected void _reportUnkownFormat(DataFormatReaders detector, DataFormatReaders.Match match) throws com.fasterxml.jackson.core.JsonProcessingException
Method called to indicate that format detection failed to detect format of given input- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
_verifySchemaType
protected void _verifySchemaType(com.fasterxml.jackson.core.FormatSchema schema)
- Since:
- 2.2
-
createDeserializationContext
protected DefaultDeserializationContext createDeserializationContext(com.fasterxml.jackson.core.JsonParser p)
Internal helper method called to create an instance ofDeserializationContext
for deserializing a single root value. Can be overridden if a custom context is needed.
-
createDummyDeserializationContext
protected DefaultDeserializationContext createDummyDeserializationContext()
-
_inputStream
protected java.io.InputStream _inputStream(java.net.URL src) throws java.io.IOException
- Throws:
java.io.IOException
-
_inputStream
protected java.io.InputStream _inputStream(java.io.File f) throws java.io.IOException
- Throws:
java.io.IOException
-
_reportUndetectableSource
protected void _reportUndetectableSource(java.lang.Object src) throws com.fasterxml.jackson.core.JsonParseException
- Throws:
com.fasterxml.jackson.core.JsonParseException
-
_findRootDeserializer
protected JsonDeserializer<java.lang.Object> _findRootDeserializer(DeserializationContext ctxt) throws JsonMappingException
Method called to locate deserializer for the passed root-level value.- Throws:
JsonMappingException
-
_findTreeDeserializer
protected JsonDeserializer<java.lang.Object> _findTreeDeserializer(DeserializationContext ctxt) throws JsonMappingException
- Throws:
JsonMappingException
- Since:
- 2.6
-
_prefetchRootDeserializer
protected JsonDeserializer<java.lang.Object> _prefetchRootDeserializer(JavaType valueType)
Method called to locate deserializer ahead of time, if permitted by configuration. Method also is NOT to throw an exception if access fails.
-
_jsonNodeType
protected final JavaType _jsonNodeType()
- Since:
- 2.10
-
_assertNotNull
protected final void _assertNotNull(java.lang.String paramName, java.lang.Object src)
-
-