java.lang.Object
tools.jackson.core.TokenStreamContext
tools.jackson.core.json.JsonReadContext
Extension of
TokenStreamContext, which implements
core methods needed, and also exposes
more complete API to parser implementation classes.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JsonReadContextprotected intprotected Stringprotected Objectprotected DupDetectorprotected intprotected final JsonReadContextParent 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
ConstructorsConstructorDescriptionJsonReadContext(JsonReadContext parent, int nestingDepth, DupDetector dups, int type, int lineNr, int colNr) -
Method Summary
Modifier and TypeMethodDescriptionvoidMethod 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 JsonReadContextcreateRootContext(int lineNr, int colNr, DupDetector dups) static JsonReadContextcreateRootContext(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.booleanAccessor for finding parent context of this context; will return null for root context.booleanreset(int type, int lineNr, int colNr) Internal method to allow instance reuse: DO NOT USE unless you absolutely know what you are doing.voidsetCurrentName(String name) Method that parser is to call when it reads a name of Object property.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.withDupDetector(DupDetector dups) 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
-
_child
-
_currentName
-
_currentValue
-
_lineNr
protected int _lineNr -
_columnNr
protected int _columnNr
-
-
Constructor Details
-
JsonReadContext
public JsonReadContext(JsonReadContext parent, int nestingDepth, DupDetector dups, int type, int lineNr, int colNr) - Parameters:
parent- Parent context, if any (nullfor Root context)nestingDepth- Number of parents this context has (0 for Root context)dups- Detector used for checking duplicate names, if any (nullif none)type- Type to assign to this context nodelineNr- Line of the starting position of this contextcolNr- Column of the starting position of this context- Since:
- 2.15
-
-
Method Details
-
reset
Internal method to allow instance reuse: DO NOT USE unless you absolutely know what you are doing. Clears up state (including "current value"), changes type to one specified; resets current duplicate-detection state (if any). Parent link left as-is since it isfinal.- Parameters:
type- Type to assign to this context nodelineNr- Line of the starting position of this contextcolNr- Column of the starting position of this context- Returns:
- This context instance (to allow call-chaining)
-
withDupDetector
-
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
-
expectComma
public boolean expectComma() -
setCurrentName
Method that parser is to call when it reads a name of Object property.- Parameters:
name- Property name that has been read- Throws:
StreamReadException- if duplicate check restriction is violated (which assumes that duplicate-detection is enabled)
-