Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   package com.fasterxml.jackson.databind;
   
   import java.io.*;
   import java.net.URL;
   import java.util.Iterator;
   import java.util.Locale;
   import java.util.TimeZone;
   
  
Builder object that can be used for per-serialization configuration of deserialization parameters, such as root type to use or object to update (instead of constructing new instance).

Uses "fluent" (or, kind of, builder) pattern so that instances are immutable (and thus fully thread-safe with no external synchronization); new instances are constructed for different configurations. Instances are initially constructed by ObjectMapper and can be reused, shared, cached; both because of thread-safety and because instances are relatively light-weight.

  
  public class ObjectReader
      extends ObjectCodec
      implements Versionedjava.io.Serializable // since 2.1
  {
      private static final long serialVersionUID = -4251443320039569153L;
  
      private final static JavaType JSON_NODE_TYPE = SimpleType.constructUnsafe(JsonNode.class);
  
      /*
      /**********************************************************
      /* Immutable configuration from ObjectMapper
      /**********************************************************
       */

    
General serialization configuration settings; while immutable, can use copy-constructor to create modified instances as necessary.
  
      protected final DeserializationConfig _config;

    
Blueprint instance of deserialization context; used for creating actual instance when needed.
  
      protected final DefaultDeserializationContext _context;

    
Factory used for constructing com.fasterxml.jackson.core.JsonGenerators
  
      protected final JsonFactory _jsonFactory;
    
    
Flag that indicates whether root values are expected to be unwrapped or not
  
      protected final boolean _unwrapRoot;
      
      /*
      /**********************************************************
      /* Configuration that can be changed during building
      /**********************************************************
       */   

    
Declared type of value to instantiate during deserialization. Defines which deserializer to use; as well as base type of instance to construct if an updatable value is not configured to be used (subject to changes by embedded type information, for polymorphic types). If _valueToUpdate is non-null, only used for locating deserializer.
  
      protected final JavaType _valueType;

    
We may pre-fetch deserializer as soon as _valueType is known, and if so, reuse it afterwards. This allows avoiding further deserializer lookups and increases performance a bit on cases where readers are reused.

Since:
2.1
  
      protected final JsonDeserializer<Object_rootDeserializer;
    
    
Instance to update with data binding; if any. If null, a new instance is created, if non-null, properties of this value object will be updated instead. Note that value can be of almost any type, except not com.fasterxml.jackson.databind.type.ArrayType; array types can not be modified because array size is immutable.
 
     protected final Object _valueToUpdate;

    
When using data format that uses a schema, schema is passed to parser.
 
     protected final FormatSchema _schema;

    
Values that can be injected during deserialization, if any.
 
     protected final InjectableValues _injectableValues;

    
Optional detector used for auto-detecting data format that byte-based input uses.

NOTE: If defined non-null, readValue() methods that take java.io.Reader or java.lang.String input will fail with exception, because format-detection only works on byte-sources. Also, if format can not be detect reliably (as per detector settings), a com.fasterxml.jackson.core.JsonParseException will be thrown).

Since:
2.1
 
     protected final DataFormatReaders _dataFormatReaders;
     
     /*
     /**********************************************************
     /* Caching
     /**********************************************************
      */
    
    
Root-level cached deserializers
 
     final protected ConcurrentHashMap<JavaTypeJsonDeserializer<Object>> _rootDeserializers;

    
Cache for root names used when root-wrapping is enabled.
 
     protected final RootNameLookup _rootNames;
     
     /*
     /**********************************************************
     /* Life-cycle, construction
     /**********************************************************
      */

    
Constructor used by ObjectMapper for initial instantiation
 
     protected ObjectReader(ObjectMapper mapperDeserializationConfig config)
     {
         this(mapperconfignullnullnullnull);
     }

    
Constructor called when a root deserializer should be fetched based on other configuration.
 
     protected ObjectReader(ObjectMapper mapperDeserializationConfig config,
             JavaType valueTypeObject valueToUpdate,
             FormatSchema schemaInjectableValues injectableValues)
     {
          = config;
          = mapper._deserializationContext;
          = mapper._rootDeserializers;
          = mapper._jsonFactory;
          = mapper._rootNames;
          = valueType;
          = valueToUpdate;
         if (valueToUpdate != null && valueType.isArrayType()) {
             throw new IllegalArgumentException("Can not update an array value");
         }
          = schema;
          = injectableValues;
          = config.useRootWrapping();
 
          = _prefetchRootDeserializer(configvalueType);
          = null;        
     }
    
    
