Class XmlReadContext
- java.lang.Object
-
- com.fasterxml.jackson.core.JsonStreamContext
-
- com.fasterxml.jackson.dataformat.xml.deser.XmlReadContext
-
public final class XmlReadContext extends JsonStreamContext
Extension ofJsonStreamContext
, which implements core methods needed, and adds small amount of additional state data we need.Almost same as standard
JsonReaderContext
, but custom version needed to be able to keep track of names of properties that need wrapping; this is needed to support wrapped/unwrapped Collection/array values.
-
-
Field Summary
-
Fields inherited from class com.fasterxml.jackson.core.JsonStreamContext
TYPE_ARRAY, TYPE_OBJECT, TYPE_ROOT
-
-
Constructor Summary
Constructors Constructor Description XmlReadContext(XmlReadContext parent, int type, int lineNr, int colNr)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description XmlReadContext
createChildArrayContext(int lineNr, int colNr)
XmlReadContext
createChildObjectContext(int lineNr, int colNr)
static XmlReadContext
createRootContext()
static XmlReadContext
createRootContext(int lineNr, int colNr)
java.lang.String
getCurrentName()
Method for accessing name associated with the current location.java.lang.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.XmlReadContext
getParent()
Accessor for finding parent context of this context; will return null for root context.boolean
hasCurrentName()
void
setCurrentName(java.lang.String name)
void
setCurrentValue(java.lang.Object v)
Method to call to pass value to be returned viaJsonStreamContext.getCurrentValue()
; typically called indirectly throughJsonParser.setCurrentValue(java.lang.Object)
orJsonGenerator.setCurrentValue(java.lang.Object)
).void
setNamesToWrap(java.util.Set<java.lang.String> namesToWrap)
boolean
shouldWrap(java.lang.String localName)
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.java.lang.String
toString()
Overridden to provide developer readable "JsonPath" representation of the context.void
valueStarted()
Method called to mark start of new value, mostly to update `index` for Array and Root contexts.-
Methods inherited from class com.fasterxml.jackson.core.JsonStreamContext
getCurrentIndex, getEntryCount, getNestingDepth, getStartLocation, getTypeDesc, hasCurrentIndex, hasPathSegment, inArray, inObject, inRoot, pathAsPointer, pathAsPointer, typeDesc
-
-
-
-
Constructor Detail
-
XmlReadContext
public XmlReadContext(XmlReadContext parent, int type, int lineNr, int colNr)
-
-
Method Detail
-
getCurrentValue
public java.lang.Object getCurrentValue()
Description copied from class:JsonStreamContext
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.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:
getCurrentValue
in classJsonStreamContext
- Returns:
- Currently active value, if one has been assigned.
-
setCurrentValue
public void setCurrentValue(java.lang.Object v)
Description copied from class:JsonStreamContext
Method to call to pass value to be returned viaJsonStreamContext.getCurrentValue()
; typically called indirectly throughJsonParser.setCurrentValue(java.lang.Object)
orJsonGenerator.setCurrentValue(java.lang.Object)
).- Overrides:
setCurrentValue
in classJsonStreamContext
- Parameters:
v
- Current value to assign to this context
-
createRootContext
public static XmlReadContext createRootContext(int lineNr, int colNr)
-
createRootContext
public static XmlReadContext createRootContext()
-
createChildArrayContext
public final XmlReadContext createChildArrayContext(int lineNr, int colNr)
-
createChildObjectContext
public final XmlReadContext createChildObjectContext(int lineNr, int colNr)
-
getCurrentName
public final java.lang.String getCurrentName()
Description copied from class:JsonStreamContext
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.- Specified by:
getCurrentName
in classJsonStreamContext
- Returns:
- Current field name within context, if any;
null
if none
-
hasCurrentName
public boolean hasCurrentName()
- Overrides:
hasCurrentName
in classJsonStreamContext
- Returns:
True
if a call toJsonStreamContext.getCurrentName()
would return non-null
name;false
otherwise
-
getParent
public final XmlReadContext getParent()
Description copied from class:JsonStreamContext
Accessor for finding parent context of this context; will return null for root context.- Specified by:
getParent
in classJsonStreamContext
- Returns:
- Parent context of this context, if any;
null
for Root contexts
-
startLocation
public final JsonLocation startLocation(ContentReference srcRef)
Description copied from class:JsonStreamContext
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. Often used for error reporting purposes. Implementations that do not keep track of such location are expected to returnJsonLocation.NA
; this is what the default implementation does.- Overrides:
startLocation
in classJsonStreamContext
- Parameters:
srcRef
- Source reference needed to construct location instance- Returns:
- Location pointing to the point where the context start marker was found
-
valueStarted
public final void valueStarted()
Method called to mark start of new value, mostly to update `index` for Array and Root contexts.- Since:
- 2.12
-
setCurrentName
public void setCurrentName(java.lang.String name)
-
setNamesToWrap
public void setNamesToWrap(java.util.Set<java.lang.String> namesToWrap)
-
shouldWrap
public boolean shouldWrap(java.lang.String localName)
-
toString
public final java.lang.String toString()
Overridden to provide developer readable "JsonPath" representation of the context.- Overrides:
toString
in classJsonStreamContext
- Returns:
- Simple developer-readable description this context layer
(note: NOT constructed with parents, unlike
JsonStreamContext.pathAsPointer()
)
-
-