Top Description Inners Fields Constructors Methods
com.fasterxml.jackson.core.filter

public Class TokenFilter

extends Object
Class Inheritance
Known Direct Subclasses
com.fasterxml.jackson.core.filter.JsonPointerBasedFilter
Imports
java.io.IOException, java.math.BigDecimal, .BigInteger, com.fasterxml.jackson.core.JsonGenerator, .JsonParser

Strategy class that can be implemented to specify actual inclusion/exclusion criteria for filtering, used by FilteringGeneratorDelegate.
Since
2.6

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
TokenFilter.Inclusion

Enumeration that controls how TokenFilter return values are interpreted.

Field Summary

Modifier and TypeField and Description
public static final TokenFilter
INCLUDE_ALL

Marker value that should be used to indicate inclusion of a structured value (sub-tree representing Object or Array), or value of a named property (regardless of type).

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected boolean

Returns:

Whether all leaf scalar values should be included (true) or not (false)
_includeScalar
()

Overridable default implementation delegated to all scalar value inclusion check methods.

public void
filterFinishArray()

Method called to indicate that output of non-filtered Array (one that may have been included either completely, or in part) is completed, in cases where filter other that INCLUDE_ALL was returned.

public void
filterFinishObject()

Method called to indicate that output of non-filtered Object (one that may have been included either completely, or in part) is completed, in cases where filter other that INCLUDE_ALL was returned.

public TokenFilter

Returns:

TokenFilter to use for further calls within Array, unless return value is null or INCLUDE_ALL (which have simpler semantics)
filterStartArray
()

Method called to check whether Array value at current output location should be included in output.

public TokenFilter

Returns:

TokenFilter to use for further calls within Array, unless return value is null or INCLUDE_ALL (which have simpler semantics)
filterStartObject
()

Method called to check whether Object value at current output location should be included in output.

public boolean

Returns:

True if the binary value is to be included; false if not
includeBinary
()

Call made to verify whether leaf-level Binary value should be included in output or not.

public boolean

Returns:

True if value is to be included; false if not
includeBoolean
(boolean
Value to check
value
)

Call made to verify whether leaf-level boolean value should be included in output or not.

public TokenFilter

Returns:

TokenFilter to use for further calls within element value, unless return value is null or INCLUDE_ALL (which have simpler semantics)
includeElement
(int
Array element index (0-based) to check
index
)

Method called to check whether array element with specified index (zero-based), at current output location, should be included in output.

public boolean

Returns:

True if value is to be included; false if not
includeEmbeddedValue
(Object
Value to check
value
)

Call made to verify whether leaf-level embedded (Opaque) value should be included in output or not.

public boolean

Returns:

True if value is to be included; false if not
includeEmptyArray
(boolean
True if Array had contents but they were filtered out (NOT included); false if we had actual empty Array.
contentsFiltered
)

Call made to verify whether leaf-level empty Array value should be included in output or not.

public boolean

Returns:

True if value is to be included; false if not
includeEmptyObject
(boolean
True if Object had contents but they were filtered out (NOT included); false if we had actual empty Object.
contentsFiltered
)

Call made to verify whether leaf-level empty Object value should be included in output or not.

public boolean

Returns:

True if (null) value is to be included; false if not
includeNull
()

Call made to verify whether leaf-level null value should be included in output or not.

public boolean

Returns:

True if value is to be included; false if not
includeNumber
(int
Value to check
value
)

Call made to verify whether leaf-level int value should be included in output or not.

public boolean

Returns:

True if value is to be included; false if not
includeNumber
(long
Value to check
value
)

Call made to verify whether leaf-level long value should be included in output or not.

public boolean

Returns:

True if value is to be included; false if not
includeNumber
(float
Value to check
value
)

Call made to verify whether leaf-level float value should be included in output or not.

public boolean

Returns:

True if value is to be included; false if not
includeNumber
(double
Value to check
value
)

Call made to verify whether leaf-level double value should be included in output or not.

public boolean

Returns:

True if value is to be included; false if not
includeNumber
(BigDecimal
Value to check
value
)

Call made to verify whether leaf-level BigDecimal value should be included in output or not.

public boolean

Returns:

