Top Description Fields Constructors Methods
tools.jackson.databind

public Class ObjectReader

extends Object
implements Versioned, TreeCodec
Class Inheritance
All Implemented Interfaces
tools.jackson.core.TreeCodec, tools.jackson.core.Versioned
Imports
java.io.*, java.nio.file.Files, .Path, java.util.*, java.util.concurrent.ConcurrentHashMap, tools.jackson.core.*, tools.jackson.core.exc.JacksonIOException, tools.jackson.core.filter.FilteringParserDelegate, .JsonPointerBasedFilter, .TokenFilter, .TokenFilter.Inclusion, tools.jackson.core.type.ResolvedType, .TypeReference, tools.jackson.databind.cfg.ContextAttributes, .DatatypeFeature, .DeserializationContexts, tools.jackson.databind.deser.DeserializationContextExt, .DeserializationProblemHandler, tools.jackson.databind.node.ArrayNode, .JsonNodeFactory, .ObjectNode, .TreeTraversingParser, tools.jackson.databind.type.SimpleType, .TypeFactory, tools.jackson.databind.util.ClassUtil, .TokenBuffer

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 by users. It is left as non-final mostly to allow frameworks that require byte code generation for proxying and similar use cases, but there is no expectation that functionality should be extended by sub-classing.

Field Summary

Modifier and TypeField and Description
protected final DeserializationConfig
_config

General serialization configuration settings; while immutable, can use copy-constructor to create modified instances as necessary.

protected final DeserializationContexts
_contexts

Blueprint instance of deserialization context; used for creating actual instance when needed.

private final TokenFilter
_filter

Filter to be consider for JsonParser.

protected final InjectableValues
_injectableValues

Values that can be injected during deserialization, if any.

protected final TokenStreamFactory
_parserFactory

Factory used for constructing JsonParsers

protected final ValueDeserializer<Object>
_rootDeserializer

We may pre-fetch deserializer as soon as _valueType is known, and if so, reuse it afterwards.

protected final ConcurrentHashMap<JavaType, ValueDeserializer<Object>>
_rootDeserializers

Root-level cached deserializers.

protected final FormatSchema
_schema

When using data format that uses a schema, schema is passed to parser.

protected final boolean
_unwrapRoot

Flag that indicates whether root values are expected to be unwrapped or not

protected final Object
_valueToUpdate

Instance to update with data binding; if any.

protected final JavaType
_valueType

Declared type of value to instantiate during deserialization.

protected static final JavaType

Constructor Summary

AccessConstructor and Description
protected
ObjectReader(ObjectMapper mapper, DeserializationConfig config)

Constructor used by ObjectMapper for initial instantiation

protected
ObjectReader(ObjectMapper mapper, DeserializationConfig config, JavaType valueType, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues)

Constructor called when a root deserializer should be fetched based on other configuration.

protected
ObjectReader(ObjectReader base, DeserializationConfig config, JavaType valueType, ValueDeserializer<Object> rootDeser, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues)

Copy constructor used for building variations.

protected
ObjectReader(ObjectReader base, DeserializationConfig config)

Copy constructor used when modifying simple feature flags

protected

Method Summary

Modifier and TypeMethod and Description
protected final void
_assertNotNull(String paramName, Object src)

protected Object
_bind(DeserializationContextExt ctxt, JsonParser p, Object valueToUpdate)

Actual implementation of value reading+binding operation.

protected Object
protected final JsonNode
protected <T> MappingIterator<T>
protected final JsonNode
protected final JsonNode
_bindAsTreeOrNull(DeserializationContextExt ctxt, JsonParser p)

Same as _bindAsTree except end-of-input is reported by returning null, not "missing node"

protected JsonParser
_considerFilter(final JsonParser p, boolean multiValue)

Consider filter when creating JsonParser.

protected DeserializationContextExt
_deserializationContext()

Internal helper method called to create an instance of DeserializationContext for deserializing a single root value.

protected DeserializationContextExt
protected ValueDeserializer<Object>
_findRootDeserializer(DeserializationContext ctxt)

Method called to locate deserializer for the passed root-level value.

protected ValueDeserializer<Object>
protected void
_initForMultiRead(DeserializationContextExt ctxt, JsonParser p)

Alternative to _initForReading 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 JsonToken
protected InputStream
protected InputStream
protected ObjectReader
_new(ObjectReader base, DeserializationConfig config)

