java.lang.Object
tools.jackson.core.TokenStreamContext
tools.jackson.core.util.SimpleStreamWriteContext
Basic implementation of
TokenStreamContext useful for most
format backend JsonGenerator implementations
(with notable exception of JSON that needs bit more advanced state).- Since:
- 3.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SimpleStreamWriteContextprotected StringName of the property of which value is to be written; only used for OBJECT contexts.protected Objectprotected DupDetectorprotected booleanMarker used to indicate that we just wrote a property name (or possibly property id for some backends) and now expect a value to write.protected final SimpleStreamWriteContextParent 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
ConstructorsModifierConstructorDescriptionprotectedSimpleStreamWriteContext(int type, SimpleStreamWriteContext parent, int nestingDepth, DupDetector dups, Object currentValue) -
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(Object currentValue) createChildObjectContext(Object currentValue) static SimpleStreamWriteContextfinal StringMethod 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.final SimpleStreamWriteContextAccessor for finding parent context of this context; will return null for root context.booleanwithDupDetector(DupDetector dups) booleanMethod that writer is to call before it writes an Object Property name.booleanMethods inherited from class tools.jackson.core.TokenStreamContext
getCurrentIndex, getEntryCount, getNestingDepth, hasCurrentIndex, hasPathSegment, inArray, inObject, inRoot, pathAsPointer, pathAsPointer, startLocation, toString, typeDesc
-
Field Details
-
_parent
Parent context for this context; null for root context. -
_dups
-
_childToRecycle
-
_currentName
Name of the property of which value is to be written; only used for OBJECT contexts. -
_currentValue
-
_gotPropertyId
protected boolean _gotPropertyIdMarker used to indicate that we just wrote a property name (or possibly property id for some backends) and now expect a value to write.
-
-
Constructor Details
-
SimpleStreamWriteContext
protected SimpleStreamWriteContext(int type, SimpleStreamWriteContext parent, int nestingDepth, DupDetector dups, Object currentValue)
-
-
Method Details
-
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
-
createChildArrayContext
-
createChildObjectContext
-
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
-
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
-
hasCurrentName
public boolean hasCurrentName()- Overrides:
hasCurrentNamein classTokenStreamContext
-
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
-
writeName
Method that writer is to call before it writes an Object Property name.- Parameters:
name- Name of Object property name being written- Returns:
Trueif name writing should proceed;falseif not- Throws:
StreamWriteException- If write fails due to duplicate check
-
writeValue
public boolean writeValue()
-