True if value is to be included; false if not
includeNumber
(BigInteger
Value to check
value
)

Call made to verify whether leaf-level BigInteger value should be included in output or not.

public TokenFilter

Returns:

TokenFilter to use for further calls within property value, unless return value is null or INCLUDE_ALL (which have simpler semantics)
includeProperty
(String
Name of Object property to check
name
)

Method called to check whether property value with specified name, at current output location, should be included in output.

public boolean

Returns:

True if the raw value is to be included; false if not
includeRawValue
()

Call made to verify whether leaf-level raw (pre-encoded, not quoted by generator) value should be included in output or not.

public TokenFilter

Returns:

TokenFilter to use for further calls within root value, unless return value is null or INCLUDE_ALL (which have simpler semantics)
includeRootValue
(int
Index (0-based) of the root value to check
index
)

Method called to check whether root-level value, at current output location, should be included in output.

public boolean

Returns:

True if value is to be included; false if not
includeString
(String
Value to check
value
)

Call made to verify whether leaf-level String value should be included in output or not.

public boolean

Returns:

True if value is to be included; false if not
includeString
(Reader
Reader used to pass String value to parser
r
,
int
indicated maximum length of String value
maxLen
)

Call made to verify whether leaf-level "streaming" String value should be included in output or not.

public boolean

Returns:

True if scalar value is to be included; false if not
includeValue
(JsonParser
Parser that points to the value (typically delegate parser, not filtering parser that wraps it)
p
)

Call made when verifying whether a scalar value is being read from a parser.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

INCLUDE_ALLback to summary
public static final TokenFilter INCLUDE_ALL

Marker value that should be used to indicate inclusion of a structured value (sub-tree representing Object or Array), or value of a named property (regardless of type). Note that if this instance is returned, it will used as a marker, and no actual callbacks need to be made. For this reason, it is more efficient to return this instance if the whole sub-tree is to be included, instead of implementing similar filter functionality explicitly.

Constructor Detail

TokenFilterback to summary
protected TokenFilter()

Method Detail

_includeScalarback to summary
protected boolean _includeScalar()

Overridable default implementation delegated to all scalar value inclusion check methods. The default implementation simply includes all leaf values.

Returns:boolean

Whether all leaf scalar values should be included (true) or not (false)

filterFinishArrayback to summary
public void filterFinishArray()

Method called to indicate that output of non-filtered Array (one that may have been included either completely, or in part) is completed, in cases where filter other that INCLUDE_ALL was returned. This occurs when JsonGenerator#writeEndArray() is called.

filterFinishObjectback to summary
public void filterFinishObject()

Method called to indicate that output of non-filtered Object (one that may have been included either completely, or in part) is completed, in cases where filter other that INCLUDE_ALL was returned. This occurs when JsonGenerator#writeEndObject() is called.

filterStartArrayback to summary
public TokenFilter filterStartArray()

Method called to check whether Array value at current output location should be included in output. Three kinds of return values may be used as follows:

  • null to indicate that the Array should be skipped
  • INCLUDE_ALL to indicate that the Array should be included completely in output
  • Any other TokenFilter implementation (possibly this one) to mean that further inclusion calls on return filter object need to be made on contained element values, as necessary. filterFinishArray() will also be called on returned filter object

Default implementation returns this, which means that checks are made recursively for elements of the array to determine possible inclusion.

Returns:TokenFilter

TokenFilter to use for further calls within Array, unless return value is null or INCLUDE_ALL (which have simpler semantics)

filterStartObjectback to summary
public TokenFilter filterStartObject()

Method called to check whether Object value at current output location should be included in output. Three kinds of return values may be used as follows:

  • null to indicate that the Object should be skipped
  • INCLUDE_ALL to indicate that the Object should be included completely in output
  • Any other TokenFilter implementation (possibly this one) to mean that further inclusion calls on return filter object need to be made on contained properties, as necessary. filterFinishObject() will also be called on returned filter object

Default implementation returns this, which means that checks are made recursively for properties of the Object to determine possible inclusion.

Returns:TokenFilter

TokenFilter to use for further calls within Array, unless return value is null or INCLUDE_ALL (which have simpler semantics)