Factory method called by various "withXxx()" methods

protected ObjectReader
_new(ObjectReader base, DeserializationConfig config, JavaType valueType, ValueDeserializer<Object> rootDeser, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues)

Factory method called by various "withXxx()" methods

protected <T> MappingIterator<T>
_newIterator(JsonParser p, DeserializationContext ctxt, ValueDeserializer<?> deser, boolean parserManaged)

Factory method used to create MappingIterator instances; either default, or custom subtype.

protected ValueDeserializer<Object>
_prefetchRootDeserializer(JavaType valueType)

Method called to locate deserializer ahead of time, if permitted by configuration.

protected final void
protected void
protected final ObjectReader
public ObjectReader
at(String pointerExpr)

Convenience method to bind from JsonPointer.

public ObjectReader
at(JsonPointer pointer)

Convenience method to bind from JsonPointer JsonPointerBasedFilter is registered and will be used for parsing later.

public JsonNode
public ArrayNode
public JsonParser
createNonBlockingByteArrayParser()

Factory method for constructing non-blocking JsonParser that is properly wired to allow configuration access (and, if relevant for parser, callbacks): essentially constructs a ObjectReadContext and then calls TokenStreamFactory#createNonBlockingByteArrayParser(ObjectReadContext).

public JsonParser
createNonBlockingByteBufferParser()

Factory method for constructing non-blocking JsonParser that is properly wired to allow configuration access (and, if relevant for parser, callbacks): essentially constructs a ObjectReadContext and then calls TokenStreamFactory#createNonBlockingByteBufferParser(ObjectReadContext).

public ObjectNode
public JsonParser
createParser(File src)

Factory method for constructing JsonParser that is properly wired to allow callbacks for deserialization: basically constructs a ObjectReadContext and then calls TokenStreamFactory#createParser(ObjectReadContext, java.io.File).

public JsonParser
createParser(Path src)

Factory method for constructing JsonParser that is properly wired to allow callbacks for deserialization: basically constructs a ObjectReadContext and then calls TokenStreamFactory#createParser(ObjectReadContext, Path).

public JsonParser
createParser(InputStream src)

Factory method for constructing JsonParser that is properly wired to allow callbacks for deserialization: basically constructs a ObjectReadContext and then calls TokenStreamFactory#createParser(ObjectReadContext, InputStream).

public JsonParser
createParser(Reader src)

Factory method for constructing JsonParser that is properly wired to allow callbacks for deserialization: basically constructs a ObjectReadContext and then calls TokenStreamFactory#createParser(ObjectReadContext, Reader).

public JsonParser
createParser(byte[] content)

Factory method for constructing JsonParser that is properly wired to allow callbacks for deserialization: basically constructs a ObjectReadContext and then calls TokenStreamFactory#createParser(ObjectReadContext, byte[]).

public JsonParser
createParser(byte[] content, int offset, int len)

Factory method for constructing JsonParser that is properly wired to allow callbacks for deserialization: basically constructs a ObjectReadContext and then calls TokenStreamFactory#createParser(ObjectReadContext, byte[], int, int).

public JsonParser
createParser(String content)

Factory method for constructing JsonParser that is properly wired to allow callbacks for deserialization: basically constructs a ObjectReadContext and then calls TokenStreamFactory#createParser(ObjectReadContext, String).

public JsonParser
createParser(char[] content)

Factory method for constructing JsonParser that is properly wired to allow callbacks for deserialization: basically constructs a ObjectReadContext and then calls TokenStreamFactory#createParser(ObjectReadContext, char[]).

public JsonParser
createParser(char[] content, int offset, int len)

Factory method for constructing JsonParser that is properly wired to allow callbacks for deserialization: basically constructs a ObjectReadContext and then calls TokenStreamFactory#createParser(ObjectReadContext, char[], int, int).

public JsonParser
createParser(DataInput content)

Factory method for constructing JsonParser that is properly wired to allow callbacks for deserialization: basically constructs a ObjectReadContext and then calls TokenStreamFactory#createParser(ObjectReadContext, DataInput).

public ObjectReader
forType(JavaType valueType)

Method for constructing a new reader instance that is configured to data bind into specified type.

public ObjectReader
forType(Class<?> valueType)

Method for constructing a new reader instance that is configured to data bind into specified type.

