Class 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 calling perOperationInstance(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 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 of ValueReaders 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_COLLECTION

        public static final int SER_COLLECTION
        All kinds of Collections other than Lists
        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_TREE_NODE

        public static final int SER_TREE_NODE
        An implementation of TreeNode
        See Also:
        Constant Field Values
      • SER_ITERABLE

        public static final int SER_ITERABLE
        Anything that implements Iterable, but not Collection.
        See Also:
        Constant Field Values
      • CACHE_FLAGS

        protected static final int CACHE_FLAGS
    • Method Detail

      • 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 parameters
        type - Type-erased type of value to construct reader for
        genericType - Full (possibly) generic type of value to construct reader for (important for Map, 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)
      • beanReader

        protected ValueReader beanReader​(java.lang.Class<?> type)
      • _resolveBeanDef

        protected POJODefinition _resolveBeanDef​(java.lang.Class<?> raw)
      • _findSimpleType

        protected int _findSimpleType​(java.lang.Class<?> raw,
                                      boolean forSer)