Class TokenFilterContext
- java.lang.Object
-
- com.fasterxml.jackson.core.JsonStreamContext
-
- com.fasterxml.jackson.core.filter.TokenFilterContext
-
public class TokenFilterContext extends JsonStreamContext
Alternative variant ofJsonStreamContext, used when filtering content being read or written (based onTokenFilter).- Since:
- 2.6
-
-
Field Summary
-
Fields inherited from class com.fasterxml.jackson.core.JsonStreamContext
TYPE_ARRAY, TYPE_OBJECT, TYPE_ROOT
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TokenFiltercheckValue(TokenFilter filter)Method called to check whether value is to be included at current output position, either as Object property, Array element, or root value.TokenFilterContextcloseArray(JsonGenerator gen)TokenFilterContextcloseObject(JsonGenerator gen)TokenFilterContextcreateChildArrayContext(TokenFilter filter, boolean writeStart)TokenFilterContextcreateChildObjectContext(TokenFilter filter, boolean writeStart)static TokenFilterContextcreateRootContext(TokenFilter filter)voidensureFieldNameWritten(JsonGenerator gen)Method called to ensure that field name, if present, has been written; may result (but does not always) in a call using given generatorTokenFilterContextfindChildOf(TokenFilterContext parent)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.TokenFiltergetFilter()TokenFilterContextgetParent()Accessor for finding parent context of this context; will return null for root context.booleanhasCurrentName()booleanisStartHandled()JsonTokennextTokenToRead()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)).TokenFiltersetFieldName(java.lang.String name)voidskipParentChecks()java.lang.StringtoString()Overridden to provide developer readable "JsonPath" representation of the context.voidwritePath(JsonGenerator gen)Method called to ensure that parent path from root is written up to and including this node.-
Methods inherited from class com.fasterxml.jackson.core.JsonStreamContext
getCurrentIndex, getEntryCount, getNestingDepth, getStartLocation, getTypeDesc, hasCurrentIndex, hasPathSegment, inArray, inObject, inRoot, pathAsPointer, pathAsPointer, startLocation, typeDesc
-
-
-
-
Method Detail
-
createRootContext
public static TokenFilterContext createRootContext(TokenFilter filter)
-
createChildArrayContext
public TokenFilterContext createChildArrayContext(TokenFilter filter, boolean writeStart)
-
createChildObjectContext
public TokenFilterContext createChildObjectContext(TokenFilter filter, boolean writeStart)
-
setFieldName
public TokenFilter setFieldName(java.lang.String name) throws JsonProcessingException
- Throws:
JsonProcessingException
-
checkValue
public TokenFilter checkValue(TokenFilter filter)
Method called to check whether value is to be included at current output position, either as Object property, Array element, or root value.- Parameters:
filter- Currently active filter- Returns:
- Filter to use for value
-
ensureFieldNameWritten
public void ensureFieldNameWritten(JsonGenerator gen) throws java.io.IOException
Method called to ensure that field name, if present, has been written; may result (but does not always) in a call using given generator- Parameters:
gen- Generator to use to write the property name, if necessary- Throws:
java.io.IOException- If there is a problem writing property name (typically thrown byJsonGenerator)
-
writePath
public void writePath(JsonGenerator gen) throws java.io.IOException
Method called to ensure that parent path from root is written up to and including this node.- Parameters:
gen- Generator to use to write the path, if necessary- Throws:
java.io.IOException- If there is a problem writing property name (typically thrown byJsonGenerator)
-
closeArray
public TokenFilterContext closeArray(JsonGenerator gen) throws java.io.IOException
- Throws:
java.io.IOException
-
closeObject
public TokenFilterContext closeObject(JsonGenerator gen) throws java.io.IOException
- Throws:
java.io.IOException
-
skipParentChecks
public void skipParentChecks()
-
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
-
getParent
public final TokenFilterContext 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
-
getCurrentName
public final 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
-
getFilter
public TokenFilter getFilter()
-
isStartHandled
public boolean isStartHandled()
-
nextTokenToRead
public JsonToken nextTokenToRead()
-
findChildOf
public TokenFilterContext findChildOf(TokenFilterContext parent)
-
toString
public java.lang.String toString()
Description copied from class:JsonStreamContextOverridden to provide developer readable "JsonPath" representation of the context.- Overrides:
toStringin classJsonStreamContext- Returns:
- Simple developer-readable description this context layer
(note: NOT constructed with parents, unlike
JsonStreamContext.pathAsPointer())
-
-