java.lang.Object
tools.jackson.core.TokenStreamContext
tools.jackson.core.util.SimpleStreamReadContext
Basic implementation of
TokenStreamContext useful for most
format backend JsonParser implementations
(with notable exception of JSON that needs bit more advanced state).- Since:
- 3.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SimpleStreamReadContextprotected intprotected Stringprotected Objectprotected DupDetectorprotected intprotected final SimpleStreamReadContextParent context for this context; null for root context.Fields inherited from class tools.jackson.core.TokenStreamContext
_index, _nestingDepth, _type, TYPE_ARRAY, TYPE_OBJECT, TYPE_ROOT -
Constructor Summary
ConstructorsConstructorDescriptionSimpleStreamReadContext(int type, SimpleStreamReadContext parent, int nestingDepth, DupDetector dups, int lineNr, int colNr) SimpleStreamReadContext(int type, SimpleStreamReadContext parent, DupDetector dups, int lineNr, int colNr) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionprotected void_checkDup(DupDetector dd, String name) voidMethod to call to pass value to be returned viaTokenStreamContext.currentValue(); typically called indirectly throughJsonParser.assignCurrentValue(java.lang.Object)orJsonGenerator.assignCurrentValue(java.lang.Object)).Method that can be used to both clear the accumulated references (specifically value set withassignCurrentValue(Object)) that should not be retained, and returns parent (as wouldgetParent()do).createChildArrayContext(int lineNr, int colNr) createChildObjectContext(int lineNr, int colNr) static SimpleStreamReadContextcreateRootContext(int lineNr, int colNr, DupDetector dups) static SimpleStreamReadContextcreateRootContext(DupDetector dups) Method for accessing name associated with the current location.Method for accessing currently active value being used by data-binding (as the source of streaming data to write, or destination of data being read), at this level in hierarchy.Accessor for finding parent context of this context; will return null for root context.booleanprotected voidreset(int type, int lineNr, int colNr) voidsetCurrentName(String name) Method called to indicate what the "current" name (Object property name just decoded) is: may also trigger duplicate detection.startLocation(ContentReference srcRef) Optional method that may be used to access starting location of this context: for example, in case of JSON `Object` context, offset at which `[` token was read or written.intMethod to call to advance index within current context: to be called when a new token found within current context (property name for objects, value for root and array contexts)Methods inherited from class tools.jackson.core.TokenStreamContext
getCurrentIndex, getEntryCount, getNestingDepth, hasCurrentIndex, hasPathSegment, inArray, inObject, inRoot, pathAsPointer, pathAsPointer, toString, typeDesc
-
Field Details
-
_parent
Parent context for this context; null for root context. -
_dups
-
_childToRecycle
-
_currentName
-
_currentValue
-
_lineNr
protected int _lineNr -
_columnNr
protected int _columnNr
-
-
Constructor Details
-
SimpleStreamReadContext
public SimpleStreamReadContext(int type, SimpleStreamReadContext parent, int nestingDepth, DupDetector dups, int lineNr, int colNr) -
SimpleStreamReadContext
@Deprecated public SimpleStreamReadContext(int type, SimpleStreamReadContext parent, DupDetector dups, int lineNr, int colNr) Deprecated.
-
-
Method Details
-
reset
protected void reset(int type, int lineNr, int colNr) -
currentValue
Description copied from class:TokenStreamContextMethod for accessing currently active value being used by data-binding (as the source of streaming data to write, or destination of data being read), at this level in hierarchy.Note that "current value" is NOT populated (or used) by Streaming parser or generator; it is only used by higher-level data-binding functionality. The reason it is included here is that it can be stored and accessed hierarchically, and gets passed through data-binding.
- Overrides:
currentValuein classTokenStreamContext- Returns:
- Currently active value, if one has been assigned.
-
assignCurrentValue
Description copied from class:TokenStreamContextMethod to call to pass value to be returned viaTokenStreamContext.currentValue(); typically called indirectly throughJsonParser.assignCurrentValue(java.lang.Object)orJsonGenerator.assignCurrentValue(java.lang.Object)).- Overrides:
assignCurrentValuein classTokenStreamContext- Parameters:
v- Current value to assign to this context
-
createRootContext
-
createRootContext
-
createChildArrayContext
-
createChildObjectContext
-
currentName
Description copied from class:TokenStreamContextMethod for accessing name associated with the current location. Non-null forPROPERTY_NAMEand value events that directly follow Property names; null for root level and array values.- Specified by:
currentNamein classTokenStreamContext- Returns:
- Current property name within context, if any;
nullif none - Since:
- 3.0
-
hasCurrentName
public boolean hasCurrentName()- Overrides:
hasCurrentNamein classTokenStreamContext
-
getParent
Description copied from class:TokenStreamContextAccessor for finding parent context of this context; will return null for root context.- Specified by:
getParentin classTokenStreamContext- Returns:
- Parent context of this context, if any;
nullfor Root contexts
-
startLocation
Description copied from class:TokenStreamContextOptional method that may be used to access starting location of this context: for example, in case of JSON `Object` context, offset at which `[` token was read or written. Often used for error reporting purposes. Implementations that do not keep track of such location are expected to returnTokenStreamLocation.NA; this is what the default implementation does.- Overrides:
startLocationin classTokenStreamContext- Parameters:
srcRef- Source reference needed to construct location instance- Returns:
- Location pointing to the point where the context
start marker was found (or written); never
null.
-
clearAndGetParent
Method that can be used to both clear the accumulated references (specifically value set withassignCurrentValue(Object)) that should not be retained, and returns parent (as wouldgetParent()do). Typically called when closing the active context when encounteringJsonToken.END_ARRAYorJsonToken.END_OBJECT.- Returns:
- Parent context of this context node, if any;
nullfor root context
-
getDupDetector
-
valueRead
public int valueRead()Method to call to advance index within current context: to be called when a new token found within current context (property name for objects, value for root and array contexts)- Returns:
- Index after increment
-
setCurrentName
Method called to indicate what the "current" name (Object property name just decoded) is: may also trigger duplicate detection.- Parameters:
name- Name of Object property encountered- Throws:
StreamReadException- If there is a duplicate name violation
-
_checkDup
- Throws:
StreamReadException
-