Class MappingIterator<T>
java.lang.Object
edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.MappingIterator<T>
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterator<T>
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)-
Field Summary
Modifier and TypeFieldDescriptionprotected final boolean
Flag that indicates whether inputJsonParser
should be closed when we are done or not; generally only called when caller did not pass JsonParser.protected final DeserializationContext
Context for deserialization, needed to pass through to deserializerprotected final JsonDeserializer<T>
Deserializer for individual element values.protected final JsonParser
Underlying parser used for reading content to bind.protected final JsonStreamContext
Context to resynchronize to, in case an exception is encountered but caller wants to try to read more elements.protected int
State of the iteratorprotected final JavaType
Type to bind individual elements to.protected final T
If not null, "value to update" instead of creating a new instance for each call.protected static final MappingIterator<?>
protected static final int
State in which iterator is closedprotected static final int
State in which "hasNextValue()" has been succesfully called and deserializer can be called to fetch valueprotected static final int
State in which no recovery is needed, but "hasNextValue()" needs to be called firstprotected static final int
State in which value read failed -
Constructor Summary
ModifierConstructorDescriptionprotected
MappingIterator
(JavaType type, JsonParser p, DeserializationContext ctxt, JsonDeserializer<?> deser, boolean managedParser, Object valueToUpdate) -
Method Summary
Modifier and TypeMethodDescriptionprotected <R> R
protected <R> R
protected void
_resync()
protected <R> R
void
close()
static <T> MappingIterator<T>
Method for getting an "empty" iterator instance: one that never has more values; may be freely shared.Convenience method, functionally equivalent to:iterator.getParser().getCurrentLocation()
Accessor for getting underlying parser this iterator uses.Accessor for accessingFormatSchema
that the underlying parser (as pergetParser()
) is using, if any; only parser of schema-aware formats use schemas.boolean
hasNext()
boolean
Equivalent ofnext()
but one that may throw checked exceptions from Jackson due to invalid input.next()
readAll()
Convenience method for reading all entries accessible via this iterator; resulting container will be aArrayList
.<C extends Collection<? super T>>
CreadAll
(C results) Convenience method for reading all entries accessible via this iteratorreadAll
(L resultList) Convenience method for reading all entries accessible via this iteratorvoid
remove()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
EMPTY_ITERATOR
-
STATE_CLOSED
protected static final int STATE_CLOSEDState in which iterator is closed- See Also:
-
STATE_NEED_RESYNC
protected static final int STATE_NEED_RESYNCState in which value read failed- See Also:
-
STATE_MAY_HAVE_VALUE
protected static final int STATE_MAY_HAVE_VALUEState in which no recovery is needed, but "hasNextValue()" needs to be called first- See Also:
-
STATE_HAS_VALUE
protected static final int STATE_HAS_VALUEState in which "hasNextValue()" has been succesfully called and deserializer can be called to fetch value- See Also:
-
_type
Type to bind individual elements to. -
_context
Context for deserialization, needed to pass through to deserializer -
_deserializer
Deserializer for individual element values. -
_parser
Underlying parser used for reading content to bind. Initialized as notnull
but set asnull
when iterator is closed, to denote closing. -
_seqContext
Context to resynchronize to, in case an exception is encountered but caller wants to try to read more elements. -
_updatedValue
If not null, "value to update" instead of creating a new instance for each call. -
_closeParser
protected final boolean _closeParserFlag that indicates whether inputJsonParser
should be closed when we are done or not; generally only called when caller did not pass JsonParser. -
_state
protected int _stateState of the iterator
-
-
Constructor Details
-
MappingIterator
protected MappingIterator(JavaType type, JsonParser p, DeserializationContext ctxt, JsonDeserializer<?> deser, boolean managedParser, Object valueToUpdate) - Parameters:
managedParser
- Whether we "own" theJsonParser
passed or not: if true, it was created byObjectReader
and code here needs to close it; if false, it was passed by calling code and should not be closed by iterator.
-
-
Method Details
-
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() -
next
-
remove
public void remove() -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
hasNextValue
Equivalent ofnext()
but one that may throw checked exceptions from Jackson due to invalid input.- Throws:
IOException
-
nextValue
- Throws:
IOException
-
readAll
Convenience method for reading all entries accessible via this iterator; resulting container will be aArrayList
.- Returns:
- List of entries read
- Throws:
IOException
- Since:
- 2.2
-
readAll
Convenience method for reading all entries accessible via this iterator- Returns:
- List of entries read (same as passed-in argument)
- Throws:
IOException
- Since:
- 2.2
-
readAll
Convenience method for reading all entries accessible via this iterator- Throws:
IOException
- Since:
- 2.5
-
getParser
Accessor for getting underlying parser this iterator uses.- Since:
- 2.2
-
getParserSchema
Accessor for accessingFormatSchema
that the underlying parser (as pergetParser()
) is using, if any; only parser of schema-aware formats use schemas.- Since:
- 2.2
-
getCurrentLocation
Convenience method, functionally equivalent to:iterator.getParser().getCurrentLocation()
- Returns:
- Location of the input stream of the underlying parser
- Since:
- 2.2.1
-
_resync
- Throws:
IOException
-
_throwNoSuchElement
protected <R> R _throwNoSuchElement() -
_handleMappingException
-
_handleIOException
-