|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.codehaus.jackson.ObjectCodec
org.codehaus.jackson.map.ObjectReader
public class ObjectReader
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 "fluid" (aka builder) 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.
| Field Summary | |
|---|---|
protected DeserializationConfig |
_config
General serialization configuration settings; while immutable, can use copy-constructor to create modified instances as necessary. |
protected InjectableValues |
_injectableValues
Values that can be injected during deserialization, if any. |
protected JsonFactory |
_jsonFactory
Factory used for constructing JsonGenerators |
protected DeserializerProvider |
_provider
|
protected ConcurrentHashMap<JavaType,JsonDeserializer<Object>> |
_rootDeserializers
Root-level cached deserializers |
protected 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 not |
protected Object |
_valueToUpdate
Instance to update with data binding; if any. |
protected JavaType |
_valueType
Declared type of value to instantiate during deserialization. |
| Constructor Summary | |
|---|---|
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)
|
protected |
ObjectReader(ObjectReader base,
DeserializationConfig config,
JavaType valueType,
Object valueToUpdate,
FormatSchema schema,
InjectableValues injectableValues)
Copy constructor used for building variations. |
| Method Summary | ||
|---|---|---|
protected Object |
_bind(JsonParser jp)
Actual implementation of value reading+binding operation. |
|
protected Object |
_bindAndClose(JsonParser jp)
|
|
protected JsonNode |
_bindAndCloseAsTree(JsonParser jp)
|
|
protected JsonNode |
_bindAsTree(JsonParser jp)
|
|
protected DeserializationContext |
_createDeserializationContext(JsonParser jp,
DeserializationConfig cfg)
|
|
protected JsonDeserializer<Object> |
_findRootDeserializer(DeserializationConfig cfg,
JavaType valueType)
Method called to locate deserializer for the passed root-level value. |
|
protected static JsonToken |
_initForReading(JsonParser jp)
|
|
protected Object |
_unwrapAndDeserialize(JsonParser jp,
DeserializationContext ctxt,
JavaType rootType,
JsonDeserializer<Object> deser)
|
|
JsonNode |
createArrayNode()
Method for construct root level Array nodes for Tree Model instances. |
|
JsonNode |
createObjectNode()
Method for construct root level Object nodes for Tree Model instances. |
|
JsonNode |
readTree(InputStream in)
Method that reads content from given input source, using configuration of this reader, and binds it as JSON Tree. |
|
JsonNode |
readTree(JsonParser jp)
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(Reader r)
Method that reads content from given input source, using configuration of this reader, and binds it as JSON Tree. |
|
JsonNode |
readTree(String content)
Method that reads content from given JSON input String, using configuration of this reader, and binds it as JSON Tree. |
|
|
readValue(byte[] src)
Method that binds content read from given byte array, using configuration of this reader. |
|
|
readValue(byte[] src,
int offset,
int length)
Method that binds content read from given byte array, using configuration of this reader. |
|
|
readValue(File src)
|
|
|
readValue(InputStream src)
Method that binds content read from given input source, using configuration of this reader. |
|
|
readValue(JsonNode src)
Convenience method for converting results from given JSON tree into given value type. |
|
|
readValue(JsonParser jp)
Method that binds content read using given parser, using configuration of this reader, including expected result type. |
|
|
readValue(JsonParser jp,
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). |
|
|
readValue(JsonParser jp,
JavaType 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). |
|
|
readValue(JsonParser jp,
TypeReference<?> 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). |
|
|
readValue(Reader src)
Method that binds content read from given input source, using configuration of this reader. |
|
|
readValue(String src)
Method that binds content read from given JSON string, using configuration of this reader. |
|
|
readValue(URL src)
Method that binds content read from given input source, using configuration of this reader. |
|
|
readValues(byte[] src,
int offset,
int length)
Method for reading sequence of Objects from parser stream. |
|
|
readValues(File src)
Method for reading sequence of Objects from parser stream. |
|
|
readValues(InputStream src)
Method for reading sequence of Objects from parser stream. |
|
|
readValues(JsonParser jp)
Method for reading sequence of Objects from parser stream. |
|
|
readValues(JsonParser jp,
Class<T> valueType)
Convenience method that is equivalent to: |
|
|
readValues(JsonParser jp,
JavaType valueType)
Convenience method that is equivalent to: |
|
|
readValues(JsonParser jp,
TypeReference<?> valueTypeRef)
Convenience method that is equivalent to: |
|
|
readValues(Reader src)
Method for reading sequence of Objects from parser stream. |
|
|
readValues(String json)
Method for reading sequence of Objects from parser stream. |
|
|
readValues(URL src)
Method for reading sequence of Objects from parser stream. |
|
JsonParser |
treeAsTokens(JsonNode n)
Method for constructing a JsonParser for reading
contents of a JSON tree, as if it was external serialized
JSON content. |
|
|
treeToValue(JsonNode n,
Class<T> valueType)
Convenience method for converting given JSON tree into instance of specified value type. |
|
Version |
version()
Method that will return version information stored in and read from jar that contains this class. |
|
ObjectReader |
withInjectableValues(InjectableValues injectableValues)
Method for constructing a new instance with configuration that uses passed InjectableValues to provide injectable values. |
|
ObjectReader |
withNodeFactory(JsonNodeFactory f)
Method for constructing a new reader instance with configuration that uses passed JsonNodeFactory for constructing JsonNode
instances. |
|
ObjectReader |
withSchema(FormatSchema schema)
Method for constructing a new instance with configuration that passes specified FormatSchema to JsonParser that
is constructed for parsing content. |
|
ObjectReader |
withType(Class<?> valueType)
Method for constructing a new reader instance that is configured to data bind into specified type. |
|
ObjectReader |
withType(JavaType valueType)
Method for constructing a new reader instance that is configured to data bind into specified type. |
|
ObjectReader |
withType(Type valueType)
Method for constructing a new reader instance that is configured to data bind into specified type. |
|
ObjectReader |
withType(TypeReference<?> valueTypeRef)
Method for constructing a new reader instance that is configured to data bind into specified type. |
|
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. |
|
void |
writeTree(JsonGenerator jgen,
JsonNode rootNode)
NOTE: NOT implemented for ObjectReader. |
|
void |
writeValue(JsonGenerator jgen,
Object value)
Method to serialize given Java Object, using generator provided. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final DeserializationConfig _config
protected final boolean _unwrapRoot
protected final ConcurrentHashMap<JavaType,JsonDeserializer<Object>> _rootDeserializers
protected final DeserializerProvider _provider
protected final JsonFactory _jsonFactory
JsonGenerators
protected final JavaType _valueType
_valueToUpdate is non-null, only used for
locating deserializer.
protected final Object _valueToUpdate
ArrayType; array
types can not be modified because array size is immutable.
protected final FormatSchema _schema
protected final InjectableValues _injectableValues
| Constructor Detail |
|---|
protected ObjectReader(ObjectMapper mapper,
DeserializationConfig config)
ObjectMapper for initial instantiation
protected ObjectReader(ObjectMapper mapper,
DeserializationConfig config,
JavaType valueType,
Object valueToUpdate,
FormatSchema schema,
InjectableValues injectableValues)
protected ObjectReader(ObjectReader base,
DeserializationConfig config,
JavaType valueType,
Object valueToUpdate,
FormatSchema schema,
InjectableValues injectableValues)
| Method Detail |
|---|
public Version version()
version in interface Versionedpublic ObjectReader withType(JavaType valueType)
Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
public ObjectReader withType(Class<?> valueType)
Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
public ObjectReader withType(Type valueType)
Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
public ObjectReader withType(TypeReference<?> valueTypeRef)
Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
public ObjectReader withNodeFactory(JsonNodeFactory f)
JsonNodeFactory for constructing JsonNode
instances.
Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
public ObjectReader withValueToUpdate(Object value)
Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
public ObjectReader withSchema(FormatSchema schema)
FormatSchema to JsonParser 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.
public ObjectReader withInjectableValues(InjectableValues injectableValues)
InjectableValues to provide injectable values.
Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.
public <T> T readValue(JsonParser jp)
throws IOException,
JsonProcessingException
withValueToUpdate(Object).
IOException
JsonProcessingException
public <T> T readValue(JsonParser jp,
Class<T> valueType)
throws IOException,
JsonProcessingException
withValueToUpdate(Object).
readValue in class ObjectCodecIOException
JsonProcessingException
public <T> T readValue(JsonParser jp,
TypeReference<?> valueTypeRef)
throws IOException,
JsonProcessingException
withValueToUpdate(Object).
readValue in class ObjectCodecIOException
JsonProcessingException
public <T> T readValue(JsonParser jp,
JavaType valueType)
throws IOException,
JsonProcessingException
withValueToUpdate(Object).
readValue in class ObjectCodecIOException
JsonProcessingException
public JsonNode readTree(JsonParser jp)
throws IOException,
JsonProcessingException
Note: if an object was specified with withValueToUpdate(java.lang.Object), it
will be ignored.
readTree in class ObjectCodecIOException
JsonProcessingException
public <T> Iterator<T> readValues(JsonParser jp,
Class<T> valueType)
throws IOException,
JsonProcessingException
withType(valueType).readValues(jp);
readValues in class ObjectCodecIOException
JsonProcessingException
public <T> Iterator<T> readValues(JsonParser jp,
TypeReference<?> valueTypeRef)
throws IOException,
JsonProcessingException
withType(valueTypeRef).readValues(jp);
readValues in class ObjectCodecIOException
JsonProcessingException
public <T> Iterator<T> readValues(JsonParser jp,
JavaType valueType)
throws IOException,
JsonProcessingException
withType(valueType).readValues(jp);
readValues in class ObjectCodecIOException
JsonProcessingException
public <T> T readValue(InputStream src)
throws IOException,
JsonProcessingException
withValueToUpdate(Object).
IOException
JsonProcessingException
public <T> T readValue(Reader src)
throws IOException,
JsonProcessingException
withValueToUpdate(Object).
IOException
JsonProcessingException
public <T> T readValue(String src)
throws IOException,
JsonProcessingException
withValueToUpdate(Object).
IOException
JsonProcessingException
public <T> T readValue(byte[] src)
throws IOException,
JsonProcessingException
withValueToUpdate(Object).
IOException
JsonProcessingException
public <T> T readValue(byte[] src,
int offset,
int length)
throws IOException,
JsonProcessingException
withValueToUpdate(Object).
IOException
JsonProcessingException
public <T> T readValue(File src)
throws IOException,
JsonProcessingException
IOException
JsonProcessingException
public <T> T readValue(URL src)
throws IOException,
JsonProcessingException
withValueToUpdate(Object).
IOException
JsonProcessingException
public <T> T readValue(JsonNode src)
throws IOException,
JsonProcessingException
objectReader.readValue(src.traverse())
IOException
JsonProcessingException
public JsonNode readTree(InputStream in)
throws IOException,
JsonProcessingException
Note that if an object was specified with a call to
withValueToUpdate(Object)
it will just be ignored; result is always a newly constructed
JsonNode instance.
IOException
JsonProcessingException
public JsonNode readTree(Reader r)
throws IOException,
JsonProcessingException
Note that if an object was specified with a call to
withValueToUpdate(Object)
it will just be ignored; result is always a newly constructed
JsonNode instance.
IOException
JsonProcessingException
public JsonNode readTree(String content)
throws IOException,
JsonProcessingException
Note that if an object was specified with a call to
withValueToUpdate(Object)
it will just be ignored; result is always a newly constructed
JsonNode instance.
IOException
JsonProcessingException
public <T> MappingIterator<T> readValues(JsonParser jp)
throws IOException,
JsonProcessingException
IOException
JsonProcessingException
public <T> MappingIterator<T> readValues(InputStream src)
throws IOException,
JsonProcessingException
IOException
JsonProcessingException
public <T> MappingIterator<T> readValues(Reader src)
throws IOException,
JsonProcessingException
IOException
JsonProcessingException
public <T> MappingIterator<T> readValues(String json)
throws IOException,
JsonProcessingException
IOException
JsonProcessingException
public <T> MappingIterator<T> readValues(byte[] src,
int offset,
int length)
throws IOException,
JsonProcessingException
IOException
JsonProcessingException
public <T> MappingIterator<T> readValues(File src)
throws IOException,
JsonProcessingException
IOException
JsonProcessingException
public <T> MappingIterator<T> readValues(URL src)
throws IOException,
JsonProcessingException
IOException
JsonProcessingException
protected Object _bind(JsonParser jp)
throws IOException,
JsonParseException,
JsonMappingException
IOException
JsonParseException
JsonMappingException
protected Object _bindAndClose(JsonParser jp)
throws IOException,
JsonParseException,
JsonMappingException
IOException
JsonParseException
JsonMappingException
protected JsonNode _bindAsTree(JsonParser jp)
throws IOException,
JsonParseException,
JsonMappingException
IOException
JsonParseException
JsonMappingException
protected JsonNode _bindAndCloseAsTree(JsonParser jp)
throws IOException,
JsonParseException,
JsonMappingException
IOException
JsonParseException
JsonMappingException
protected static JsonToken _initForReading(JsonParser jp)
throws IOException,
JsonParseException,
JsonMappingException
IOException
JsonParseException
JsonMappingException
protected JsonDeserializer<Object> _findRootDeserializer(DeserializationConfig cfg,
JavaType valueType)
throws JsonMappingException
JsonMappingException
protected DeserializationContext _createDeserializationContext(JsonParser jp,
DeserializationConfig cfg)
protected Object _unwrapAndDeserialize(JsonParser jp,
DeserializationContext ctxt,
JavaType rootType,
JsonDeserializer<Object> deser)
throws IOException,
JsonParseException,
JsonMappingException
IOException
JsonParseException
JsonMappingExceptionpublic JsonNode createArrayNode()
ObjectCodec
createArrayNode in class ObjectCodecpublic JsonNode createObjectNode()
ObjectCodec
createObjectNode in class ObjectCodecpublic JsonParser treeAsTokens(JsonNode n)
ObjectCodecJsonParser for reading
contents of a JSON tree, as if it was external serialized
JSON content.
treeAsTokens in class ObjectCodec
public <T> T treeToValue(JsonNode n,
Class<T> valueType)
throws IOException,
JsonProcessingException
ObjectCodecJsonParser to
iterate over contents of the tree, and using that parser for data binding.
treeToValue in class ObjectCodecIOException
JsonProcessingException
public void writeTree(JsonGenerator jgen,
JsonNode rootNode)
throws IOException,
JsonProcessingException
ObjectReader.
writeTree in class ObjectCodecIOException
JsonProcessingException
public void writeValue(JsonGenerator jgen,
Object value)
throws IOException,
JsonProcessingException
ObjectCodec
writeValue in class ObjectCodecIOException
JsonProcessingException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||