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.ObjectRoot-level helper object that handles initial delegation to actual readers (which areValueReaders), 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_collectionBuilderHandler that takes care of constructingMaps as neededprotected int_featuresprotected MapBuilder_mapBuilderHandler that takes care of constructingMaps as neededprotected com.fasterxml.jackson.core.JsonParser_parserParser used by this reader instance.protected ValueReaderLocator_readerLocatorObject that is used to find value readers dynamically.protected com.fasterxml.jackson.core.TreeCodec_treeCodecConfiguredTreeCodecthat is needed if values of typeTreeNodeare to be read.
-
Constructor Summary
Constructors Modifier Constructor Description JSONReader(CollectionBuilder lb, MapBuilder mb)Constructor used for creating the blueprint instances.protectedJSONReader(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 constructedbooleanarraysAsLists()booleanisEnabled(JSON.Feature f)JSONReaderperOperationInstance(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> TreadBean(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 aListout of it.<T> java.util.List<T>readListOf(java.lang.Class<T> type)Method for reading a JSON Array from input and building aListout 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 aMapout 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 aMapout of it, binding values into specifiedtype.com.fasterxml.jackson.core.TreeNodereadTree()java.lang.ObjectreadValue()Method for reading a "simple" Object of type indicated by JSON content:Mapfor JSON Object,Mapfor JSON Array (or,Object[]if so configured),Stringfor JSON String value and so on.JSONReaderwith(CollectionBuilder lb)JSONReaderwith(MapBuilder mb)JSONReaderwithCacheCheck(int features)
-
-
-
Field Detail
-
_mapBuilder
protected final MapBuilder _mapBuilder
Handler that takes care of constructingMaps as needed
-
_collectionBuilder
protected final CollectionBuilder _collectionBuilder
Handler that takes care of constructingMaps as needed
-
_features
protected final int _features
-
_treeCodec
protected final com.fasterxml.jackson.core.TreeCodec _treeCodec
ConfiguredTreeCodecthat is needed if values of typeTreeNodeare 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.IOExceptionMethod for reading a "simple" Object of type indicated by JSON content:Mapfor JSON Object,Mapfor JSON Array (or,Object[]if so configured),Stringfor 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.IOExceptionMethod for reading a JSON Object from input and building aMapout of it. Note that if input does NOT contain a JSON Object,JSONObjectExceptionwill be thrown.- Throws:
java.io.IOException
-
readList
public java.util.List<java.lang.Object> readList() throws java.io.IOExceptionMethod for reading a JSON Array from input and building aListout of it. Note that if input does NOT contain a JSON Array,JSONObjectExceptionwill be thrown.- Throws:
java.io.IOException
-
readArray
public java.lang.Object[] readArray() throws java.io.IOExceptionMethod for reading a JSON Array from input and building aObject[]out of it. Note that if input does NOT contain a JSON Array,JSONObjectExceptionwill be thrown.- Throws:
java.io.IOException
-
readBean
public <T> T readBean(java.lang.Class<T> type) throws java.io.IOExceptionMethod 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.IOExceptionMethod for reading a JSON Array from input and building aListout of it, binding values into specifiedtype. Note that if input does NOT contain a JSON Array,JSONObjectExceptionwill 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.IOExceptionMethod for reading a JSON Object from input and building aMapout of it, binding values into specifiedtype. Note that if input does NOT contain a JSON Object,JSONObjectExceptionwill 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)
-
-