Class MappingIterator<T>

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.util.Iterator<T>

    public class MappingIterator<T>
    extends java.lang.Object
    implements java.util.Iterator<T>, java.io.Closeable
    Iterator exposed by ObjectMapper when binding sequence of objects. Extension is done to allow more convenient exposing of IOException (which basic Iterator does not expose)
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      static <T> MappingIterator<T> emptyIterator()
      Method for getting an "empty" iterator instance: one that never has more values; may be freely shared.
      JsonLocation getCurrentLocation()
      Convenience method, functionally equivalent to: iterator.getParser().getCurrentLocation()
      JsonParser getParser()
      Accessor for getting underlying parser this iterator uses.
      FormatSchema getParserSchema()
      Accessor for accessing FormatSchema that the underlying parser (as per getParser()) is using, if any; only parser of schema-aware formats use schemas.
      boolean hasNext()  
      boolean hasNextValue()
      Equivalent of next() but one that may throw checked exceptions from Jackson due to invalid input.
      T next()  
      T nextValue()  
      java.util.List<T> readAll()
      Convenience method for reading all entries accessible via this iterator; resulting container will be a ArrayList.
      <C extends java.util.Collection<? super T>>
      C
      readAll​(C results)
      Convenience method for reading all entries accessible via this iterator
      <L extends java.util.List<? super T>>
      L
      readAll​(L resultList)
      Convenience method for reading all entries accessible via this iterator
      void remove()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Method Detail

      • emptyIterator

        public static <T> MappingIterator<T> emptyIterator()
        Method for getting an "empty" iterator instance: one that never has more values; may be freely shared.
        Since:
        2.10 Existed earlier but public since 2.10
      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<T>
      • next

        public T next()
        Specified by:
        next in interface java.util.Iterator<T>
      • remove

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<T>
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • hasNextValue

        public boolean hasNextValue()
                             throws java.io.IOException
        Equivalent of next() but one that may throw checked exceptions from Jackson due to invalid input.
        Throws:
        java.io.IOException
      • nextValue

        public T nextValue()
                    throws java.io.IOException
        Throws:
        java.io.IOException
      • readAll

        public java.util.List<T> readAll()
                                  throws java.io.IOException
        Convenience method for reading all entries accessible via this iterator; resulting container will be a ArrayList.
        Returns:
        List of entries read
        Throws:
        java.io.IOException
        Since:
        2.2
      • readAll

        public <L extends java.util.List<? super T>> L readAll​(L resultList)
                                                        throws java.io.IOException
        Convenience method for reading all entries accessible via this iterator
        Returns:
        List of entries read (same as passed-in argument)
        Throws:
        java.io.IOException
        Since:
        2.2
      • readAll

        public <C extends java.util.Collection<? super T>> C readAll​(C results)
                                                              throws java.io.IOException
        Convenience method for reading all entries accessible via this iterator
        Throws:
        java.io.IOException
        Since:
        2.5
      • getParser

        public JsonParser getParser()
        Accessor for getting underlying parser this iterator uses.
        Since:
        2.2
      • getParserSchema

        public FormatSchema getParserSchema()
        Accessor for accessing FormatSchema that the underlying parser (as per getParser()) is using, if any; only parser of schema-aware formats use schemas.
        Since:
        2.2
      • getCurrentLocation

        public JsonLocation getCurrentLocation()
        Convenience method, functionally equivalent to: iterator.getParser().getCurrentLocation()
        Returns:
        Location of the input stream of the underlying parser
        Since:
        2.2.1