Copy constructor used for building variations.
 
     protected ObjectReader(ObjectReader baseDeserializationConfig config,
             JavaType valueTypeJsonDeserializer<ObjectrootDeserObject valueToUpdate,
             FormatSchema schemaInjectableValues injectableValues,
             DataFormatReaders dataFormatReaders)
     {
          = config;
          = base._context;
 
          = base._rootDeserializers;
          = base._jsonFactory;
          = base._rootNames;
 
          = valueType;
          = rootDeser;
          = valueToUpdate;
         if (valueToUpdate != null && valueType.isArrayType()) {
             throw new IllegalArgumentException("Can not update an array value");
         }
          = schema;
          = injectableValues;
          = config.useRootWrapping();
          = dataFormatReaders;
     }

    
Copy constructor used when modifying simple feature flags
 
     protected ObjectReader(ObjectReader baseDeserializationConfig config)
     {
          = config;
          = base._context;
 
          = base._rootDeserializers;
          = base._jsonFactory;
          = base._rootNames;
 
          = base._valueType;
          = base._rootDeserializer;
          = base._valueToUpdate;
          = base._schema;
          = base._injectableValues;
          = config.useRootWrapping();
          = base._dataFormatReaders;
     }
 
     protected ObjectReader(ObjectReader baseJsonFactory f)
     {
          = base._config;
          = base._context;
 
          = base._rootDeserializers;
          = f;
          = base._rootNames;
 
          = base._valueType;
          = base._rootDeserializer;
          = base._valueToUpdate;
          = base._schema;
          = base._injectableValues;
          = base._unwrapRoot;
          = base._dataFormatReaders;
     }
    
    
Method that will return version information stored in and read from jar that contains this class.
 
 //  @Override
     public Version version() {
         return ..version();
     }
 
     /*
     /**********************************************************
     /* Life-cycle, fluent factory methods
     /**********************************************************
      */
 
     public ObjectReader with(DeserializationConfig config) {
         return _with(config);
     }    
    
    
Method for constructing a new reader instance that is configured with specified feature enabled.
 
     public ObjectReader with(DeserializationFeature feature) {
         return _with(.with(feature));
     }    

    
Method for constructing a new reader instance that is configured with specified features enabled.
 
     public ObjectReader with(DeserializationFeature first,
             DeserializationFeature... other)
     {
         return _with(.with(firstother));
     }    

    
Method for constructing a new reader instance that is configured with specified features enabled.
 
     public ObjectReader withFeatures(DeserializationFeature... features) {
         return _with(.withFeatures(features));
     }    
    
    
Method for constructing a new reader instance that is configured with specified feature disabled.
 
     public ObjectReader without(DeserializationFeature feature) {
         return _with(.without(feature)); 
     }    

    
Method for constructing a new reader instance that is configured with specified features disabled.
 
             DeserializationFeature... other)
     {
         return _with(.without(firstother));
     }    

    
Method for constructing a new reader instance that is configured with specified features disabled.
 
     public ObjectReader withoutFeatures(DeserializationFeature... features) {
         return _with(.withoutFeatures(features));
     }    
    
    
Method for constructing a new instance with configuration that uses passed InjectableValues to provide injectable values.

Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.

 
     public ObjectReader with(InjectableValues injectableValues)
     {
         if ( == injectableValues) {
             return this;
         }
         return new ObjectReader(this,
                 ,
                 injectableValues);
     }

    
Method for constructing a new reader instance with configuration that uses passed com.fasterxml.jackson.databind.node.JsonNodeFactory for constructing JsonNode instances.

Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.

 
     public ObjectReader with(JsonNodeFactory f) {
         return _with(.with(f));
     }

    
Method for constructing a new reader instance with configuration that uses passed com.fasterxml.jackson.core.JsonFactory for constructing underlying Readers.

NOTE: only factories that DO NOT REQUIRE SPECIAL MAPPERS (that is, ones that return false for com.fasterxml.jackson.core.JsonFactory.requiresCustomCodec()) can be used: trying to use one that requires custom codec will throw exception

Since:
2.1
 
     public ObjectReader with(JsonFactory f) {
         if (f == ) {
             return this;
         }
         ObjectReader r = new ObjectReader(thisf);
         // Also, try re-linking, if possible...
         if (f.getCodec() == null) {
             f.setCodec(r);
         }
         return r;
     }
    
    
