Package com.fasterxml.jackson.core.json
Class JsonReadContext
- java.lang.Object
 - 
- com.fasterxml.jackson.core.JsonStreamContext
 - 
- com.fasterxml.jackson.core.json.JsonReadContext
 
 
 
- 
public final class JsonReadContext extends JsonStreamContext
Extension ofJsonStreamContext, which implements core methods needed, and also exposes more complete API to parser implementation classes. 
- 
- 
Field Summary
- 
Fields inherited from class com.fasterxml.jackson.core.JsonStreamContext
TYPE_ARRAY, TYPE_OBJECT, TYPE_ROOT 
 - 
 
- 
Constructor Summary
Constructors Constructor Description JsonReadContext(JsonReadContext parent, DupDetector dups, int type, int lineNr, int colNr) 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description JsonReadContextclearAndGetParent()Method that can be used to both clear the accumulated references (specifically value set withsetCurrentValue(Object)) that should not be retained, and returns parent (as wouldgetParent()do).JsonReadContextcreateChildArrayContext(int lineNr, int colNr)JsonReadContextcreateChildObjectContext(int lineNr, int colNr)static JsonReadContextcreateRootContext(int lineNr, int colNr, DupDetector dups)static JsonReadContextcreateRootContext(DupDetector dups)booleanexpectComma()java.lang.StringgetCurrentName()Method for accessing name associated with the current location.java.lang.ObjectgetCurrentValue()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.DupDetectorgetDupDetector()JsonReadContextgetParent()Accessor for finding parent context of this context; will return null for root context.JsonLocationgetStartLocation(java.lang.Object rawSrc)Deprecated.booleanhasCurrentName()voidreset(int type, int lineNr, int colNr)Internal method to allow instance reuse: DO NOT USE unless you absolutely know what you are doing.voidsetCurrentName(java.lang.String name)voidsetCurrentValue(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)).JsonLocationstartLocation(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.JsonReadContextwithDupDetector(DupDetector dups)- 
Methods inherited from class com.fasterxml.jackson.core.JsonStreamContext
getCurrentIndex, getEntryCount, getTypeDesc, hasCurrentIndex, hasPathSegment, inArray, inObject, inRoot, pathAsPointer, pathAsPointer, toString, typeDesc 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
JsonReadContext
public JsonReadContext(JsonReadContext parent, DupDetector dups, int type, int lineNr, int colNr)
 
 - 
 
- 
Method Detail
- 
reset
public 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. Clears up state (including "current value"), changes type to one specified; resets current duplicate-detection state (if any). Parent link left as-is since it isfinal.NOTE: Public since 2.12.
- Parameters:
 type- Type to assign to this context nodelineNr- Line of the starting position of this contextcolNr- Column of the starting position of this context
 
- 
withDupDetector
public JsonReadContext withDupDetector(DupDetector dups)
 
- 
getCurrentValue
public java.lang.Object getCurrentValue()
Description copied from class:JsonStreamContextMethod 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:
 getCurrentValuein classJsonStreamContext- Returns:
 - Currently active value, if one has been assigned.
 
 
- 
setCurrentValue
public void setCurrentValue(java.lang.Object v)
Description copied from class:JsonStreamContextMethod to call to pass value to be returned viaJsonStreamContext.getCurrentValue(); typically called indirectly throughJsonParser.setCurrentValue(java.lang.Object)orJsonGenerator.setCurrentValue(java.lang.Object)).- Overrides:
 setCurrentValuein classJsonStreamContext- Parameters:
 v- Current value to assign to this context
 
- 
createRootContext
public static JsonReadContext createRootContext(int lineNr, int colNr, DupDetector dups)
 
- 
createRootContext
public static JsonReadContext createRootContext(DupDetector dups)
 
- 
createChildArrayContext
public JsonReadContext createChildArrayContext(int lineNr, int colNr)
 
- 
createChildObjectContext
public JsonReadContext createChildObjectContext(int lineNr, int colNr)
 
- 
getCurrentName
public java.lang.String getCurrentName()
Description copied from class:JsonStreamContextMethod for accessing name associated with the current location. Non-null forFIELD_NAMEand value events that directly follow field names; null for root level and array values.- Specified by:
 getCurrentNamein classJsonStreamContext- Returns:
 - Current field name within context, if any; 
nullif none 
 
- 
hasCurrentName
public boolean hasCurrentName()
- Overrides:
 hasCurrentNamein classJsonStreamContext- Returns:
 Trueif a call toJsonStreamContext.getCurrentName()would return non-nullname;falseotherwise
 
- 
getParent
public JsonReadContext getParent()
Description copied from class:JsonStreamContextAccessor for finding parent context of this context; will return null for root context.- Specified by:
 getParentin classJsonStreamContext- Returns:
 - Parent context of this context, if any; 
nullfor Root contexts 
 
- 
startLocation
public JsonLocation startLocation(ContentReference srcRef)
Description copied from class:JsonStreamContextOptional 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:
 startLocationin classJsonStreamContext- Parameters:
 srcRef- Source reference needed to construct location instance- Returns:
 - Location pointing to the point where the context
   start marker was found (or written); never 
null. 
 
- 
getStartLocation
@Deprecated public JsonLocation getStartLocation(java.lang.Object rawSrc)
Deprecated.- Overrides:
 getStartLocationin classJsonStreamContext- Parameters:
 rawSrc- Source reference needed to construct location instance- Returns:
 - Location pointing to the point where the context
   start marker was found (or written); never 
null. 
 
- 
clearAndGetParent
public JsonReadContext clearAndGetParent()
Method that can be used to both clear the accumulated references (specifically value set withsetCurrentValue(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 - Since:
 - 2.7
 
 
- 
getDupDetector
public DupDetector getDupDetector()
 
- 
expectComma
public boolean expectComma()
 
- 
setCurrentName
public void setCurrentName(java.lang.String name) throws JsonProcessingException- Throws:
 JsonProcessingException
 
 - 
 
 -