Package org.codehaus.jackson
Class JsonStreamContext
java.lang.Object
org.codehaus.jackson.JsonStreamContext
- Direct Known Subclasses:
JsonReadContext
,JsonWriteContext
Shared base class for streaming processing contexts used during
reading and writing of Json content using Streaming API.
This context is also exposed to applications:
context object can be used by applications to get an idea of
relative position of the parser/generator within json content
being processed. This allows for some contextual processing: for
example, output within Array context can differ from that of
Object context.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
Index of the currently processed entry.protected int
protected static final int
protected static final int
protected static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal int
abstract String
Method for accessing name associated with the current location.final int
abstract JsonStreamContext
Accessor for finding parent context of this context; will return null for root context.final String
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)final 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.final 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.final 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.
-
Field Details
-
TYPE_ROOT
protected static final int TYPE_ROOT- See Also:
-
TYPE_ARRAY
protected static final int TYPE_ARRAY- See Also:
-
TYPE_OBJECT
protected static final int TYPE_OBJECT- See Also:
-
_type
protected int _type -
_index
protected int _indexIndex of the currently processed entry. Starts with -1 to signal that no entries have been started, and gets advanced each time a new entry is started, either by encountering an expected separator, or with new values if no separators are expected (the case for root context).
-
-
Constructor Details
-
JsonStreamContext
protected JsonStreamContext()
-
-
Method Details
-
getParent
Accessor for finding parent context of this context; will return null for root context. -
inArray
public final 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. -
inRoot
public final 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. -
inObject
public final 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. -
getTypeDesc
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) -
getEntryCount
public final int getEntryCount()- Returns:
- Number of entries that are complete and started.
-
getCurrentIndex
public final int getCurrentIndex()- Returns:
- Index of the currently processed entry, if any
-
getCurrentName
Method for accessing name associated with the current location. Non-null forFIELD_NAME
and value events that directly follow field names; null for root level and array values.
-