Method for constructing a new instance with configuration that specifies what root name to expect for "root name unwrapping". See DeserializationConfig.withRootName(java.lang.String) for details.

Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.

 
     public ObjectReader withRootName(String rootName) {
         return _with(.withRootName(rootName));
     }
    
    
Method for constructing a new instance with configuration that passes specified com.fasterxml.jackson.core.FormatSchema to com.fasterxml.jackson.core.JsonParser that is constructed for parsing content.

Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.

 
     public ObjectReader with(FormatSchema schema)
     {
         if ( == schema) {
             return this;
         }
         return new ObjectReader(this,
                 schema);
     }

    
Method for constructing a new reader instance that is configured to data bind into specified type.

Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.

 
     public ObjectReader withType(JavaType valueType)
     {
         if (valueType != null && valueType.equals()) {
             return this;
         }
         JsonDeserializer<ObjectrootDeser = _prefetchRootDeserializer(valueType);
         // type is stored here, no need to make a copy of config
         DataFormatReaders det = ;
         if (det != null) {
             det = det.withType(valueType);
         }
         return new ObjectReader(thisvalueTyperootDeser,
                 det);
     }    

    
Method for constructing a new reader instance that is configured to data bind into specified type.

Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.

 
     public ObjectReader withType(Class<?> valueType) {
         return withType(.constructType(valueType));
     }    

    
Method for constructing a new reader instance that is configured to data bind into specified type.

Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.

 
     public ObjectReader withType(java.lang.reflect.Type valueType) {
         return withType(.getTypeFactory().constructType(valueType));
     }    

    
Method for constructing a new reader instance that is configured to data bind into specified type.

Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.

 
     public ObjectReader withType(TypeReference<?> valueTypeRef) {
         return withType(.getTypeFactory().constructType(valueTypeRef.getType()));
     }    

    
Method for constructing a new instance with configuration that updates passed Object (as root value), instead of constructing a new value.

Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.

 
     public ObjectReader withValueToUpdate(Object value)
     {
         if (value == return this;
         if (value == null) {
             throw new IllegalArgumentException("cat not update null value");
         }
         JavaType t;
         
         /* no real benefit from pre-fetching, as updating readers are much
          * less likely to be reused, and value type may also be forced
          * with a later chained call...
          */
         if ( == null) {
             t = .constructType(value.getClass());
         } else {
             t = ;
         }
         return new ObjectReader(thistvalue,
                 );
     }

    
Method for constructing a new instance with configuration that uses specified View for filtering.

Note that the method does NOT change state of this reader, but rather construct and returns a newly configured instance.

 
     public ObjectReader withView(Class<?> activeView) {
         return _with(.withView(activeView));
     }
 
     public ObjectReader with(Locale l) {
         return _with(.with(l));
     }
 
     public ObjectReader with(TimeZone tz) {
         return _with(.with(tz));
     }
 
         return _with(.withHandler(h));
     }
 
     public ObjectReader with(Base64Variant defaultBase64) {
         return _with(.with(defaultBase64));
     }

    
Fluent factory method for constructing a reader that will try to auto-detect underlying data format, using specified list of com.fasterxml.jackson.core.JsonFactory instances, and default com.fasterxml.jackson.databind.deser.DataFormatReaders settings (for customized com.fasterxml.jackson.databind.deser.DataFormatReaders, you can construct instance yourself). to construct appropriate com.fasterxml.jackson.core.JsonParser for actual parsing.

Note: since format detection only works with byte sources, it is possible to get a failure from some 'readValue()' methods. Also, if input can not be reliably (enough) detected as one of specified types, an exception will be thrown.

Note: not all com.fasterxml.jackson.core.JsonFactory types can be passed: specifically, ones that require "custom codec" (like XML factory) will not work. Instead, use method that takes ObjectReader instances instead of factories.

Parameters:
readers Data formats accepted, in decreasing order of priority (that is, matches checked in listed order, first match wins)
Returns:
Newly configured writer instance
Since:
2.1
 
     public ObjectReader withFormatDetection(ObjectReader... readers)
     {
         return withFormatDetection(new DataFormatReaders(readers));
     }

    
Fluent factory method for constructing a reader that will try to auto-detect underlying data format, using specified com.fasterxml.jackson.databind.deser.DataFormatReaders.

NOTE: since format detection only works with byte sources, it is possible to get a failure from some 'readValue()' methods. Also, if input can not be reliably (enough) detected as one of specified types, an exception will be thrown.