public ObjectReader
forType(TypeReference<?> valueTypeRef)

Method for constructing a new reader instance that is configured to data bind into specified type.

public ContextAttributes
public DeserializationConfig
public InjectableValues
public TypeFactory
getTypeFactory()
Deprecated Since 3.0 use typeFactory

public JavaType
public boolean
public boolean
public boolean
public boolean
public JsonNode
public JsonNode
public TokenStreamFactory
public JsonNode
readTree(JsonParser p)

Implements tools.jackson.core.TreeCodec.readTree.

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.

public JsonNode
readTree(InputStream src)

Method that reads content from given input source, using configuration of this reader, and binds it as JSON Tree.

public JsonNode
readTree(Reader src)

Same as readTree(InputStream) except content accessed through passed-in Reader

public JsonNode
readTree(String content)

Same as readTree(InputStream) except content read from passed-in String

public JsonNode
readTree(byte[] content)

Same as readTree(InputStream) except content read from passed-in byte array.

public JsonNode
readTree(byte[] content, int offset, int len)

Same as readTree(InputStream) except content read from passed-in byte array.

public JsonNode
readTree(DataInput content)

Same as readTree(InputStream) except content read using passed-in DataInput.

public JsonNode
readTree(TokenBuffer src)

Same as readTree(InputStream) except content read using passed-in TokenBuffer.

public <T> T
readValue(JsonParser p)

Method that binds content read using given parser, using configuration of this reader, including expected result type.

public <T> T
readValue(InputStream in)

Method that binds content read from given input source, using configuration of this reader.

public <T> T
readValue(Reader
Source to read content from
r
)

Method that binds content read from given input source, using configuration of this reader.

public <T> T
readValue(String
String that contains content to read
content
)

Method that binds content read from given JSON string, using configuration of this reader.

public <T> T
readValue(byte[]
Byte array that contains encoded content to read
content
)

Method that binds content read from given byte array, using configuration of this reader.

public <T> T
readValue(byte[]
Byte array that contains encoded content to read
buffer
,
int
Offset of the first content byte in buffer
offset
,
int
Length of content in buffer, in bytes
length
)

Method that binds content read from given byte array, using configuration of this reader.

public <T> T
readValue(File
File that contains content to read
f
)

Method that binds content read from given File using configuration of this reader.

public <T> T
readValue(Path
Path that contains content to read
path
)

Method that binds content read from given Path using configuration of this reader.

public <T> T
readValue(JsonNode
Tree that contains content to convert
node
)

Convenience method for converting results from given JSON tree into given value type.

public <T> T
public <T> T
readValue(TokenBuffer
TokenBuffer that contains content to read
src
)

Method that binds content read from given TokenBuffer using configuration of this reader.

public <T> Iterator<T>
readValues(JsonParser p, Class<T> valueType)

Convenience method that is equivalent to:

   withType(valueType).readValues(p);
public <T> Iterator<T>
readValues(JsonParser p, TypeReference<T> valueTypeRef)

Convenience method that is equivalent to:

   withType(valueTypeRef).readValues(p);
public <T> Iterator<T>
readValues(JsonParser p, ResolvedType valueType)

Convenience method that is equivalent to:

   withType(valueType).readValues(p);
public <T> Iterator<T>
readValues(JsonParser p, JavaType valueType)

Convenience method that is equivalent to:

   withType(valueType).readValues(p);
public <T> MappingIterator<T>
readValues(JsonParser p)

Method for reading sequence of Objects from parser stream.

public <T> MappingIterator<T>
readValues(InputStream src)

Method for reading sequence of Objects from parser stream.

public <T> MappingIterator<T>
readValues(Reader src)

Overloaded version of readValue(InputStream).

public <T> MappingIterator<T>
readValues(String
String that contains JSON content to parse
content
)

Overloaded version of readValue(InputStream).

public <T> MappingIterator<T>
readValues(byte[] content, int offset, int length)

Overloaded version of readValue(InputStream).

public final <T> MappingIterator<T>
readValues(byte[] content)

Overloaded version of readValue(InputStream).

public <T> MappingIterator<T>
readValues(File src)

Overloaded version of readValue(InputStream).

public <T> MappingIterator<T>
readValues(Path src)

Overloaded version of readValues(InputStream).

public <T> MappingIterator<T>
public <T> MappingIterator<T>
public JsonNode
public JsonParser
protected JsonParser
public <T> T
treeToValue(TreeNode n, Class<T> valueType)

