Package com.fasterxml.jackson.jr.ob.impl
Class ValueReaderLocator
- java.lang.Object
-
- com.fasterxml.jackson.jr.ob.impl.ValueReaderLocator
-
public class ValueReaderLocator extends java.lang.Object
Helper object used for efficient detection of type information relevant to our conversion needs when writing out Java Objects as JSON.Note that usage pattern is such that a single "root" instance is kept by each
JSON
instance; and an actual per-operation instance must be constructed by callingperOperationInstance(com.fasterxml.jackson.jr.ob.impl.JSONReader, int)
: reason for this is that instances use simple caching to handle the common case of repeating types within JSON Arrays.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
_features
Feature flags that are enabledprotected java.util.Map<ClassKey,ValueReader>
_incompleteReaders
During resolution, some readers may be in-progress, but need to be linked: for example, with cyclic type references.protected java.util.concurrent.ConcurrentHashMap<ClassKey,ValueReader>
_knownReaders
Set ofValueReader
s that we have resolvedprotected JSONReader
_readContext
protected java.lang.Object
_readerLock
Object used for mutex during construction of a Bean deserializer: necessary to avoid race conditions during handling of cyclic dependencies.protected ReaderWriterModifier
_readerModifier
Provider for reader customizer, if any; may be null.protected ReaderWriterProvider
_readerProvider
Provider for custom readers, if any; may be null.protected TypeResolver
_typeResolver
For generic containers (Collections, Maps, arrays), we may need this guy.protected static int
CACHE_FLAGS
protected static int
MAX_CACHED_READERS
While we should be able to cache all types in the active working set, we should also avoid potential unbounded retention, since there is often just one big instance per JVM (or at least ClassLoader).static int
SER_BOOLEAN
static int
SER_BOOLEAN_ARRAY
static int
SER_BYTE_ARRAY
static int
SER_CALENDAR
static int
SER_CHAR
static int
SER_CHAR_ARRAY
static int
SER_CHARACTER_SEQUENCE
static int
SER_CLASS
static int
SER_COLLECTION
All kinds ofCollection
s other thanList
sstatic int
SER_DATE
static int
SER_ENUM
static int
SER_FILE
static int
SER_INT_ARRAY
static int
SER_ITERABLE
Anything that implementsIterable
, but notCollection
.static int
SER_LIST
All kinds ofList
s.static int
SER_LONG_ARRAY
static int
SER_MAP
All kinds ofMap
s.static int
SER_NUMBER_BIG_DECIMAL
static int
SER_NUMBER_BIG_INTEGER
static int
SER_NUMBER_BYTE
static int
SER_NUMBER_DOUBLE
static int
SER_NUMBER_FLOAT
static int
SER_NUMBER_INTEGER
static int
SER_NUMBER_LONG
static int
SER_NUMBER_SHORT
static int
SER_OBJECT_ARRAY
Arrays of non-primitive typesstatic int
SER_STRING
static int
SER_TREE_NODE
An implementation ofTreeNode
static int
SER_UNKNOWN
Type not yet resolvedstatic int
SER_URI
static int
SER_URL
static int
SER_UUID
-
Constructor Summary
Constructors Modifier Constructor Description protected
ValueReaderLocator(ReaderWriterProvider rwp, ReaderWriterModifier rwm)
Constructor for the blueprint instanceprotected
ValueReaderLocator(ValueReaderLocator base, int features, JSONReader r)
protected
ValueReaderLocator(ValueReaderLocator base, ReaderWriterProvider rwp, ReaderWriterModifier rwm)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ValueReader
_createReader(java.lang.Class<?> contextType, java.lang.Class<?> type, java.lang.reflect.Type genericType)
protected int
_findSimpleType(java.lang.Class<?> raw, boolean forSer)
protected POJODefinition
_resolveBeanDef(java.lang.Class<?> raw)
protected BeanReader
_resolveBeanForDeser(java.lang.Class<?> raw, POJODefinition beanDef)
protected ValueReader
arrayReader(java.lang.Class<?> contextType, java.lang.Class<?> arrayType)
protected ValueReader
beanReader(java.lang.Class<?> type)
static ValueReaderLocator
blueprint(ReaderWriterProvider rwp, ReaderWriterModifier rwm)
protected ValueReader
collectionReader(java.lang.Class<?> collectionType, ResolvedType valueType)
protected ValueReader
collectionReader(java.lang.Class<?> contextType, java.lang.reflect.Type collectionType)
protected ValueReader
createReader(java.lang.Class<?> contextType, java.lang.Class<?> type, java.lang.reflect.Type genericType)
Factory method for creating standard readers of any declared type.protected ValueReader
enumReader(java.lang.Class<?> enumType)
ValueReader
findReader(java.lang.Class<?> raw)
Method used during deserialization to find handler for given non-generic type: will first check for already resolved (and cached) readers -- and return if one found -- and then if no cached reader found, create one, cache, return.protected ValueReader
mapReader(java.lang.Class<?> mapType, ResolvedType valueType)
protected ValueReader
mapReader(java.lang.Class<?> contextType, java.lang.reflect.Type mapType)
ValueReaderLocator
perOperationInstance(JSONReader r, int features)
ReaderWriterModifier
readerWriterModifier()
ReaderWriterProvider
readerWriterProvider()
ValueReaderLocator
with(ReaderWriterModifier rwm)
ValueReaderLocator
with(ReaderWriterProvider rwp)
-
-
-
Field Detail
-
MAX_CACHED_READERS
protected static final int MAX_CACHED_READERS
While we should be able to cache all types in the active working set, we should also avoid potential unbounded retention, since there is often just one big instance per JVM (or at least ClassLoader).- See Also:
- Constant Field Values
-
_typeResolver
protected final TypeResolver _typeResolver
For generic containers (Collections, Maps, arrays), we may need this guy.
-
_readerProvider
protected final ReaderWriterProvider _readerProvider
Provider for custom readers, if any; may be null.- Since:
- 2.10
-
_readerModifier
protected final ReaderWriterModifier _readerModifier
Provider for reader customizer, if any; may be null.- Since:
- 2.11
-
_knownReaders
protected final java.util.concurrent.ConcurrentHashMap<ClassKey,ValueReader> _knownReaders
Set ofValueReader
s that we have resolved
-
_incompleteReaders
protected java.util.Map<ClassKey,ValueReader> _incompleteReaders
During resolution, some readers may be in-progress, but need to be linked: for example, with cyclic type references.
-
_readerLock
protected final java.lang.Object _readerLock
Object used for mutex during construction of a Bean deserializer: necessary to avoid race conditions during handling of cyclic dependencies.
-
_features
protected final int _features
Feature flags that are enabled
-
_readContext
protected final JSONReader _readContext
-
SER_UNKNOWN
public static final int SER_UNKNOWN
Type not yet resolved- See Also:
- Constant Field Values
-
SER_MAP
public static final int SER_MAP
All kinds ofMap
s.- See Also:
- Constant Field Values
-
SER_LIST
public static final int SER_LIST
All kinds ofList
s.- See Also:
- Constant Field Values
-
SER_COLLECTION
public static final int SER_COLLECTION
All kinds ofCollection
s other thanList
s- See Also:
- Constant Field Values
-
SER_OBJECT_ARRAY
public static final int SER_OBJECT_ARRAY
Arrays of non-primitive types- See Also:
- Constant Field Values
-
SER_INT_ARRAY
public static final int SER_INT_ARRAY
- See Also:
- Constant Field Values
-
SER_LONG_ARRAY
public static final int SER_LONG_ARRAY
- See Also:
- Constant Field Values
-
SER_BOOLEAN_ARRAY
public static final int SER_BOOLEAN_ARRAY
- See Also:
- Constant Field Values
-
SER_TREE_NODE
public static final int SER_TREE_NODE
An implementation ofTreeNode
- See Also:
- Constant Field Values
-
SER_STRING
public static final int SER_STRING
- See Also:
- Constant Field Values
-
SER_CHARACTER_SEQUENCE
public static final int SER_CHARACTER_SEQUENCE
- See Also:
- Constant Field Values
-
SER_CHAR_ARRAY
public static final int SER_CHAR_ARRAY
- See Also:
- Constant Field Values
-
SER_BYTE_ARRAY
public static final int SER_BYTE_ARRAY
- See Also:
- Constant Field Values
-
SER_NUMBER_BYTE
public static final int SER_NUMBER_BYTE
- See Also:
- Constant Field Values
-
SER_NUMBER_SHORT
public static final int SER_NUMBER_SHORT
- See Also:
- Constant Field Values
-
SER_NUMBER_INTEGER
public static final int SER_NUMBER_INTEGER
- See Also:
- Constant Field Values
-
SER_NUMBER_LONG
public static final int SER_NUMBER_LONG
- See Also:
- Constant Field Values
-
SER_NUMBER_FLOAT
public static final int SER_NUMBER_FLOAT
- See Also:
- Constant Field Values
-
SER_NUMBER_DOUBLE
public static final int SER_NUMBER_DOUBLE
- See Also:
- Constant Field Values
-
SER_NUMBER_BIG_INTEGER
public static final int SER_NUMBER_BIG_INTEGER
- See Also:
- Constant Field Values
-
SER_NUMBER_BIG_DECIMAL
public static final int SER_NUMBER_BIG_DECIMAL
- See Also:
- Constant Field Values
-
SER_BOOLEAN
public static final int SER_BOOLEAN
- See Also:
- Constant Field Values
-
SER_CHAR
public static final int SER_CHAR
- See Also:
- Constant Field Values
-
SER_ENUM
public static final int SER_ENUM
- See Also:
- Constant Field Values
-
SER_DATE
public static final int SER_DATE
- See Also:
- Constant Field Values
-
SER_CALENDAR
public static final int SER_CALENDAR
- See Also:
- Constant Field Values
-
SER_CLASS
public static final int SER_CLASS
- See Also:
- Constant Field Values
-
SER_FILE
public static final int SER_FILE
- See Also:
- Constant Field Values
-
SER_UUID
public static final int SER_UUID
- See Also:
- Constant Field Values
-
SER_URL
public static final int SER_URL
- See Also:
- Constant Field Values
-
SER_URI
public static final int SER_URI
- See Also:
- Constant Field Values
-
SER_ITERABLE
public static final int SER_ITERABLE
Anything that implementsIterable
, but notCollection
.- See Also:
- Constant Field Values
-
CACHE_FLAGS
protected static final int CACHE_FLAGS
-
-
Constructor Detail
-
ValueReaderLocator
protected ValueReaderLocator(ReaderWriterProvider rwp, ReaderWriterModifier rwm)
Constructor for the blueprint instance
-
ValueReaderLocator
protected ValueReaderLocator(ValueReaderLocator base, int features, JSONReader r)
-
ValueReaderLocator
protected ValueReaderLocator(ValueReaderLocator base, ReaderWriterProvider rwp, ReaderWriterModifier rwm)
-
-
Method Detail
-
blueprint
public static final ValueReaderLocator blueprint(ReaderWriterProvider rwp, ReaderWriterModifier rwm)
-
with
public ValueReaderLocator with(ReaderWriterProvider rwp)
-
with
public ValueReaderLocator with(ReaderWriterModifier rwm)
-
perOperationInstance
public ValueReaderLocator perOperationInstance(JSONReader r, int features)
-
readerWriterProvider
public ReaderWriterProvider readerWriterProvider()
-
readerWriterModifier
public ReaderWriterModifier readerWriterModifier()
-
findReader
public ValueReader findReader(java.lang.Class<?> raw)
Method used during deserialization to find handler for given non-generic type: will first check for already resolved (and cached) readers -- and return if one found -- and then if no cached reader found, create one, cache, return.- Parameters:
raw
- Type-erased type of value to find reader for- Returns:
- ValueReader to use for given type
-
createReader
protected ValueReader createReader(java.lang.Class<?> contextType, java.lang.Class<?> type, java.lang.reflect.Type genericType)
Factory method for creating standard readers of any declared type.- Parameters:
contextType
- Context for resolving generic type parameterstype
- Type-erased type of value to construct reader forgenericType
- Full (possibly) generic type of value to construct reader for (important forMap
,Collection
).
-
_createReader
protected ValueReader _createReader(java.lang.Class<?> contextType, java.lang.Class<?> type, java.lang.reflect.Type genericType)
-
arrayReader
protected ValueReader arrayReader(java.lang.Class<?> contextType, java.lang.Class<?> arrayType)
-
enumReader
protected ValueReader enumReader(java.lang.Class<?> enumType)
-
collectionReader
protected ValueReader collectionReader(java.lang.Class<?> contextType, java.lang.reflect.Type collectionType)
-
collectionReader
protected ValueReader collectionReader(java.lang.Class<?> collectionType, ResolvedType valueType)
-
mapReader
protected ValueReader mapReader(java.lang.Class<?> contextType, java.lang.reflect.Type mapType)
-
mapReader
protected ValueReader mapReader(java.lang.Class<?> mapType, ResolvedType valueType)
-
beanReader
protected ValueReader beanReader(java.lang.Class<?> type)
-
_resolveBeanDef
protected POJODefinition _resolveBeanDef(java.lang.Class<?> raw)
-
_resolveBeanForDeser
protected BeanReader _resolveBeanForDeser(java.lang.Class<?> raw, POJODefinition beanDef)
-
_findSimpleType
protected int _findSimpleType(java.lang.Class<?> raw, boolean forSer)
-
-