Parameters:
readers DataFormatReaders to use for detecting underlying format.
Returns:
Newly configured writer instance
Since:
2.1
 
     {
         return new ObjectReader(this,
                 readers);
     }
     
     /*
     /**********************************************************
     /* Simple accessors
     /**********************************************************
      */
     
     public boolean isEnabled(DeserializationFeature f) {
         return .isEnabled(f);
     }
 
     public boolean isEnabled(MapperFeature f) {
         return .isEnabled(f);
     }
 
     public boolean isEnabled(JsonParser.Feature f) {
         return .isEnabled(f);
     }
 
     @Override
     public JsonFactory getFactory() {
         return ;
     }
    
    

Deprecated:
Since 2.1: Use getFactory() instead
 
     @Deprecated
     @Override
     public JsonFactory getJsonFactory() {
         return ;
     }
 
     public TypeFactory getTypeFactory() {
         return .getTypeFactory();
     }
     
     /*
     /**********************************************************
     /* Deserialization methods; basic ones to support ObjectCodec first
     /* (ones that take JsonParser)
     /**********************************************************
      */

    
Method that binds content read using given parser, using configuration of this reader, including expected result type. Value return is either newly constructed, or root value that was specified with withValueToUpdate(java.lang.Object).

NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.

 
     @SuppressWarnings("unchecked")
     public <T> T readValue(JsonParser jp)
         throws IOExceptionJsonProcessingException
     {
         return (T) _bind(jp);
     }

    
Convenience method that binds content read using given parser, using configuration of this reader, except that expected value type is specified with the call (instead of currently configured root type). Value return is either newly constructed, or root value that was specified with withValueToUpdate(java.lang.Object).

NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.

 
     @SuppressWarnings("unchecked")
     @Override
     public <T> T readValue(JsonParser jpClass<T> valueType)
         throws IOExceptionJsonProcessingException
     {
         return (T) withType(valueType).readValue(jp);
     }

    
Convenience method that binds content read using given parser, using configuration of this reader, except that expected value type is specified with the call (instead of currently configured root type). Value return is either newly constructed, or root value that was specified with withValueToUpdate(java.lang.Object).

NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.

 
     @SuppressWarnings("unchecked")
     @Override
     public <T> T readValue(JsonParser jpTypeReference<?> valueTypeRef)
         throws IOExceptionJsonProcessingException
     {
         return (T) withType(valueTypeRef).readValue(jp);
     }

    
Convenience method that binds content read using given parser, using configuration of this reader, except that expected value type is specified with the call (instead of currently configured root type). Value return is either newly constructed, or root value that was specified with withValueToUpdate(java.lang.Object).

NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.

 
     @Override
     @SuppressWarnings("unchecked")
     public <T> T readValue(JsonParser jpResolvedType valueTypethrows IOExceptionJsonProcessingException {
         return (T) withType((JavaType)valueType).readValue(jp);
     }

    
Type-safe overloaded method, basically alias for readValue(com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.core.type.ResolvedType).

NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.

 
     @SuppressWarnings("unchecked")
     public <T> T readValue(JsonParser jpJavaType valueTypethrows IOExceptionJsonProcessingException {
         return (T) withType(valueType).readValue(jp);
     }
    
    
Convenience method that binds content read using given parser, using configuration of this reader, except that content is bound as JSON tree instead of configured root value type.

Note: if an object was specified with withValueToUpdate(java.lang.Object), it will be ignored.

NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.

 
     @SuppressWarnings("unchecked")
     @Override
     public <T extends TreeNode> T readTree(JsonParser jp)
         throws IOExceptionJsonProcessingException
     {
         return (T) _bindAsTree(jp);
     }

    
Convenience method that is equivalent to:
   withType(valueType).readValues(jp);

NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.

 
     @Override
     public <T> Iterator<T> readValues(JsonParser jpClass<T> valueType)
         throws IOExceptionJsonProcessingException {
         return withType(valueType).readValues(jp);
     }

    
Convenience method that is equivalent to:
   withType(valueTypeRef).readValues(jp);

NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.

 
     @Override
     public <T> Iterator<T> readValues(JsonParser jpTypeReference<?> valueTypeRef)
         throws IOExceptionJsonProcessingException {
         return withType(valueTypeRef).readValues(jp);
     }
    
    
Convenience method that is equivalent to:
   withType(valueType).readValues(jp);

NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.

 
     @Override
     public <T> Iterator<T> readValues(JsonParser jpResolvedType valueType)
         throws IOExceptionJsonProcessingException {
         return readValues(jp, (JavaTypevalueType);
     }

    
Convenience method that is equivalent to:
   withType(valueType).readValues(jp);

NOTE: this method never tries to auto-detect format, since actual (data-format specific) parser is given.

 
     public <T> Iterator<T> readValues(JsonParser jpJavaType valueType)
         throws IOExceptionJsonProcessingException {
         return withType(valueType).readValues(jp);
     }
     
     /*
     /**********************************************************
     /* Deserialization methods; others similar to what ObjectMapper has
     /**********************************************************
      */
    
    
Method that binds content read from given input source, using configuration of this reader. Value return is either newly constructed, or root value that was specified with withValueToUpdate(java.lang.Object).
 
     @SuppressWarnings("unchecked")
     public <T> T readValue(InputStream src)
         throws IOExceptionJsonProcessingException
     {
         if ( != null) {
             return (T) _detectBindAndClose(.findFormat(src), false);
         }
         return (T) _bindAndClose(.createJsonParser(src), );
     }

    
Method that binds content read from given input source, using configuration of this reader. Value return is either newly constructed, or root value that was specified with withValueToUpdate(java.lang.Object).
 
     @SuppressWarnings("unchecked")
     public <T> T readValue(Reader src)
         throws IOExceptionJsonProcessingException
     {
         if ( != null) {
             _reportUndetectableSource(src);
         }
         return (T) _bindAndClose(.createJsonParser(src), );
     }
    
    
Method that binds content read from given JSON string, using configuration of this reader. Value return is either newly constructed, or root value that was specified with withValueToUpdate(java.lang.Object).
 
     @SuppressWarnings("unchecked")
     public <T> T readValue(String src)
         throws IOExceptionJsonProcessingException
     {
         if ( != null) {
             _reportUndetectableSource(src);
         }
         return (T) _bindAndClose(.createJsonParser(src), );
     }

    
Method that binds content read from given byte array, using configuration of this reader. Value return is either newly constructed, or root value that was specified with withValueToUpdate(java.lang.Object).
 
     @SuppressWarnings("unchecked")
     public <T> T readValue(byte[] src)
         throws IOExceptionJsonProcessingException
     {
         if ( != null) {
             return (T) _detectBindAndClose(src, 0, src.length);
         }
         return (T) _bindAndClose(.createJsonParser(src), );
     }

    
Method that binds content read from given byte array, using configuration of this reader. Value return is either newly constructed, or root value that was specified with withValueToUpdate(java.lang.Object).
 
     @SuppressWarnings("unchecked")
     public <T> T readValue(byte[] srcint offsetint length)
         throws IOExceptionJsonProcessingException
     {
         if ( != null) {
             return (T) _detectBindAndClose(srcoffsetlength);
         }
         return (T) _bindAndClose(.createJsonParser(srcoffsetlength), );
     }
     
     @SuppressWarnings("unchecked")
     public <T> T readValue(File src)
         throws IOExceptionJsonProcessingException
     {
         if ( != null) {
             return (T) _detectBindAndClose(.findFormat(_inputStream(src)), true);
         }
         return (T) _bindAndClose(.createJsonParser(src), );
     }

    
Method that binds content read from given input source, using configuration of this reader. Value return is either newly constructed, or root value that was specified with withValueToUpdate(java.lang.Object).
 
     @SuppressWarnings("unchecked")
     public <T> T readValue(URL src)
         throws IOExceptionJsonProcessingException
     {
         if ( != null) {
             return (T) _detectBindAndClose(.findFormat(_inputStream(src)), true);
         }
         return (T) _bindAndClose(.createJsonParser(src), );
     }

    
Convenience method for converting results from given JSON tree into given value type. Basically short-cut for:
   objectReader.readValue(src.traverse())
 
     @SuppressWarnings("unchecked")
     public <T> T readValue(JsonNode src)
         throws IOExceptionJsonProcessingException
     {
         if ( != null) {
             _reportUndetectableSource(src);
         }
         return (T) _bindAndClose(treeAsTokens(src), );
     }
    
    
Method that reads content from given input source, using configuration of this reader, and binds it as JSON Tree.

Note that if an object was specified with a call to withValueToUpdate(java.lang.Object) it will just be ignored; result is always a newly constructed JsonNode instance.

 
     public JsonNode readTree(InputStream in)
         throws IOExceptionJsonProcessingException
     {
         if ( != null) {
             return _detectBindAndCloseAsTree(in);
         }
         return _bindAndCloseAsTree(.createJsonParser(in));
     }
    
    
Method that reads content from given input source, using configuration of this reader, and binds it as JSON Tree.

Note that if an object was specified with a call to withValueToUpdate(java.lang.Object) it will just be ignored; result is always a newly constructed JsonNode instance.

 
     public JsonNode readTree(Reader r)
         throws IOExceptionJsonProcessingException
     {
         if ( != null) {
             _reportUndetectableSource(r);
         }
     }

    
Method that reads content from given JSON input String, using configuration of this reader, and binds it as JSON Tree.

Note that if an object was specified with a call to withValueToUpdate(java.lang.Object) it will just be ignored; result is always a newly constructed JsonNode instance.

 
     public JsonNode readTree(String json)
         throws IOExceptionJsonProcessingException
     {
         if ( != null) {
             _reportUndetectableSource(json);
         }
         return _bindAndCloseAsTree(.createJsonParser(json));
     }
 
     /*
     /**********************************************************
     /* Deserialization methods; reading sequence of values
     /**********************************************************
      */
    
    
Method for reading sequence of Objects from parser stream.

Sequence can be either root-level "unwrapped" sequence (without surrounding JSON array), or a sequence contained in a JSON Array. In either case com.fasterxml.jackson.core.JsonParser must point to the first token of the first element, OR not point to any token (in which case it is advanced to the next token). This means, specifically, that for wrapped sequences, parser MUST NOT point to the surrounding START_ARRAY but rather to the token following it.

 
     public <T> MappingIterator<T> readValues(JsonParser jp)
         throws IOExceptionJsonProcessingException
     {
         // false -> do not close as caller gave parser instance
         return new MappingIterator<T>(jpctxt,
                 _findRootDeserializer(ctxt),
                 false);
     }
    
    
Method for reading sequence of Objects from parser stream.

Sequence can be either wrapped or unwrapped root-level sequence: wrapped means that the elements are enclosed in JSON Array; and unwrapped that elements are directly accessed at main level. Assumption is that iff the first token of the document is START_ARRAY, we have a wrapped sequence; otherwise unwrapped. For wrapped sequences, leading START_ARRAY is skipped, so that for both cases, underlying com.fasterxml.jackson.core.JsonParser will point to what is expected to be the first token of the first element.

Note that the wrapped vs unwrapped logic means that it is NOT possible to use this method for reading an unwrapped sequence of elements written as JSON Arrays: to read such sequences, one has to use readValues(com.fasterxml.jackson.core.JsonParser), making sure parser points to the first token of the first element (i.e. the second START_ARRAY which is part of the first element).

 
     public <T> MappingIterator<T> readValues(InputStream src)
        throws IOExceptionJsonProcessingException
    {
        if ( != null) {
            return _detectBindAndReadValues(.findFormat(src), false);
        }
    }
    
    
Overloaded version of readValue(java.io.InputStream).
    public <T> MappingIterator<T> readValues(Reader src)
        throws IOExceptionJsonProcessingException
    {
        if ( != null) {
            _reportUndetectableSource(src);
        }
        JsonParser jp = .createJsonParser(src);
        if ( != null) {
            jp.setSchema();
        }
        jp.nextToken();
        return new MappingIterator<T>(jpctxt,
                _findRootDeserializer(ctxt), true);
    }
    
    
Overloaded version of readValue(java.io.InputStream).

Parameters:
json String that contains JSON content to parse
    public <T> MappingIterator<T> readValues(String json)
        throws IOExceptionJsonProcessingException
    {
        if ( != null) {
            _reportUndetectableSource(json);
        }
        JsonParser jp = .createJsonParser(json);
        if ( != null) {
            jp.setSchema();
        }
        jp.nextToken();
        return new MappingIterator<T>(jpctxt,
                _findRootDeserializer(ctxt), true);
    }

    
Overloaded version of readValue(java.io.InputStream).
    public <T> MappingIterator<T> readValues(byte[] srcint offsetint length)
        throws IOExceptionJsonProcessingException
    {
        if ( != null) {
            return _detectBindAndReadValues(.findFormat(srcoffsetlength), false);
        }
    }

    
Overloaded version of readValue(java.io.InputStream).
    public final <T> MappingIterator<T> readValues(byte[] src)
            throws IOExceptionJsonProcessingException {
        return readValues(src, 0, src.length);
    }
    
    
Overloaded version of readValue(java.io.InputStream).
    public <T> MappingIterator<T> readValues(File src)
        throws IOExceptionJsonProcessingException
    {
        if ( != null) {
            return _detectBindAndReadValues(
                    .findFormat(_inputStream(src)), false);
        }
    }

    
Overloaded version of readValue(java.io.InputStream).

Parameters:
src URL to read to access JSON content to parse.
    public <T> MappingIterator<T> readValues(URL src)
        throws IOExceptionJsonProcessingException
    {
        if ( != null) {
            return _detectBindAndReadValues(
                    .findFormat(_inputStream(src)), true);
        }
    }
    /*
    /**********************************************************
    /* Implementation of rest of ObjectCodec methods
    /**********************************************************
     */
    
    @Override
    public JsonNode createArrayNode() {
        return .getNodeFactory().arrayNode();
    }
    @Override
    public JsonNode createObjectNode() {
        return .getNodeFactory().objectNode();
    }
    @Override
    public JsonParser treeAsTokens(TreeNode n) {
        return new TreeTraversingParser((JsonNodenthis);
    }
    @Override
    public <T> T treeToValue(TreeNode nClass<T> valueType)
        throws JsonProcessingException
    {
        try {
            return readValue(treeAsTokens(n), valueType);
        } catch (JsonProcessingException e) {
            throw e;
        } catch (IOException e) { // should not occur, no real i/o...
            throw new IllegalArgumentException(e.getMessage(), e);
        }
    }
    @Override
    public void writeValue(JsonGenerator jgenObject valuethrows IOExceptionJsonProcessingException
    {
        throw new UnsupportedOperationException("Not implemented for ObjectReader");
    }
    /*
    /**********************************************************
    /* Helper methods, data-binding
    /**********************************************************
     */
    
    
Actual implementation of value reading+binding operation.
    protected Object _bind(JsonParser jpObject valueToUpdate)
    {
        /* First: may need to read the next token, to initialize state (either
         * before first read from parser, or after previous token has been cleared)
         */
        Object result;
        JsonToken t = _initForReading(jp);
        if (t == .) {
            if (valueToUpdate == null) {
                DeserializationContext ctxt = createDeserializationContext(jp);
                result = _findRootDeserializer(ctxt).getNullValue();
            } else {
                result = valueToUpdate;
            }
        } else if (t == . || t == .) {
            result = valueToUpdate;
        } else { // pointing to event other than null
            DeserializationContext ctxt = createDeserializationContext(jp);
            JsonDeserializer<Objectdeser = _findRootDeserializer(ctxt);
            if () {
                result = _unwrapAndDeserialize(jpctxtdeser);
            } else {
                if (valueToUpdate == null) {
                    result = deser.deserialize(jpctxt);
                } else {
                    deser.deserialize(jpctxtvalueToUpdate);
                    result = valueToUpdate;
                }
            }
        }
        // Need to consume the token too
        jp.clearCurrentToken();
        return result;
    }
    
    protected Object _bindAndClose(JsonParser jpObject valueToUpdate)
    {
        if ( != null) {
            jp.setSchema();
        }
        try {
            Object result;
            JsonToken t = _initForReading(jp);
            if (t == .) {
                if (valueToUpdate == null) {
                    DeserializationContext ctxt = createDeserializationContext(jp);
                    result = _findRootDeserializer(ctxt).getNullValue();
                } else {
                    result = valueToUpdate;
                }
            } else if (t == . || t == .) {
                result = valueToUpdate;
            } else {
                DeserializationContext ctxt = createDeserializationContext(jp);
                JsonDeserializer<Objectdeser = _findRootDeserializer(ctxt);
                if () {
                    result = _unwrapAndDeserialize(jpctxtdeser);
                } else {
                    if (valueToUpdate == null) {
                        result = deser.deserialize(jpctxt);
                    } else {
                        deser.deserialize(jpctxtvalueToUpdate);
                        result = valueToUpdate;                    
                    }
                }
            }
            return result;
        } finally {
            try {
                jp.close();
            } catch (IOException ioe) { }
        }
    }
    protected JsonNode _bindAsTree(JsonParser jp)
    {
        JsonNode result;
        JsonToken t = _initForReading(jp);
        if (t == . || t == . || t == .) {
            result = .;
        } else {
            DeserializationContext ctxt = createDeserializationContext(jp);
            JsonDeserializer<Objectdeser = _findRootDeserializer(ctxt);
            if () {
                result = (JsonNode_unwrapAndDeserialize(jpctxtdeser);
            } else {
                result = (JsonNodedeser.deserialize(jpctxt);
            }
        }
        // Need to consume the token too
        jp.clearCurrentToken();
        return result;
    }
    
    {
        if ( != null) {
            jp.setSchema();
        }
        try {
            return _bindAsTree(jp);
        } finally {
            try {
                jp.close();
            } catch (IOException ioe) { }
        }
    }
    
    

Since:
2.1
    protected <T> MappingIterator<T> _bindAndReadValues(JsonParser p,
            Object valueToUpdate)
        throws IOExceptionJsonProcessingException
    {
        if ( != null) {
            p.setSchema();
        }
        p.nextToken();
        return new MappingIterator<T>(pctxt
                _findRootDeserializer(ctxt),
                true);
    }
    
    protected static JsonToken _initForReading(JsonParser jp)
    {
        /* First: must point to a token; if not pointing to one, advance.
         * This occurs before first read from JsonParser, as well as
         * after clearing of current token.
         */
        JsonToken t = jp.getCurrentToken();
        if (t == null) { // and then we must get something...
            t = jp.nextToken();
            if (t == null) {
                /* [JACKSON-546] Throw mapping exception, since it's failure to map,
                 *   not an actual parsing problem
                 */
                throw JsonMappingException.from(jp"No content to map due to end-of-input");
            }
        }
        return t;
    }

    
Method called to locate deserializer for the passed root-level value.
            JavaType valueType)
        throws JsonMappingException
    {
        if ( != null) {
            return ;
        }
        // Sanity check: must have actual type...
        if (valueType == null) {
            throw new JsonMappingException("No value type configured for ObjectReader");
        }
        
        // First: have we already seen it?
        JsonDeserializer<Objectdeser = .get(valueType);
        if (deser != null) {
            return deser;
        }
        // Nope: need to ask provider to resolve it
        deser = ctxt.findRootValueDeserializer(valueType);
        if (deser == null) { // can this happen?
            throw new JsonMappingException("Can not find a deserializer for type "+valueType);
        }
        .put(valueTypedeser);
        return deser;
    }

    
Method called to locate deserializer ahead of time, if permitted by configuration. Method also is NOT to throw an exception if access fails.
            DeserializationConfig configJavaType valueType)
    {
        if (valueType == null || !.isEnabled(.)) {
            return null;
        }
        // already cached?
        JsonDeserializer<Objectdeser = .get(valueType);
        if (deser == null) {
            try {
                // If not, need to resolve; for which we need a temporary context as well:
                DeserializationContext ctxt = createDeserializationContext(null);
                deser = ctxt.findRootValueDeserializer(valueType);
                if (deser != null) {
                    .put(valueTypedeser);
                }
                return deser;
                
            } catch (JsonProcessingException e) {
                // need to swallow?
            }
        }
        return deser;
    }
    
            JavaType rootTypeJsonDeserializer<Objectdeser)
    {
        String expName = .getRootName();
        if (expName == null) {
            SerializedString sstr = .findRootName(rootType);
            expName = sstr.getValue();
        }
        if (jp.getCurrentToken() != .) {
            throw JsonMappingException.from(jp"Current token not START_OBJECT (needed to unwrap root name '"
                    +expName+"'), but "+jp.getCurrentToken());
        }
        if (jp.nextToken() != .) {
            throw JsonMappingException.from(jp"Current token not FIELD_NAME (to contain expected root name '"
                    +expName+"'), but "+jp.getCurrentToken());
        }
        String actualName = jp.getCurrentName();
        if (!expName.equals(actualName)) {
            throw JsonMappingException.from(jp"Root name '"+actualName+"' does not match expected ('"
                    +expName+"') for type "+rootType);
        }
        // ok, then move to value itself....
        jp.nextToken();
        Object result;
        if ( == null) {
            result = deser.deserialize(jpctxt);
        } else {
            deser.deserialize(jpctxt);
            result = ;                    
        }
        // and last, verify that we now get matching END_OBJECT
        if (jp.nextToken() != .) {
            throw JsonMappingException.from(jp"Current token not END_OBJECT (to match wrapper object with root name '"
                    +expName+"'), but "+jp.getCurrentToken());
        }
        return result;
    }
    /*
    /**********************************************************
    /* Internal methods, format auto-detection (since 2.1)