java.lang.Object
tools.jackson.core.TokenStreamContext
tools.jackson.core.json.JsonWriteContext
Extension of
TokenStreamContext, which implements
core methods needed, and also exposes
more complete API to generator implementation classes.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JsonWriteContextprotected StringName of the Object property of which value is to be written; only used for OBJECT contextsprotected Objectprotected DupDetectorprotected booleanMarker used to indicate that we just wrote a name, and now expect a value to writeprotected final JsonWriteContextParent context for this context; null for root context.static final intstatic final intstatic final intstatic final intstatic final intstatic final intFields inherited from class tools.jackson.core.TokenStreamContext
_index, _nestingDepth, _type, TYPE_ARRAY, TYPE_OBJECT, TYPE_ROOT -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJsonWriteContext(int type, JsonWriteContext parent, DupDetector dups, Object currValue) -
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 currValue) createChildObjectContext(Object currValue) static JsonWriteContextfinal 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 JsonWriteContextAccessor for finding parent context of this context; will return null for root context.booleanprotected JsonWriteContextInternal method to allow instance reuse: DO NOT USE unless you absolutely know what you are doing.withDupDetector(DupDetector dups) intMethod that generator is to call when it writes a name of Object property.intMethods inherited from class tools.jackson.core.TokenStreamContext
getCurrentIndex, getEntryCount, getNestingDepth, hasCurrentIndex, hasPathSegment, inArray, inObject, inRoot, pathAsPointer, pathAsPointer, startLocation, toString, typeDesc
-
Field Details
-
STATUS_OK_AS_IS
public static final int STATUS_OK_AS_IS- See Also:
-
STATUS_OK_AFTER_COMMA
public static final int STATUS_OK_AFTER_COMMA- See Also:
-
STATUS_OK_AFTER_COLON
public static final int STATUS_OK_AFTER_COLON- See Also:
-
STATUS_OK_AFTER_SPACE
public static final int STATUS_OK_AFTER_SPACE- See Also:
-
STATUS_EXPECT_VALUE
public static final int STATUS_EXPECT_VALUE- See Also:
-
STATUS_EXPECT_NAME
public static final int STATUS_EXPECT_NAME- See Also:
-
_parent
Parent context for this context; null for root context. -
_dups
-
_child
-
_currentName
Name of the Object property of which value is to be written; only used for OBJECT contexts -
_currentValue
-
_gotName
protected boolean _gotNameMarker used to indicate that we just wrote a name, and now expect a value to write
-
-
Constructor Details
-
JsonWriteContext
-
-
Method Details
-
reset
Internal method to allow instance reuse: DO NOT USE unless you absolutely know what you are doing. Clears up state, changes type to one specified, assigns "current value"; resets current duplicate-detection state (if any). Parent link left as-is since it isfinal.- Parameters:
type- Type to assign to this context nodecurrValue- Current value to assign to this context node- Returns:
- This context instance to allow call-chaining
- Since:
- 2.10
-
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 generator is to call when it writes a name of Object property.- Parameters:
name- Property name being written- Returns:
- Index of the Object property (0-based)
- Throws:
StreamWriteException- if duplicate check restriction is violated (which assumes that duplicate-detection is enabled)
-
writeValue
public int writeValue()
-