Top Description Fields Constructors Methods
com.fasterxml.jackson.jr.ob.impl

public Class JSONReader

extends Object
Class Inheritance
Imports
java.io.*, java.util.*, com.fasterxml.jackson.core.*, com.fasterxml.jackson.jr.ob.JSON, .JSONObjectException, com.fasterxml.jackson.jr.ob.api.CollectionBuilder, .MapBuilder, .ValueReader

Root-level helper object that handles initial delegation to actual readers (which are ValueReaders), 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.

Field Summary

Modifier and TypeField and Description
protected final CollectionBuilder
_collectionBuilder

Handler that takes care of constructing java.util.Maps as needed

protected final int
protected final MapBuilder
_mapBuilder

Handler that takes care of constructing java.util.Maps as needed

protected final JsonParser
_parser

Parser used by this reader instance.

protected final ValueReaderLocator
_readerLocator

Object that is used to find value readers dynamically.

protected final Object[]
_setterBuffer

Minor performance optimization: Object[1] reused to avoid Reflection having to allocate it for every "setter" call.

protected final TreeCodec
_treeCodec

Configured TreeCodec that is needed if values of type TreeNode are to be read.

Constructor Summary

AccessConstructor and Description
public
JSONReader(CollectionBuilder lb, MapBuilder mb)

Constructor used for creating the blueprint instances.

protected
JSONReader(JSONReader base, int features, ValueReaderLocator loc, TreeCodec tc, JsonParser p)

Constructor used for per-operation (non-blueprint) instance.

Method Summary

Modifier and TypeMethod and Description
protected CollectionBuilder
protected MapBuilder
_mapBuilder(Class<?> mapType)

protected JSONReader
_with(CollectionBuilder lb, MapBuilder mb)

Overridable method that all mutant factories call if a new instance is to be constructed

public boolean
public int
public boolean
public JSONReader
public Object[]
readArray()

Method for reading a JSON Array from input and building a Object[] out of it.

public <T> T[]
readArrayOf(Class<T> type)

public <T> T
readBean(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.

public List<Object>
readList()

Method for reading a JSON Array from input and building a java.util.List out of it.

public <T> List<T>
readListOf(Class<T> type)

Method for reading a JSON Array from input and building a java.util.List out of it, binding values into specified type.

public Map<String, Object>
readMap()

Method for reading a JSON Object from input and building a java.util.Map out of it.

public <T> Map<String, T>
readMapOf(Class<T> type)

Method for reading a JSON Object from input and building a java.util.Map out of it, binding values into specified type.

public TreeNode
public Object
readValue()

Method for reading a "simple" Object of type indicated by JSON content: java.util.Map for JSON Object, java.util.Map for JSON Array (or, Object[] if so configured), java.lang.String for JSON String value and so on.

public JSONReader
public JSONReader
public JSONReader
withCacheCheck(int features)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_collectionBuilderback to summary
protected final CollectionBuilder _collectionBuilder

Handler that takes care of constructing java.util.Maps as needed

_featuresback to summary
protected final int _features
_mapBuilderback to summary
protected final MapBuilder _mapBuilder

Handler that takes care of constructing java.util.Maps as needed

_parserback to summary
protected final JsonParser _parser

Parser used by this reader instance.

_readerLocatorback to summary
protected final ValueReaderLocator _readerLocator

Object that is used to find value readers dynamically.

_setterBufferback to summary
protected final Object[] _setterBuffer

Minor performance optimization: Object[1] reused to avoid Reflection having to allocate it for every "setter" call.

Since
2.13
_treeCodecback to summary
protected final TreeCodec _treeCodec

Configured TreeCodec that is needed if values of type TreeNode are to be read.

Constructor Detail

JSONReaderback to summary
public JSONReader(CollectionBuilder lb, MapBuilder mb)

Constructor used for creating the blueprint instances.

JSONReaderback to summary
protected JSONReader(JSONReader base, int features, ValueReaderLocator loc, TreeCodec tc, JsonParser p)

Constructor used for per-operation (non-blueprint) instance.

Method Detail

_collectionBuilderback to summary
protected CollectionBuilder _collectionBuilder(Class<?> collType)
_mapBuilderback to summary
protected MapBuilder _mapBuilder(Class<?> mapType)
_withback to summary
protected JSONReader _with(CollectionBuilder lb, MapBuilder mb)

Overridable method that all mutant factories call if a new instance is to be constructed

arraysAsListsback to summary
public boolean arraysAsLists()
Since
2.8
featuresback to summary
public int features()
Since
2.13
isEnabledback to summary
public boolean isEnabled(JSON.Feature f)
Since
2.11
perOperationInstanceback to summary
public JSONReader perOperationInstance(int features, ValueReaderLocator loc, TreeCodec tc, JsonParser p)
readArrayback to summary
public Object[] readArray() throws IOException

Method for reading a JSON Array from input and building a Object[] out of it. Note that if input does NOT contain a JSON Array, JSONObjectException will be thrown.

readArrayOfback to summary
public <T> T[] readArrayOf(Class<T> type) throws IOException
Annotations
@SuppressWarnings:unchecked
readBeanback to summary
public <T> T readBean(Class<T> type) throws 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.

Annotations
@SuppressWarnings:unchecked
readListback to summary
public List<Object> readList() throws IOException

Method for reading a JSON Array from input and building a java.util.List out of it. Note that if input does NOT contain a JSON Array, JSONObjectException will be thrown.

readListOfback to summary
public <T> List<T> readListOf(Class<T> type) throws IOException

Method for reading a JSON Array from input and building a java.util.List out of it, binding values into specified type. Note that if input does NOT contain a JSON Array, JSONObjectException will be thrown.

Annotations
@SuppressWarnings:unchecked
readMapback to summary
public Map<String, Object> readMap() throws IOException

Method for reading a JSON Object from input and building a java.util.Map out of it. Note that if input does NOT contain a JSON Object, JSONObjectException will be thrown.

readMapOfback to summary
public <T> Map<String, T> readMapOf(Class<T> type) throws IOException

Method for reading a JSON Object from input and building a java.util.Map out of it, binding values into specified type. Note that if input does NOT contain a JSON Object, JSONObjectException will be thrown.

Annotations
@SuppressWarnings:unchecked
Since
2.10
readTreeback to summary
public TreeNode readTree() throws IOException
Since
2.11
readValueback to summary
public Object readValue() throws IOException

Method for reading a "simple" Object of type indicated by JSON content: java.util.Map for JSON Object, java.util.Map for JSON Array (or, Object[] if so configured), java.lang.String for JSON String value and so on.

withback to summary
public JSONReader with(MapBuilder mb)
withback to summary
public JSONReader with(CollectionBuilder lb)
withCacheCheckback to summary
public JSONReader withCacheCheck(int features)