public final class JsonReadContext extends JsonStreamContext
JsonStreamContext
, which implements
core methods needed, and also exposes
more complete API to parser implementation classes.Modifier and Type | Field and Description |
---|---|
protected JsonReadContext |
_child |
protected int |
_columnNr |
protected String |
_currentName |
protected Object |
_currentValue |
protected DupDetector |
_dups |
protected int |
_lineNr |
protected JsonReadContext |
_parent
Parent context for this context; null for root context.
|
_index, _nestingDepth, _type, TYPE_ARRAY, TYPE_OBJECT, TYPE_ROOT
Constructor and Description |
---|
JsonReadContext(JsonReadContext parent,
DupDetector dups,
int type,
int lineNr,
int colNr)
Deprecated.
|
JsonReadContext(JsonReadContext parent,
int nestingDepth,
DupDetector dups,
int type,
int lineNr,
int colNr) |
Modifier and Type | Method and Description |
---|---|
JsonReadContext |
clearAndGetParent()
Method that can be used to both clear the accumulated references
(specifically value set with
setCurrentValue(Object) )
that should not be retained, and returns parent (as would
getParent() do). |
JsonReadContext |
createChildArrayContext(int lineNr,
int colNr) |
JsonReadContext |
createChildObjectContext(int lineNr,
int colNr) |
static JsonReadContext |
createRootContext(DupDetector dups) |
static JsonReadContext |
createRootContext(int lineNr,
int colNr,
DupDetector dups) |
boolean |
expectComma() |
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.
|
DupDetector |
getDupDetector() |
JsonReadContext |
getParent()
Accessor for finding parent context of this context; will
return null for root context.
|
JsonLocation |
getStartLocation(Object rawSrc)
Deprecated.
|
boolean |
hasCurrentName() |
void |
reset(int type,
int lineNr,
int colNr)
Internal method to allow instance reuse: DO NOT USE unless you absolutely
know what you are doing.
|
void |
setCurrentName(String name) |
void |
setCurrentValue(Object v)
Method to call to pass value to be returned via
JsonStreamContext.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.
|
JsonReadContext |
withDupDetector(DupDetector dups) |
getCurrentIndex, getEntryCount, getNestingDepth, getTypeDesc, hasCurrentIndex, hasPathSegment, inArray, inObject, inRoot, pathAsPointer, pathAsPointer, toString, typeDesc
protected final JsonReadContext _parent
protected DupDetector _dups
protected JsonReadContext _child
protected String _currentName
protected Object _currentValue
protected int _lineNr
protected int _columnNr
public JsonReadContext(JsonReadContext parent, int nestingDepth, DupDetector dups, int type, int lineNr, int colNr)
@Deprecated public JsonReadContext(JsonReadContext parent, DupDetector dups, int type, int lineNr, int colNr)
public void reset(int type, int lineNr, int colNr)
final
.
NOTE: Public since 2.12.
type
- Type to assign to this context nodelineNr
- Line of the starting position of this contextcolNr
- Column of the starting position of this contextpublic JsonReadContext withDupDetector(DupDetector dups)
public Object getCurrentValue()
JsonStreamContext
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.
getCurrentValue
in class JsonStreamContext
public void setCurrentValue(Object v)
JsonStreamContext
JsonStreamContext.getCurrentValue()
; typically
called indirectly through JsonParser.setCurrentValue(java.lang.Object)
or JsonGenerator.setCurrentValue(java.lang.Object)
).setCurrentValue
in class JsonStreamContext
v
- Current value to assign to this contextpublic static JsonReadContext createRootContext(int lineNr, int colNr, DupDetector dups)
public static JsonReadContext createRootContext(DupDetector dups)
public JsonReadContext createChildArrayContext(int lineNr, int colNr)
public JsonReadContext createChildObjectContext(int lineNr, int colNr)
public String getCurrentName()
JsonStreamContext
FIELD_NAME
and value events that directly
follow field names; null for root level and array values.getCurrentName
in class JsonStreamContext
null
if nonepublic boolean hasCurrentName()
hasCurrentName
in class JsonStreamContext
True
if a call to JsonStreamContext.getCurrentName()
would return non-null
name; false
otherwisepublic JsonReadContext getParent()
JsonStreamContext
getParent
in class JsonStreamContext
null
for Root contextspublic JsonLocation startLocation(ContentReference srcRef)
JsonStreamContext
JsonLocation.NA
; this is what the default implementation does.startLocation
in class JsonStreamContext
srcRef
- Source reference needed to construct location instancenull
.@Deprecated public JsonLocation getStartLocation(Object rawSrc)
getStartLocation
in class JsonStreamContext
rawSrc
- Source reference needed to construct location instancenull
.public JsonReadContext clearAndGetParent()
setCurrentValue(Object)
)
that should not be retained, and returns parent (as would
getParent()
do). Typically called when closing the active
context when encountering JsonToken.END_ARRAY
or
JsonToken.END_OBJECT
.null
for root contextpublic DupDetector getDupDetector()
public boolean expectComma()
public void setCurrentName(String name) throws JsonProcessingException
JsonProcessingException
Copyright © 2008–2023 FasterXML. All rights reserved.