includeBinaryback to summary
public boolean includeBinary()

Call made to verify whether leaf-level Binary value should be included in output or not.

Note

no binary payload passed; assumption is this won't be of much use.

Returns:boolean

True if the binary value is to be included; false if not

includeBooleanback to summary
public boolean includeBoolean(boolean value)

Call made to verify whether leaf-level boolean value should be included in output or not.

Parameters
value:boolean

Value to check

Returns:boolean

True if value is to be included; false if not

includeElementback to summary
public TokenFilter includeElement(int index)

Method called to check whether array element with specified index (zero-based), at current output location, should be included in output. Three kinds of return values may be used as follows:

  • null to indicate that the Array element should be skipped
  • INCLUDE_ALL to indicate that the Array element should be included completely in output
  • Any other TokenFilter implementation (possibly this one) to mean that further inclusion calls on returned filter object need to be made as necessary, to determine inclusion.

The default implementation simply returns this to continue calling methods on this filter object, without full inclusion or exclusion.

Parameters
index:int

Array element index (0-based) to check

Returns:TokenFilter

TokenFilter to use for further calls within element value, unless return value is null or INCLUDE_ALL (which have simpler semantics)

includeEmbeddedValueback to summary
public boolean includeEmbeddedValue(Object value)

Call made to verify whether leaf-level embedded (Opaque) value should be included in output or not.

Parameters
value:Object

Value to check

Returns:boolean

True if value is to be included; false if not

includeEmptyArrayback to summary
public boolean includeEmptyArray(boolean contentsFiltered)

Call made to verify whether leaf-level empty Array value should be included in output or not.

Parameters
contentsFiltered:boolean

True if Array had contents but they were filtered out (NOT included); false if we had actual empty Array.

Returns:boolean

True if value is to be included; false if not

Since
2.14
includeEmptyObjectback to summary
public boolean includeEmptyObject(boolean contentsFiltered)

Call made to verify whether leaf-level empty Object value should be included in output or not.

Parameters
contentsFiltered:boolean

True if Object had contents but they were filtered out (NOT included); false if we had actual empty Object.

Returns:boolean

True if value is to be included; false if not

Since
2.14
includeNullback to summary
public boolean includeNull()

Call made to verify whether leaf-level null value should be included in output or not.

Returns:boolean

True if (null) value is to be included; false if not

includeNumberback to summary
public boolean includeNumber(int value)

Call made to verify whether leaf-level int value should be included in output or not.

Note

also called for `short`, `byte`

Parameters
value:int

Value to check

Returns:boolean

True if value is to be included; false if not

includeNumberback to summary
public boolean includeNumber(long value)

Call made to verify whether leaf-level long value should be included in output or not.

Parameters
value:long

Value to check

Returns:boolean

True if value is to be included; false if not

includeNumberback to summary
public boolean includeNumber(float value)

Call made to verify whether leaf-level float value should be included in output or not.

Parameters
value:float

Value to check

Returns:boolean

True if value is to be included; false if not

includeNumberback to summary
public boolean includeNumber(double value)

Call made to verify whether leaf-level double value should be included in output or not.

Parameters
value:double

Value to check

Returns:boolean

True if value is to be included; false if not

includeNumberback to summary
public boolean includeNumber(BigDecimal value)

Call made to verify whether leaf-level BigDecimal value should be included in output or not.

Parameters
value:BigDecimal

Value to check

Returns:boolean

True if value is to be included; false if not

includeNumberback to summary
public boolean includeNumber(BigInteger value)

Call made to verify whether leaf-level BigInteger value should be included in output or not.

Parameters
value:BigInteger

Value to check

Returns:boolean

True if value is to be included; false if not

includePropertyback to summary
public TokenFilter includeProperty(String name)

Method called to check whether property value with specified name, at current output location, should be included in output. Three kinds of return values may be used as follows:

  • null to indicate that the property and its value should be skipped
  • INCLUDE_ALL to indicate that the property and its value should be included completely in output
  • Any other TokenFilter implementation (possibly this one) to mean that further inclusion calls on returned filter object need to be made as necessary, to determine inclusion.

The default implementation simply returns this to continue calling methods on this filter object, without full inclusion or exclusion.

