public abstract class JsonStreamContext extends Object
Modifier and Type | Field and Description |
---|---|
protected int |
_index
Index of the currently processed entry.
|
protected int |
_type
Indicates logical type of context as one of
TYPE_xxx consants. |
static int |
TYPE_ARRAY
Indicator for "Array" context.
|
static int |
TYPE_OBJECT
Indicator for "Object" context.
|
static int |
TYPE_ROOT
Indicator for "Root Value" context (has not parent)
|
Modifier | Constructor and Description |
---|---|
protected |
JsonStreamContext() |
protected |
JsonStreamContext(int type,
int index) |
protected |
JsonStreamContext(JsonStreamContext base)
Copy constructor used by sub-classes for creating copies for
buffering.
|
Modifier and Type | Method and Description |
---|---|
int |
getCurrentIndex() |
abstract String |
getCurrentName()
Method for accessing name associated with the current location.
|
Object |
getCurrentValue()
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.
|
int |
getEntryCount() |
abstract JsonStreamContext |
getParent()
Accessor for finding parent context of this context; will
return null for root context.
|
JsonLocation |
getStartLocation(Object srcRef)
Deprecated.
Since 2.13 use
startLocation(com.fasterxml.jackson.core.io.ContentReference) instead |
String |
getTypeDesc()
Deprecated.
Since 2.8 use
typeDesc() instead |
boolean |
hasCurrentIndex()
Method that may be called to verify whether this context has valid index:
will return `false` before the first entry of Object context or before
first element of Array context; otherwise returns `true`.
|
boolean |
hasCurrentName() |
boolean |
hasPathSegment()
Method that may be called to check if this context is either:
Object, with at least one entry written (partially or completely)
Array, with at least one entry written (partially or completely)
and if so, return `true`; otherwise return `false`.
|
boolean |
inArray()
Method that returns true if this context is an Array context;
that is, content is being read from or written to a JSON Array.
|
boolean |
inObject()
Method that returns true if this context is an Object context;
that is, content is being read from or written to a JSON Object.
|
boolean |
inRoot()
Method that returns true if this context is a Root context;
that is, content is being read from or written to without
enclosing array or object structure.
|
JsonPointer |
pathAsPointer()
Factory method for constructing a
JsonPointer that points to the current
location within the stream that this context is for, excluding information about
"root context" (only relevant for multi-root-value cases) |
JsonPointer |
pathAsPointer(boolean includeRoot)
Factory method for constructing a
JsonPointer that points to the current
location within the stream that this context is for, optionally including
"root value index" |
void |
setCurrentValue(Object v)
Method to call to pass value to be returned via
getCurrentValue() ; typically
called indirectly through JsonParser.setCurrentValue(java.lang.Object)
or JsonGenerator.setCurrentValue(java.lang.Object) ). |
JsonLocation |
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.
|
String |
toString()
Overridden to provide developer readable "JsonPath" representation
of the context.
|
String |
typeDesc()
Method for accessing simple type description of current context;
either ROOT (for root-level values), OBJECT (for field names and
values of JSON Objects) or ARRAY (for values of JSON Arrays)
|
public static final int TYPE_ROOT
public static final int TYPE_ARRAY
public static final int TYPE_OBJECT
protected int _type
TYPE_xxx
consants.protected int _index
protected JsonStreamContext()
protected JsonStreamContext(JsonStreamContext base)
base
- Context instance to copy type and index fromprotected JsonStreamContext(int type, int index)
public abstract JsonStreamContext getParent()
null
for Root contextspublic final boolean inArray()
True
if this context represents an Array; false
otherwisepublic final boolean inRoot()
True
if this context represents a sequence of Root values; false
otherwisepublic final boolean inObject()
True
if this context represents an Object; false
otherwise@Deprecated public final String getTypeDesc()
typeDesc()
insteadpublic String typeDesc()
public final int getEntryCount()
public final int getCurrentIndex()
public boolean hasCurrentIndex()
True
if this context has value index to access, false
otherwisepublic boolean hasPathSegment()
Method is mostly used to determine whether this context should be used for
constructing JsonPointer
True
if this context has value path segment to access, false
otherwisepublic abstract String getCurrentName()
FIELD_NAME
and value events that directly
follow field names; null for root level and array values.null
if nonepublic boolean hasCurrentName()
True
if a call to getCurrentName()
would return non-null
name; false
otherwisepublic Object getCurrentValue()
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.
public void setCurrentValue(Object v)
getCurrentValue()
; typically
called indirectly through JsonParser.setCurrentValue(java.lang.Object)
or JsonGenerator.setCurrentValue(java.lang.Object)
).v
- Current value to assign to this contextpublic JsonPointer pathAsPointer()
JsonPointer
that points to the current
location within the stream that this context is for, excluding information about
"root context" (only relevant for multi-root-value cases)public JsonPointer pathAsPointer(boolean includeRoot)
JsonPointer
that points to the current
location within the stream that this context is for, optionally including
"root value index"includeRoot
- Whether root-value offset is included as the first segment or not;public JsonLocation startLocation(ContentReference srcRef)
JsonLocation.NA
; this is what the default implementation does.srcRef
- Source reference needed to construct location instancenull
.@Deprecated public JsonLocation getStartLocation(Object srcRef)
startLocation(com.fasterxml.jackson.core.io.ContentReference)
insteadsrcRef
- Source reference needed to construct location instancenull
.public String toString()
toString
in class Object
pathAsPointer()
)Copyright © 2008–2022 FasterXML. All rights reserved.