Class ObjectReader
- All Implemented Interfaces:
Versioned
,Serializable
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:
-
Field Summary
Modifier and TypeFieldDescriptionprotected final DeserializationConfig
General serialization configuration settings; while immutable, can use copy-constructor to create modified instances as necessary.protected final DefaultDeserializationContext
Blueprint instance of deserialization context; used for creating actual instance when needed.protected final DataFormatReaders
Optional detector used for auto-detecting data format that byte-based input uses.protected final InjectableValues
Values that can be injected during deserialization, if any.protected JavaType
protected final JsonFactory
Factory used for constructingJsonGenerator
sprotected final JsonDeserializer<Object>
We may pre-fetch deserializer as soon as_valueType
is known, and if so, reuse it afterwards.protected final ConcurrentHashMap<JavaType,
JsonDeserializer<Object>> Root-level cached deserializers.protected final FormatSchema
When using data format that uses a schema, schema is passed to parser.protected final boolean
Flag that indicates whether root values are expected to be unwrapped or notprotected final Object
Instance to update with data binding; if any.protected final JavaType
Declared type of value to instantiate during deserialization. -
Constructor Summary
ModifierConstructorDescriptionprotected
ObjectReader
(ObjectMapper mapper, DeserializationConfig config) Constructor used byObjectMapper
for initial instantiationprotected
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, TokenFilter filter) protected
ObjectReader
(ObjectReader base, JsonFactory f) protected
ObjectReader
(ObjectReader base, DeserializationConfig config) Copy constructor used when modifying simple feature flagsprotected
ObjectReader
(ObjectReader base, DeserializationConfig config, JavaType valueType, JsonDeserializer<Object> rootDeser, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues, DataFormatReaders dataFormatReaders) Copy constructor used for building variations. -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
_assertNotNull
(String paramName, Object src) protected Object
_bind
(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
Same as_bindAsTree(edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.core.JsonParser)
except end-of-input is reported by returningnull
, not "missing node"protected JsonParser
_considerFilter
(JsonParser p, boolean multiValue) Consider filter when creating JsonParser.protected Object
_detectBindAndClose
(byte[] src, int offset, int length) protected Object
_detectBindAndClose
(DataFormatReaders.Match match, boolean forceClosing) protected JsonNode
protected <T> MappingIterator<T>
_detectBindAndReadValues
(DataFormatReaders.Match match, boolean forceClosing) protected JsonDeserializer<Object>
Method called to locate deserializer for the passed root-level value.protected JsonDeserializer<Object>
protected void
Alternative to_initForReading(edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.DeserializationContext, edu.internet2.middleware.grouperClientExt.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 JsonToken
protected InputStream
_inputStream
(File f) protected InputStream
_inputStream
(URL src) protected final JavaType
protected ObjectReader
_new
(ObjectReader base, 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<Object> rootDeser, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues, DataFormatReaders dataFormatReaders) Overridable factory method called by various "withXxx()" methodsprotected <T> MappingIterator<T>
_newIterator
(JsonParser p, DeserializationContext ctxt, JsonDeserializer<?> deser, boolean parserManaged) Factory method used to createMappingIterator
instances; either default, or custom subtype.protected JsonDeserializer<Object>
_prefetchRootDeserializer
(JavaType valueType) Method called to locate deserializer ahead of time, if permitted by configuration.protected void
protected void
_reportUnkownFormat
(DataFormatReaders detector, DataFormatReaders.Match match) Method called to indicate that format detection failed to detect format of given inputprotected final void
_verifyNoTrailingTokens
(JsonParser p, DeserializationContext ctxt, JavaType bindType) protected void
_verifySchemaType
(FormatSchema schema) protected ObjectReader
_with
(DeserializationConfig newConfig) at
(JsonPointer pointer) Convenience method to bind fromJsonPointer
JsonPointerBasedFilter
is registered and will be used for parsing later.Convenience method to bind fromJsonPointer
.Method for construct root level Array nodes for Tree Model instances.protected DefaultDeserializationContext
Internal helper method called to create an instance ofDeserializationContext
for deserializing a single root value.protected DefaultDeserializationContext
Factory method for constructing properly initializedJsonParser
to read content using non-blocking (asynchronous) mode.Method for construct root level Object nodes for Tree Model instances.createParser
(byte[] content) Factory method for constructing properly initializedJsonParser
to read content from specified byte array.createParser
(byte[] content, int offset, int len) Factory method for constructing properly initializedJsonParser
to read content from specified byte array.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.createParser
(char[] content, int offset, int len) Factory method for constructing properly initializedJsonParser
to read content from specified character array.createParser
(DataInput content) Factory method for constructing properly initializedJsonParser
to read content using specifiedDataInput
.createParser
(File src) Factory method for constructing properly initializedJsonParser
to read content from specifiedFile
.Factory method for constructing properly initializedJsonParser
to read content using specifiedInputStream
.Factory method for constructing properly initializedJsonParser
to read content using specifiedReader
.createParser
(String content) Factory method for constructing properly initializedJsonParser
to read content from specified String.createParser
(URL src) Factory method for constructing properly initializedJsonParser
to read content from specifiedFile
.forType
(TypeReference<?> valueTypeRef) Method for constructing a new reader instance that is configured to data bind into specified type.Method for constructing a new reader instance that is configured to data bind into specified type.Method for constructing a new reader instance that is configured to data bind into specified type.Accessor for finding underlying data format factory (JsonFactory
) codec will use for data binding.boolean
boolean
boolean
boolean
boolean
nullNode()
readTree
(byte[] json) Same asreadTree(InputStream)
except content read from passed-in byte array.readTree
(byte[] json, int offset, int len) Same asreadTree(InputStream)
except content read from passed-in byte array.<T extends TreeNode>
TConvenience 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.Same asreadTree(InputStream)
except content read using passed-inDataInput
.readTree
(InputStream src) Method that reads content from given input source, using configuration of this reader, and binds it as JSON Tree.Same asreadTree(InputStream)
except content accessed through passed-inReader
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
Same asreadValue(byte[],int,int)
except that target value type overridden asvalueType
<T> T
Same asreadValue(byte[])
except that target value type overridden asvalueType
<T> T
Method that binds content read using given parser, using configuration of this reader, including expected result type.<T> T
readValue
(JsonParser p, 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
(JsonParser p, 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
(JsonParser p, JavaType valueType) Type-safe overloaded method, basically alias forreadValue(JsonParser, ResolvedType)
.<T> T
readValue
(JsonParser p, 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
Convenience method for converting results from given JSON tree into given value type.<T> T
Same asreadValue(JsonNode)
except that target value type overridden asvalueType
<T> T
<T> T
Same asreadValue(DataInput)
except that target value type overridden asvalueType
<T> T
Method that binds content read from givenFile
using configuration of this reader.<T> T
Same asreadValue(File)
except that target value type overridden asvalueType
<T> T
readValue
(InputStream src) Method that binds content read from given input source, using configuration of this reader.<T> T
readValue
(InputStream src, Class<T> valueType) Same asreadValue(InputStream)
except that target value type overridden asvalueType
<T> T
Method that binds content read from given input source, using configuration of this reader.<T> T
Same asreadValue(Reader)
except that target value type overridden asvalueType
<T> T
Method that binds content read from given JSON string, using configuration of this reader.<T> T
Same asreadValue(String)
except that target value type overridden asvalueType
<T> T
Method that binds content read from given input source, using configuration of this reader.<T> T
Same asreadValue(URL)
except that target value type overridden asvalueType
final <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>
Method for reading sequence of Objects from parser stream.<T> Iterator<T>
readValues
(JsonParser p, ResolvedType valueType) Convenience method that is equivalent to:<T> Iterator<T>
readValues
(JsonParser p, TypeReference<T> valueTypeRef) Convenience method that is equivalent to:<T> Iterator<T>
readValues
(JsonParser p, JavaType valueType) Convenience method that is equivalent to:<T> Iterator<T>
readValues
(JsonParser p, Class<T> valueType) Convenience method that is equivalent to:<T> MappingIterator<T>
readValues
(DataInput src) <T> MappingIterator<T>
readValues
(File src) Overloaded version ofreadValue(InputStream)
.<T> MappingIterator<T>
readValues
(InputStream src) Method for reading sequence of Objects from parser stream.<T> MappingIterator<T>
readValues
(Reader src) Overloaded version ofreadValue(InputStream)
.<T> MappingIterator<T>
readValues
(String json) Overloaded version ofreadValue(InputStream)
.<T> MappingIterator<T>
readValues
(URL src) Overloaded version ofreadValue(InputStream)
.Method for constructing aJsonParser
for reading contents of a JSON tree, as if it was external serialized JSON content.<T> T
treeToValue
(TreeNode n, JavaType valueType) Same astreeToValue(TreeNode, Class)
but with type-resolved target value type.<T> T
treeToValue
(TreeNode n, Class<T> valueType) Convenience method for converting given JSON tree into instance of specified value type.version()
Method that will return version information stored in and read from jar that contains this class.with
(Base64Variant defaultBase64) with
(FormatFeature feature) Method for constructing a new reader instance that is configured with specified feature enabled.with
(FormatSchema schema) Method for constructing a new instance with configuration that passes specifiedFormatSchema
toJsonParser
that is constructed for parsing content.with
(JsonFactory f) Method for constructing a new reader instance with configuration that uses passedJsonFactory
for constructing underlying Readers.with
(JsonParser.Feature feature) Method for constructing a new reader instance that is configured with specified feature enabled.with
(StreamReadFeature feature) Method for constructing a new reader instance that is configured with specified feature enabled.with
(ContextAttributes attrs) with
(DatatypeFeature feature) Method for constructing a new reader instance that is configured with specified feature enabled.with
(DeserializationConfig config) Mutant factory method that will construct a new instance that has specified underlyingDeserializationConfig
.with
(DeserializationFeature feature) Method for constructing a new reader instance that is configured with specified feature enabled.with
(DeserializationFeature first, DeserializationFeature... other) Method for constructing a new reader instance that is configured with specified features enabled.with
(InjectableValues injectableValues) Method for constructing a new instance with configuration that uses passedInjectableValues
to provide injectable values.Method for constructing a new reader instance with configuration that uses passedJsonNodeFactory
for constructingJsonNode
instances.withAttribute
(Object key, Object value) withAttributes
(Map<?, ?> attrs) withFeatures
(FormatFeature... features) Method for constructing a new reader instance that is configured with specified features enabled.withFeatures
(JsonParser.Feature... features) Method for constructing a new reader instance that is configured with specified features enabled.withFeatures
(DatatypeFeature... features) Method for constructing a new reader instance that is configured with specified features enabled.withFeatures
(DeserializationFeature... features) Method for constructing a new reader instance that is configured with specified features enabled.withFormatDetection
(DataFormatReaders readers) Fluent factory method for constructing a reader that will try to auto-detect underlying data format, using specifiedDataFormatReaders
.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).without
(FormatFeature feature) Method for constructing a new reader instance that is configured with specified feature disabled.without
(JsonParser.Feature feature) Method for constructing a new reader instance that is configured with specified feature disabled.without
(StreamReadFeature feature) Method for constructing a new reader instance that is configured with specified feature disabled.without
(DatatypeFeature feature) Method for constructing a new reader instance that is configured with specified feature disabled.without
(DeserializationFeature feature) Method for constructing a new reader instance that is configured with specified feature disabled.without
(DeserializationFeature first, DeserializationFeature... other) Method for constructing a new reader instance that is configured with specified features disabled.withoutAttribute
(Object key) withoutFeatures
(FormatFeature... features) Method for constructing a new reader instance that is configured with specified features disabled.withoutFeatures
(JsonParser.Feature... features) Method for constructing a new reader instance that is configured with specified features disabled.withoutFeatures
(DatatypeFeature... features) Method for constructing a new reader instance that is configured with specified features disabled.withoutFeatures
(DeserializationFeature... features) Method for constructing a new reader instance that is configured with specified features disabled.Convenience method that is same as calling:withRootName("")
which will forcibly prevent use of root name wrapping when writing values with thisObjectReader
.withRootName
(PropertyName rootName) withRootName
(String rootName) Method for constructing a new instance with configuration that specifies what root name to expect for "root name unwrapping".withType
(TypeReference<?> valueTypeRef) Deprecated.Deprecated.since 2.5 UseforType(JavaType)
insteadDeprecated.since 2.5 UseforType(Class)
insteadDeprecated.since 2.5 UseforType(Class)
insteadwithValueToUpdate
(Object value) Method for constructing a new instance with configuration that updates passed Object (as root value), instead of constructing a new value.Method for constructing a new instance with configuration that uses specified View for filtering.void
writeTree
(JsonGenerator g, TreeNode rootNode) Method for serializing JSON content from given Tree instance, using specified generator.void
writeValue
(JsonGenerator gen, Object value) Method to serialize given Java Object, using generator provided.Methods inherited from class edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.core.ObjectCodec
getJsonFactory
-
Field Details
-
_config
General serialization configuration settings; while immutable, can use copy-constructor to create modified instances as necessary. -
_context
Blueprint instance of deserialization context; used for creating actual instance when needed. -
_parserFactory
Factory used for constructingJsonGenerator
s -
_unwrapRoot
protected final boolean _unwrapRootFlag that indicates whether root values are expected to be unwrapped or not -
_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
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
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
When using data format that uses a schema, schema is passed to parser. -
_injectableValues
Values that can be injected during deserialization, if any. -
_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), aStreamReadException
will be thrown).- Since:
- 2.1
-
_rootDeserializers
Root-level cached deserializers. Passed byObjectMapper
, shared with it. -
_jsonNodeType
-
-
Constructor Details
-
ObjectReader
Constructor used byObjectMapper
for initial instantiation -
ObjectReader
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. -
ObjectReader
protected ObjectReader(ObjectReader base, DeserializationConfig config, JavaType valueType, JsonDeserializer<Object> rootDeser, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues, DataFormatReaders dataFormatReaders) Copy constructor used for building variations. -
ObjectReader
Copy constructor used when modifying simple feature flags -
ObjectReader
-
ObjectReader
-
-
Method Details
-
version
Method that will return version information stored in and read from jar that contains this class.- Specified by:
version
in interfaceVersioned
- Specified by:
version
in classObjectCodec
- Returns:
- Version of the component
-
_new
Overridable factory method called by various "withXxx()" methods- Since:
- 2.5
-
_new
Overridable factory method called by various "withXxx()" methods- Since:
- 2.5
-
_new
protected ObjectReader _new(ObjectReader base, DeserializationConfig config, JavaType valueType, JsonDeserializer<Object> rootDeser, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues, DataFormatReaders dataFormatReaders) Overridable factory method called by various "withXxx()" methods- Since:
- 2.5
-
_newIterator
protected <T> MappingIterator<T> _newIterator(JsonParser p, DeserializationContext ctxt, JsonDeserializer<?> deser, boolean parserManaged) Factory method used to createMappingIterator
instances; either default, or custom subtype.- Since:
- 2.5
-
_initForReading
- Throws:
IOException
-
_initForMultiRead
Alternative to_initForReading(edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.DeserializationContext, edu.internet2.middleware.grouperClientExt.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:
IOException
- Since:
- 2.8
-
with
Method for constructing a new reader instance that is configured with specified feature enabled. -
with
Method for constructing a new reader instance that is configured with specified features enabled. -
withFeatures
Method for constructing a new reader instance that is configured with specified features enabled. -
without
Method for constructing a new reader instance that is configured with specified feature disabled. -
without
Method for constructing a new reader instance that is configured with specified features disabled. -
withoutFeatures
Method for constructing a new reader instance that is configured with specified features disabled. -
with
Method for constructing a new reader instance that is configured with specified feature enabled.- Since:
- 2.14
-
withFeatures
Method for constructing a new reader instance that is configured with specified features enabled.- Since:
- 2.14
-
without
Method for constructing a new reader instance that is configured with specified feature disabled.- Since:
- 2.14
-
withoutFeatures
Method for constructing a new reader instance that is configured with specified features disabled.- Since:
- 2.14
-
with
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
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
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
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
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
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
Method for constructing a new reader instance that is configured with specified feature enabled.- Since:
- 2.7
-
withFeatures
Method for constructing a new reader instance that is configured with specified features enabled.- Since:
- 2.7
-
without
Method for constructing a new reader instance that is configured with specified feature disabled.- Since:
- 2.7
-
withoutFeatures
Method for constructing a new reader instance that is configured with specified features disabled.- Since:
- 2.7
-
at
Convenience method to bind fromJsonPointer
.JsonPointerBasedFilter
is registered and will be used for parsing later.- Since:
- 2.6
-
at
Convenience method to bind fromJsonPointer
JsonPointerBasedFilter
is registered and will be used for parsing later.- Since:
- 2.6
-
with
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
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
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
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
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
- Since:
- 2.6
-
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
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
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
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
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.since 2.5 UseforType(JavaType)
instead -
withType
Deprecated.since 2.5 UseforType(Class)
instead -
withType
Deprecated.since 2.5 UseforType(Class)
instead -
withType
Deprecated.since 2.5 UseforType(TypeReference)
instead -
withValueToUpdate
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
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
-
with
-
withHandler
-
with
-
withFormatDetection
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
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
- Since:
- 2.3
-
withAttributes
- Since:
- 2.3
-
withAttribute
- Since:
- 2.3
-
withoutAttribute
- Since:
- 2.3
-
_with
-
isEnabled
-
isEnabled
-
isEnabled
- Since:
- 2.14
-
isEnabled
-
isEnabled
- Since:
- 2.11
-
getConfig
- Since:
- 2.2
-
getFactory
Description copied from class:ObjectCodec
Accessor for finding underlying data format factory (JsonFactory
) codec will use for data binding.- Overrides:
getFactory
in classObjectCodec
- Returns:
- Underlying
JsonFactory
instance - Since:
- 2.1
-
getTypeFactory
-
getAttributes
- Since:
- 2.3
-
getInjectableValues
- Since:
- 2.6
-
getValueType
- Since:
- 2.10
-
createParser
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:
IOException
- Since:
- 2.11
-
createParser
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:
IOException
- Since:
- 2.11
-
createParser
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:
IOException
- Since:
- 2.11
-
createParser
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:
IOException
- Since:
- 2.11
-
createParser
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:
IOException
- Since:
- 2.11
-
createParser
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:
IOException
- Since:
- 2.11
-
createParser
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:
IOException
- Since:
- 2.11
-
createParser
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:
IOException
- Since:
- 2.11
-
createParser
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:
IOException
- Since:
- 2.11
-
createParser
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:
IOException
- Since:
- 2.11
-
createNonBlockingByteArrayParser
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:
IOException
- Since:
- 2.11
-
readValue
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:
IOException
-
readValue
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 classObjectCodec
- Type Parameters:
T
- Nominal parameter for target type- Parameters:
p
- Parser to use for decoding content to bindvalueType
- Java value type to bind content to- Returns:
- Value deserialized
- Throws:
IOException
- for low-level read issues, orJsonParseException
for decoding problems
-
readValue
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 classObjectCodec
- Type Parameters:
T
- Nominal parameter for target type- Parameters:
p
- Parser to use for decoding content to bindvalueTypeRef
- Java value type to bind content to- Returns:
- Value deserialized
- Throws:
IOException
- for low-level read issues, orJsonParseException
for decoding problems
-
readValue
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 classObjectCodec
- Type Parameters:
T
- Nominal parameter for target type- Parameters:
p
- Parser to use for decoding content to bindvalueType
- Java value type to bind content to- Returns:
- Value deserialized
- Throws:
IOException
- for low-level read issues, orJsonParseException
for decoding problems
-
readValue
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:
IOException
-
readValues
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 classObjectCodec
- Type Parameters:
T
- Nominal parameter for target type- Parameters:
p
- Parser to use for decoding content to bindvalueType
- Java value type to bind content to- Returns:
- Iterator for incrementally deserializing values
- Throws:
IOException
- for low-level read issues, orJsonParseException
for decoding problems
-
readValues
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 classObjectCodec
- Type Parameters:
T
- Nominal parameter for target type- Parameters:
p
- Parser to use for decoding content to bindvalueTypeRef
- Java value type to bind content to- Returns:
- Iterator for incrementally deserializing values
- Throws:
IOException
- for low-level read issues, orJsonParseException
for decoding problems
-
readValues
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 classObjectCodec
- Type Parameters:
T
- Nominal parameter for target type- Parameters:
p
- Parser to use for decoding content to bindvalueType
- Java value type to bind content to- Returns:
- Iterator for incrementally deserializing values
- Throws:
IOException
- for low-level read issues, orJsonParseException
for decoding problems
-
readValues
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:
IOException
-
createArrayNode
Description copied from class:ObjectCodec
Method for construct root level Array nodes for Tree Model instances.- Specified by:
createArrayNode
in classObjectCodec
- Returns:
- Array node created
-
createObjectNode
Description copied from class:ObjectCodec
Method for construct root level Object nodes for Tree Model instances.- Specified by:
createObjectNode
in classObjectCodec
- Returns:
- Object node created
-
missingNode
- Overrides:
missingNode
in classTreeCodec
- Returns:
- Node that represents "missing" node during traversal: something referenced but that does not exist in content model
-
nullNode
-
treeAsTokens
Description copied from class:ObjectCodec
Method for constructing aJsonParser
for reading contents of a JSON tree, as if it was external serialized JSON content.- Specified by:
treeAsTokens
in classObjectCodec
- Parameters:
n
- Content to traverse over- Returns:
- Parser constructed for traversing over contents of specified node
-
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. 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 classObjectCodec
- Returns:
- next tree from
p
, ornull
if empty. - Throws:
IOException
- for low-level read issues, orJsonParseException
for decoding problems
-
writeTree
Description copied from class:ObjectCodec
Method for serializing JSON content from given Tree instance, using specified generator.- Specified by:
writeTree
in classObjectCodec
- Parameters:
g
- Generator to use for serializing valuerootNode
- Tree to serialize
-
readValue
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:
IOException
-
readValue
Same asreadValue(InputStream)
except that target value type overridden asvalueType
- Parameters:
src
- Source to read content fromvalueType
- Target type to bind content to- Throws:
IOException
- Since:
- 2.11
-
readValue
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:
IOException
-
readValue
Same asreadValue(Reader)
except that target value type overridden asvalueType
- Parameters:
src
- Source to read content fromvalueType
- Target type to bind content to- Throws:
IOException
- Since:
- 2.11
-
readValue
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:
JsonProcessingException
JsonMappingException
-
readValue
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:
IOException
- Since:
- 2.11
-
readValue
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:
IOException
-
readValue
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:
IOException
- Since:
- 2.11
-
readValue
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:
IOException
-
readValue
public <T> T readValue(byte[] buffer, int offset, int length, Class<T> valueType) throws 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:
IOException
- Since:
- 2.11
-
readValue
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:
IOException
-
readValue
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:
IOException
- Since:
- 2.11
-
readValue
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:
IOException
-
readValue
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:
IOException
- Since:
- 2.11
-
readValue
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:
IOException
-
readValue
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:
IOException
- Since:
- 2.11
-
readValue
- Throws:
IOException
-
readValue
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:
IOException
- Since:
- 2.11
-
readTree
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:
IOException
-
readTree
Same asreadTree(InputStream)
except content accessed through passed-inReader
- Throws:
IOException
-
readTree
Same asreadTree(InputStream)
except content read from passed-inString
-
readTree
Same asreadTree(InputStream)
except content read from passed-in byte array.- Throws:
IOException
-
readTree
Same asreadTree(InputStream)
except content read from passed-in byte array.- Throws:
IOException
-
readTree
Same asreadTree(InputStream)
except content read using passed-inDataInput
.- Throws:
IOException
-
readValues
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:
IOException
-
readValues
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:
IOException
-
readValues
Overloaded version ofreadValue(InputStream)
.- Throws:
IOException
-
readValues
Overloaded version ofreadValue(InputStream)
.- Parameters:
json
- String that contains JSON content to parse- Throws:
IOException
-
readValues
Overloaded version ofreadValue(InputStream)
.- Throws:
IOException
-
readValues
Overloaded version ofreadValue(InputStream)
.- Throws:
IOException
-
readValues
Overloaded version ofreadValue(InputStream)
.- Throws:
IOException
-
readValues
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:
IOException
-
readValues
- Throws:
IOException
- Since:
- 2.8
-
treeToValue
Description copied from class:ObjectCodec
Convenience method for converting given JSON tree into instance of specified value type. This is equivalent to first constructing aJsonParser
to iterate over contents of the tree, and using that parser for data binding.- Specified by:
treeToValue
in classObjectCodec
- Type Parameters:
T
- Nominal parameter for target type- Parameters:
n
- Tree to convertvalueType
- Java target value type to convert content to- Returns:
- Converted value instance
- Throws:
JsonProcessingException
- if structural conversion fails
-
treeToValue
Same astreeToValue(TreeNode, Class)
but with type-resolved target value type.- Throws:
JsonProcessingException
- Since:
- 2.13
-
writeValue
Description copied from class:ObjectCodec
Method to serialize given Java Object, using generator provided.- Specified by:
writeValue
in classObjectCodec
- Parameters:
gen
- Generator to use for serializing valuevalue
- Value to serialize- Throws:
IOException
- for low-level write issues, orJsonGenerationException
for decoding problems
-
_bind
Actual implementation of value reading+binding operation.- Throws:
IOException
-
_bindAndClose
- Throws:
IOException
-
_bindAndCloseAsTree
- Throws:
IOException
-
_bindAsTree
- Throws:
IOException
-
_bindAsTreeOrNull
Same as_bindAsTree(edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.core.JsonParser)
except end-of-input is reported by returningnull
, not "missing node"- Throws:
IOException
-
_bindAndReadValues
- Throws:
IOException
- Since:
- 2.1
-
_considerFilter
Consider filter when creating JsonParser. -
_verifyNoTrailingTokens
protected final void _verifyNoTrailingTokens(JsonParser p, DeserializationContext ctxt, JavaType bindType) throws IOException - Throws:
IOException
- Since:
- 2.9
-
_detectBindAndClose
- Throws:
IOException
-
_detectBindAndClose
protected Object _detectBindAndClose(DataFormatReaders.Match match, boolean forceClosing) throws IOException - Throws:
IOException
-
_detectBindAndReadValues
protected <T> MappingIterator<T> _detectBindAndReadValues(DataFormatReaders.Match match, boolean forceClosing) throws IOException - Throws:
IOException
-
_detectBindAndCloseAsTree
- Throws:
IOException
-
_reportUnkownFormat
protected void _reportUnkownFormat(DataFormatReaders detector, DataFormatReaders.Match match) throws IOException Method called to indicate that format detection failed to detect format of given input- Throws:
IOException
-
_verifySchemaType
- Since:
- 2.2
-
createDeserializationContext
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
-
_inputStream
- Throws:
IOException
-
_inputStream
- Throws:
IOException
-
_reportUndetectableSource
- Throws:
StreamReadException
-
_findRootDeserializer
protected JsonDeserializer<Object> _findRootDeserializer(DeserializationContext ctxt) throws DatabindException Method called to locate deserializer for the passed root-level value.- Throws:
DatabindException
-
_findTreeDeserializer
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt) throws DatabindException - Throws:
DatabindException
- Since:
- 2.6
-
_prefetchRootDeserializer
Method called to locate deserializer ahead of time, if permitted by configuration. Method also is NOT to throw an exception if access fails. -
_jsonNodeType
- Since:
- 2.10
-
_assertNotNull
-
forType(TypeReference)
instead