Parameters
name:String

Name of Object property to check

Returns:TokenFilter

TokenFilter to use for further calls within property value, unless return value is null or INCLUDE_ALL (which have simpler semantics)

includeRawValueback to summary
public boolean includeRawValue()

Call made to verify whether leaf-level raw (pre-encoded, not quoted by generator) value should be included in output or not.

Note

value itself not passed since it may come on multiple forms and is unlikely to be of much use in determining inclusion criteria.

Returns:boolean

True if the raw value is to be included; false if not

includeRootValueback to summary
public TokenFilter includeRootValue(int index)

Method called to check whether root-level value, at current output location, should be included in output. Three kinds of return values may be used as follows:

  • null to indicate that the root value should be skipped
  • INCLUDE_ALL to indicate that the root value should be included completely in output
  • Any other TokenFilter implementation (possibly this one) to mean that further inclusion calls on returned filter object need to be made as necessary, to determine inclusion.

The default implementation simply returns this to continue calling methods on this filter object, without full inclusion or exclusion.

Parameters
index:int

Index (0-based) of the root value to check

Returns:TokenFilter

TokenFilter to use for further calls within root value, unless return value is null or INCLUDE_ALL (which have simpler semantics)

includeStringback to summary
public boolean includeString(String value)

Call made to verify whether leaf-level String value should be included in output or not.

Parameters
value:String

Value to check

Returns:boolean

True if value is to be included; false if not

includeStringback to summary
public boolean includeString(Reader r, int maxLen)

Call made to verify whether leaf-level "streaming" String value should be included in output or not.

Note

note that any reads from passed in Reader may lead to actual loss of content to write; typically method should NOT access content passed via this method.

Parameters
r:Reader

Reader used to pass String value to parser

maxLen:int

indicated maximum length of String value

Returns:boolean

True if value is to be included; false if not

Since
2.11
includeValueback to summary
public boolean includeValue(JsonParser p) throws IOException

Call made when verifying whether a scalar value is being read from a parser.

Default action is to call _includeScalar() and return whatever it indicates.

Parameters
p:JsonParser

Parser that points to the value (typically delegate parser, not filtering parser that wraps it)

Returns:boolean

True if scalar value is to be included; false if not

Exceptions
IOException:
if there are any problems reading content (typically via calling passed-in JsonParser)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
com.fasterxml.jackson.core.filter back to summary

public final Enum TokenFilter.Inclusion

extends Enum<TokenFilter.Inclusion>
Class Inheritance

Enumeration that controls how TokenFilter return values are interpreted.
Since
2.12

Field Summary

Modifier and TypeField and Description
public static final TokenFilter.Inclusion
INCLUDE_ALL_AND_PATH

When TokenFilter.INCLUDE_ALL is returned, the corresponding token will be included as well as enclosing tokens up to the root

public static final TokenFilter.Inclusion
INCLUDE_NON_NULL

Tokens will be included if any non-null filter is returned.

public static final TokenFilter.Inclusion
ONLY_INCLUDE_ALL

Tokens will only be included if the filter returns TokenFilter.INCLUDE_ALL

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static TokenFilter.Inclusion
public static TokenFilter.Inclusion[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INCLUDE_ALL_AND_PATHback to summary
public static final TokenFilter.Inclusion INCLUDE_ALL_AND_PATH

When TokenFilter.INCLUDE_ALL is returned, the corresponding token will be included as well as enclosing tokens up to the root

INCLUDE_NON_NULLback to summary
public static final TokenFilter.Inclusion INCLUDE_NON_NULL

Tokens will be included if any non-null filter is returned. The exception is if a field name returns a non-null filter, but the field value returns a null filter. In this case the field name and value will both be omitted.

ONLY_INCLUDE_ALLback to summary
public static final TokenFilter.Inclusion ONLY_INCLUDE_ALL

Tokens will only be included if the filter returns TokenFilter.INCLUDE_ALL

Constructor Detail

Inclusionback to summary
private Inclusion()

Method Detail

valueOfback to summary
public static TokenFilter.Inclusion valueOf(String name)
valuesback to summary
public static TokenFilter.Inclusion[] values()