Package com.fasterxml.jackson.jr.ob.impl
Class JSONReader
- java.lang.Object
-
- com.fasterxml.jackson.jr.ob.impl.JSONReader
-
public class JSONReader extends java.lang.Object
Root-level helper object that handles initial delegation to actual readers (which areValueReader
s), but does not handle any of reading itself (despite name).Life-cycle is such that initial instance (called blueprint) is constructed first (including possible configuration using mutant factory methods). This blueprint object acts as a factory, and is never used for direct reading; instead, per-call instance is created by calling
perOperationInstance(int, com.fasterxml.jackson.jr.ob.impl.ValueReaderLocator, com.fasterxml.jackson.core.TreeCodec, com.fasterxml.jackson.core.JsonParser)
.
-
-
Field Summary
Fields Modifier and Type Field Description protected CollectionBuilder
_collectionBuilder
Handler that takes care of constructingMap
s as neededprotected int
_features
protected MapBuilder
_mapBuilder
Handler that takes care of constructingMap
s as neededprotected com.fasterxml.jackson.core.JsonParser
_parser
Parser used by this reader instance.protected ValueReaderLocator
_readerLocator
Object that is used to find value readers dynamically.protected com.fasterxml.jackson.core.TreeCodec
_treeCodec
ConfiguredTreeCodec
that is needed if values of typeTreeNode
are to be read.
-
Constructor Summary
Constructors Modifier Constructor Description JSONReader(CollectionBuilder lb, MapBuilder mb)
Constructor used for creating the blueprint instances.protected
JSONReader(JSONReader base, int features, ValueReaderLocator loc, com.fasterxml.jackson.core.TreeCodec tc, com.fasterxml.jackson.core.JsonParser p)
Constructor used for per-operation (non-blueprint) instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected CollectionBuilder
_collectionBuilder(java.lang.Class<?> collType)
protected MapBuilder
_mapBuilder(java.lang.Class<?> mapType)
protected JSONReader
_with(CollectionBuilder lb, MapBuilder mb)
Overridable method that all mutant factories call if a new instance is to be constructedboolean
arraysAsLists()
boolean
isEnabled(JSON.Feature f)
JSONReader
perOperationInstance(int features, ValueReaderLocator loc, com.fasterxml.jackson.core.TreeCodec tc, com.fasterxml.jackson.core.JsonParser p)
java.lang.Object[]
readArray()
Method for reading a JSON Array from input and building aObject[]
out of it.<T> T[]
readArrayOf(java.lang.Class<T> type)
<T> T
readBean(java.lang.Class<T> type)
Method for reading a JSON Object from input and building a Bean of specified type out of it; Bean has to conform to standard Java Bean specification by having setters for passing JSON Object properties.java.util.List<java.lang.Object>
readList()
Method for reading a JSON Array from input and building aList
out of it.<T> java.util.List<T>
readListOf(java.lang.Class<T> type)
Method for reading a JSON Array from input and building aList
out of it, binding values into specifiedtype
.java.util.Map<java.lang.String,java.lang.Object>
readMap()
Method for reading a JSON Object from input and building aMap
out of it.<T> java.util.Map<java.lang.String,T>
readMapOf(java.lang.Class<T> type)
Method for reading a JSON Object from input and building aMap
out of it, binding values into specifiedtype
.com.fasterxml.jackson.core.TreeNode
readTree()
java.lang.Object
readValue()
Method for reading a "simple" Object of type indicated by JSON content:Map
for JSON Object,Map
for JSON Array (or,Object[]
if so configured),String
for JSON String value and so on.JSONReader
with(CollectionBuilder lb)
JSONReader
with(MapBuilder mb)
JSONReader
withCacheCheck(int features)
-
-
-
Field Detail
-
_mapBuilder
protected final MapBuilder _mapBuilder
Handler that takes care of constructingMap
s as needed
-
_collectionBuilder
protected final CollectionBuilder _collectionBuilder
Handler that takes care of constructingMap
s as needed
-
_features
protected final int _features
-
_treeCodec
protected final com.fasterxml.jackson.core.TreeCodec _treeCodec
ConfiguredTreeCodec
that is needed if values of typeTreeNode
are to be read.
-
_readerLocator
protected final ValueReaderLocator _readerLocator
Object that is used to find value readers dynamically.
-
_parser
protected final com.fasterxml.jackson.core.JsonParser _parser
Parser used by this reader instance.
-
-
Constructor Detail
-
JSONReader
public JSONReader(CollectionBuilder lb, MapBuilder mb)
Constructor used for creating the blueprint instances.
-
JSONReader
protected JSONReader(JSONReader base, int features, ValueReaderLocator loc, com.fasterxml.jackson.core.TreeCodec tc, com.fasterxml.jackson.core.JsonParser p)
Constructor used for per-operation (non-blueprint) instance.
-
-
Method Detail
-
withCacheCheck
public JSONReader withCacheCheck(int features)
-
with
public JSONReader with(MapBuilder mb)
-
with
public JSONReader with(CollectionBuilder lb)
-
_with
protected JSONReader _with(CollectionBuilder lb, MapBuilder mb)
Overridable method that all mutant factories call if a new instance is to be constructed
-
perOperationInstance
public JSONReader perOperationInstance(int features, ValueReaderLocator loc, com.fasterxml.jackson.core.TreeCodec tc, com.fasterxml.jackson.core.JsonParser p)
-
arraysAsLists
public boolean arraysAsLists()
- Since:
- 2.8
-
isEnabled
public boolean isEnabled(JSON.Feature f)
- Since:
- 2.11
-
readValue
public java.lang.Object readValue() throws java.io.IOException
Method for reading a "simple" Object of type indicated by JSON content:Map
for JSON Object,Map
for JSON Array (or,Object[]
if so configured),String
for JSON String value and so on.- Throws:
java.io.IOException
-
readMap
public java.util.Map<java.lang.String,java.lang.Object> readMap() throws java.io.IOException
Method for reading a JSON Object from input and building aMap
out of it. Note that if input does NOT contain a JSON Object,JSONObjectException
will be thrown.- Throws:
java.io.IOException
-
readList
public java.util.List<java.lang.Object> readList() throws java.io.IOException
Method for reading a JSON Array from input and building aList
out of it. Note that if input does NOT contain a JSON Array,JSONObjectException
will be thrown.- Throws:
java.io.IOException
-
readArray
public java.lang.Object[] readArray() throws java.io.IOException
Method for reading a JSON Array from input and building aObject[]
out of it. Note that if input does NOT contain a JSON Array,JSONObjectException
will be thrown.- Throws:
java.io.IOException
-
readBean
public <T> T readBean(java.lang.Class<T> type) throws java.io.IOException
Method for reading a JSON Object from input and building a Bean of specified type out of it; Bean has to conform to standard Java Bean specification by having setters for passing JSON Object properties.- Throws:
java.io.IOException
-
readArrayOf
public <T> T[] readArrayOf(java.lang.Class<T> type) throws java.io.IOException
- Throws:
java.io.IOException
-
readListOf
public <T> java.util.List<T> readListOf(java.lang.Class<T> type) throws java.io.IOException
Method for reading a JSON Array from input and building aList
out of it, binding values into specifiedtype
. Note that if input does NOT contain a JSON Array,JSONObjectException
will be thrown.- Throws:
java.io.IOException
-
readMapOf
public <T> java.util.Map<java.lang.String,T> readMapOf(java.lang.Class<T> type) throws java.io.IOException
Method for reading a JSON Object from input and building aMap
out of it, binding values into specifiedtype
. Note that if input does NOT contain a JSON Object,JSONObjectException
will be thrown.- Throws:
java.io.IOException
- Since:
- 2.10
-
readTree
public com.fasterxml.jackson.core.TreeNode readTree() throws java.io.IOException
- Throws:
java.io.IOException
- Since:
- 2.11
-
_mapBuilder
protected MapBuilder _mapBuilder(java.lang.Class<?> mapType)
-
_collectionBuilder
protected CollectionBuilder _collectionBuilder(java.lang.Class<?> collType)
-
-