public <T> T
treeToValue(TreeNode n, JavaType valueType)

Same as treeToValue(TreeNode, Class) but with type-resolved target value type.

public TypeFactory
public Version
version()

Implements tools.jackson.core.Versioned.version.

Method that will return version information stored in and read from jar that contains this class.

public ObjectReader
with(DeserializationFeature feature)

Method for constructing a new reader instance that is configured with specified feature enabled.

public ObjectReader
with(DeserializationFeature first, DeserializationFeature... other)

Method for constructing a new reader instance that is configured with specified features enabled.

public ObjectReader
with(DatatypeFeature feature)

Method for constructing a new reader instance that is configured with specified feature enabled.

public ObjectReader
with(StreamReadFeature feature)

Method for constructing a new reader instance that is configured with specified feature enabled.

public ObjectReader
with(FormatFeature feature)

Method for constructing a new reader instance that is configured with specified feature enabled.

public ObjectReader
with(DeserializationConfig config)

Mutant factory method that will construct a new instance that has specified underlying DeserializationConfig.

public ObjectReader
with(InjectableValues injectableValues)

Method for constructing a new instance with configuration that uses passed InjectableValues to provide injectable values.

public ObjectReader
with(JsonNodeFactory f)

Method for constructing a new reader instance with configuration that uses passed JsonNodeFactory for constructing JsonNode instances.

public ObjectReader
with(FormatSchema schema)

Method for constructing a new instance with configuration that passes specified FormatSchema to JsonParser that is constructed for parsing content.

public ObjectReader
public ObjectReader
public ObjectReader
with(Base64Variant defaultBase64)

public ObjectReader

Returns:

ObjectReader instance with specified default attributes (which is usually a newly constructed reader instance with otherwise identical settings)
with
(ContextAttributes
Default ContextAttributes to use with a reader
attrs
)

Mutant factory for overriding set of (default) attributes for ObjectReader to use.

public ObjectReader
public ObjectReader
withAttributes(Map<?, ?> attrs)

public ObjectReader
withFeatures(DeserializationFeature... features)

Method for constructing a new reader instance that is configured with specified features enabled.

public ObjectReader
withFeatures(DatatypeFeature... features)

Method for constructing a new reader instance that is configured with specified features enabled.

public ObjectReader
withFeatures(StreamReadFeature... features)

Method for constructing a new reader instance that is configured with specified features enabled.

public ObjectReader
withFeatures(FormatFeature... features)

Method for constructing a new reader instance that is configured with specified features enabled.

public ObjectReader
public ObjectReader
without(DeserializationFeature feature)

Method for constructing a new reader instance that is configured with specified feature disabled.

public ObjectReader
without(DeserializationFeature first, DeserializationFeature... other)

Method for constructing a new reader instance that is configured with specified features disabled.

public ObjectReader
without(DatatypeFeature feature)

Method for constructing a new reader instance that is configured with specified feature disabled.

public ObjectReader
without(StreamReadFeature feature)

Method for constructing a new reader instance that is configured with specified feature disabled.

public ObjectReader
without(FormatFeature feature)

Method for constructing a new reader instance that is configured with specified feature disabled.

public ObjectReader
public ObjectReader
withoutFeatures(DeserializationFeature... features)

Method for constructing a new reader instance that is configured with specified features disabled.

public ObjectReader
withoutFeatures(DatatypeFeature... features)

Method for constructing a new reader instance that is configured with specified features disabled.

public ObjectReader
withoutFeatures(StreamReadFeature... features)

Method for constructing a new reader instance that is configured with specified features disabled.

public ObjectReader
withoutFeatures(FormatFeature... features)

Method for constructing a new reader instance that is configured with specified features disabled.

public ObjectReader
withoutRootName()

Convenience method that is same as calling: withRootName("") which will forcibly prevent use of root name wrapping when writing values with this ObjectReader.

public ObjectReader
withRootName(String rootName)

Method for constructing a new instance with configuration that specifies what root name to expect for "root name unwrapping".

public ObjectReader
public ObjectReader
withValueToUpdate(Object value)

Method for constructing a new instance with configuration that updates passed Object (as root value), instead of constructing a new value.

public ObjectReader
withView(Class<?> activeView)

Method for constructing a new instance with configuration that uses specified View for filtering.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait