Class TokenFilter
- Direct Known Subclasses:
JsonPointerBasedFilter
FilteringGeneratorDelegate
.- Since:
- 2.6
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enumeration that controls how TokenFilter return values are interpreted. -
Field Summary
Modifier and TypeFieldDescriptionstatic final TokenFilter
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
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Overridable default implementation delegated to all scalar value inclusion check methods.void
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 thatINCLUDE_ALL
was returned.void
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 thatINCLUDE_ALL
was returned.Method called to check whether Array value at current output location should be included in output.Method called to check whether Object value at current output location should be included in output.boolean
Call made to verify whether leaf-level Binary value should be included in output or not.boolean
includeBoolean
(boolean value) Call made to verify whether leaf-level boolean value should be included in output or not.includeElement
(int index) Method called to check whether array element with specified index (zero-based), at current output location, should be included in output.boolean
includeEmbeddedValue
(Object value) Call made to verify whether leaf-level embedded (Opaque) value should be included in output or not.boolean
includeEmptyArray
(boolean contentsFiltered) Call made to verify whether leaf-level empty Array value should be included in output or not.boolean
includeEmptyObject
(boolean contentsFiltered) Call made to verify whether leaf-level empty Object value should be included in output or not.boolean
Call made to verify whether leaf-level null value should be included in output or not.boolean
includeNumber
(double value) Call made to verify whether leaf-leveldouble
value should be included in output or not.boolean
includeNumber
(float value) Call made to verify whether leaf-levelfloat
value should be included in output or not.boolean
includeNumber
(int value) Call made to verify whether leaf-levelint
value should be included in output or not.boolean
includeNumber
(long value) Call made to verify whether leaf-levellong
value should be included in output or not.boolean
includeNumber
(BigDecimal value) Call made to verify whether leaf-levelBigDecimal
value should be included in output or not.boolean
includeNumber
(BigInteger value) Call made to verify whether leaf-levelBigInteger
value should be included in output or not.includeProperty
(String name) Method called to check whether property value with specified name, at current output location, should be included in output.boolean
Call made to verify whether leaf-level raw (pre-encoded, not quoted by generator) value should be included in output or not.includeRootValue
(int index) Method called to check whether root-level value, at current output location, should be included in output.boolean
includeString
(Reader r, int maxLen) Call made to verify whether leaf-level "streaming" String value should be included in output or not.boolean
includeString
(String value) Call made to verify whether leaf-level String value should be included in output or not.boolean
Call made when verifying whether a scalar value is being read from a parser.toString()
-
Field Details
-
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 Details
-
TokenFilter
protected TokenFilter()
-
-
Method Details
-
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 skippedINCLUDE_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 to use for further calls within Array, unless return value
is
null
orINCLUDE_ALL
(which have simpler semantics)
-
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 skippedINCLUDE_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 to use for further calls within Array, unless return value
is
null
orINCLUDE_ALL
(which have simpler semantics)
-
filterFinishObject
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 thatINCLUDE_ALL
was returned. This occurs whenJsonGenerator.writeEndObject()
is called. -
filterFinishArray
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 thatINCLUDE_ALL
was returned. This occurs whenJsonGenerator.writeEndArray()
is called. -
includeProperty
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 skippedINCLUDE_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
- Name of Object property to check- Returns:
- TokenFilter to use for further calls within property value, unless return value
is
null
orINCLUDE_ALL
(which have simpler semantics)
-
includeElement
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 skippedINCLUDE_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
- Array element index (0-based) to check- Returns:
- TokenFilter to use for further calls within element value, unless return value
is
null
orINCLUDE_ALL
(which have simpler semantics)
-
includeRootValue
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 skippedINCLUDE_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
- Index (0-based) of the root value to check- Returns:
- TokenFilter to use for further calls within root value, unless return value
is
null
orINCLUDE_ALL
(which have simpler semantics)
-
includeValue
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
- Parser that points to the value (typicallydelegate
parser, not filtering parser that wraps it)- Returns:
- True if scalar value is to be included; false if not
- Throws:
IOException
- if there are any problems reading content (typically via calling passed-inJsonParser
)
-
includeBoolean
public boolean includeBoolean(boolean value) Call made to verify whether leaf-level boolean value should be included in output or not.- Parameters:
value
- Value to check- Returns:
- True if value is to be included; false if not
-
includeNull
public boolean includeNull()Call made to verify whether leaf-level null value should be included in output or not.- Returns:
- True if (
null
) value is to be included; false if not
-
includeString
Call made to verify whether leaf-level String value should be included in output or not.- Parameters:
value
- Value to check- Returns:
- True if value is to be included; false if not
-
includeString
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 used to pass String value to parsermaxLen
- indicated maximum length of String value- Returns:
- True if value is to be included; false if not
- Since:
- 2.11
-
includeNumber
public boolean includeNumber(int value) Call made to verify whether leaf-levelint
value should be included in output or not. NOTE: also called for `short`, `byte`- Parameters:
value
- Value to check- Returns:
- True if value is to be included; false if not
-
includeNumber
public boolean includeNumber(long value) Call made to verify whether leaf-levellong
value should be included in output or not.- Parameters:
value
- Value to check- Returns:
- True if value is to be included; false if not
-
includeNumber
public boolean includeNumber(float value) Call made to verify whether leaf-levelfloat
value should be included in output or not.- Parameters:
value
- Value to check- Returns:
- True if value is to be included; false if not
-
includeNumber
public boolean includeNumber(double value) Call made to verify whether leaf-leveldouble
value should be included in output or not.- Parameters:
value
- Value to check- Returns:
- True if value is to be included; false if not
-
includeNumber
Call made to verify whether leaf-levelBigDecimal
value should be included in output or not.- Parameters:
value
- Value to check- Returns:
- True if value is to be included; false if not
-
includeNumber
Call made to verify whether leaf-levelBigInteger
value should be included in output or not.- Parameters:
value
- Value to check- Returns:
- True if value is to be included; false if not
-
includeBinary
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:
- True if the binary value is to be included; false if not
-
includeRawValue
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:
- True if the raw value is to be included; false if not
-
includeEmbeddedValue
Call made to verify whether leaf-level embedded (Opaque) value should be included in output or not.- Parameters:
value
- Value to check- Returns:
- True if value is to be included; false if not
-
includeEmptyArray
public boolean includeEmptyArray(boolean contentsFiltered) Call made to verify whether leaf-level empty Array value should be included in output or not.- Parameters:
contentsFiltered
- True if Array had contents but they were filtered out (NOT included); false if we had actual empty Array.- Returns:
- True if value is to be included; false if not
- Since:
- 2.14
-
includeEmptyObject
public boolean includeEmptyObject(boolean contentsFiltered) Call made to verify whether leaf-level empty Object value should be included in output or not.- Parameters:
contentsFiltered
- True if Object had contents but they were filtered out (NOT included); false if we had actual empty Object.- Returns:
- True if value is to be included; false if not
- Since:
- 2.14
-
toString
-
_includeScalar
protected boolean _includeScalar()Overridable default implementation delegated to all scalar value inclusion check methods. The default implementation simply includes all leaf values.- Returns:
- Whether all leaf scalar values should be included (
true
) or not (false
)
-