Top Description Fields Constructors Methods
com.fasterxml.jackson.core.io

public Class ContentReference

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.*, java.net.URI, .URL, java.nio.charset.StandardCharsets, java.util.Objects, com.fasterxml.jackson.core.ErrorReportConfiguration

Abstraction that encloses information about content being processed -- input source or output target, streaming or not -- for the purpose of including pertinent information in location (see com.fasterxml.jackson.core.JsonLocation) objections, most commonly to be printed out as part of Exception messages.
Since
2.13

Field Summary

Modifier and TypeField and Description
protected final boolean
_isContentTextual

Marker flag to indicate whether included content is textual or not: this is taken to mean, by default, that a snippet of content may be displayed for exception messages.

protected final int
_length

For static content, indicates length of content in the static array.

protected final int
_maxRawContentLength

max raw content to return as configured

protected final int
_offset

For static content, indicates offset from the beginning of static array.

protected final transient Object
_rawContent

Reference to the actual underlying content.

public static final int
DEFAULT_MAX_CONTENT_SNIPPET

Include at most first 500 characters/bytes from contents; should be enough to give context, but not cause unfortunate side effects in things like logs.

protected static final ContentReference
REDACTED_CONTENT

As content will be redacted by default in Jackson 2.16 and later, we'll use a new marker reference for slightly different description from "unknown", to indicate explicit removal of source/content reference (as opposed to it missing from not being available or so)

private static final long
protected static final ContentReference
UNKNOWN_CONTENT

Constant that may be used when source/target content is not known (or not exposed).

Constructor Summary

AccessConstructor and Description
protected
ContentReference(boolean isContentTextual, Object rawContent)

Deprecated Since 2.16.
protected
ContentReference(boolean isContentTextual, Object rawContent, int offset, int length)

Deprecated Since 2.16.
protected
ContentReference(boolean isContentTextual, Object rawContent, ErrorReportConfiguration errorReportConfiguration)

protected
ContentReference(boolean isContentTextual, Object rawContent, int offset, int length, ErrorReportConfiguration errorReportConfiguration)

Method Summary

Modifier and TypeMethod and Description
protected int
protected boolean
_appendEscaped(StringBuilder sb, int ctrlChar)

protected String
_truncate(CharSequence cs, int[] offsets, int maxSnippetLen)

protected String
_truncate(char[] cs, int[] offsets, int maxSnippetLen)

protected String
_truncate(byte[] b, int[] offsets, int maxSnippetLen)

protected void
_truncateOffsets(int[] offsets, int actualLength)

public StringBuilder

Returns:

StringBuilder passed as argument (for call chaining)
appendSourceDescription
(StringBuilder
StringBuilder to append description to
sb
)

Method for appending a "source description" when content represented by this reference is read.

public String

Returns:

Description constructed
buildSourceDescription
()

Method for constructing a "source description" when content represented by this reference is read.

public static ContentReference
construct(boolean isContentTextual, Object rawContent)

Deprecated Since 2.16.
public static ContentReference
construct(boolean isContentTextual, Object rawContent, int offset, int length)

Deprecated Since 2.16.
public static ContentReference
construct(boolean isContentTextual, Object rawContent, int offset, int length, ErrorReportConfiguration errorReportConfiguration)

public static ContentReference
construct(boolean isContentTextual, Object rawContent, ErrorReportConfiguration errorReportConfiguration)

public int
public int
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public Object
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean
protected int

Returns:

Maximum content snippet to include before truncating
maxRawContentLength
()

Internal accessor, overridable, used for checking length (in units in which content is counted, either bytes or chars) to use for truncation (so as not to include full content for humongous sources or targets)

public static ContentReference

Returns:

Instance with minimal information about content (basically just raw content reference without offsets
rawReference
(boolean
Is raw content assumed to have textual content (true) or binary (false)
isContentTextual
,
Object
Underlying raw content access
rawContent
)

Factory method for legacy code to use for constructing instances to content about which only minimal amount of information is available.

public static ContentReference
rawReference(Object rawContent)

private void
protected Object
public static ContentReference

Returns:

Placeholder instance to use in cases where reference is explicitly blocked, usually for security reasons.
redacted
()

Accessor for getting a placeholder when actual content is not to be exposed: different from unknown() where content is not available to be referenced.

public static ContentReference

Returns:

Placeholder "unknown" (or "empty") instance to use instead of null reference
unknown
()

Accessor for getting a placeholder for cases where actual content is not known (or is not something that system wants to expose).

private void
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

_isContentTextualback to summary
protected final boolean _isContentTextual

Marker flag to indicate whether included content is textual or not: this is taken to mean, by default, that a snippet of content may be displayed for exception messages.

_lengthback to summary
protected final int _length

For static content, indicates length of content in the static array. -1 if not in use.

_maxRawContentLengthback to summary
protected final int _maxRawContentLength

max raw content to return as configured

Since
2.16
_offsetback to summary
protected final int _offset

For static content, indicates offset from the beginning of static array. -1 if not in use.

_rawContentback to summary
protected final transient Object _rawContent

Reference to the actual underlying content.

DEFAULT_MAX_CONTENT_SNIPPETback to summary
public static final int DEFAULT_MAX_CONTENT_SNIPPET

Deprecated

Since 2.16. ErrorReportConfiguration#DEFAULT_MAX_RAW_CONTENT_LENGTH will be used instead.

Include at most first 500 characters/bytes from contents; should be enough to give context, but not cause unfortunate side effects in things like logs.

Annotations
@Deprecated
Since
2.9
REDACTED_CONTENTback to summary
protected static final ContentReference REDACTED_CONTENT

As content will be redacted by default in Jackson 2.16 and later, we'll use a new marker reference for slightly different description from "unknown", to indicate explicit removal of source/content reference (as opposed to it missing from not being available or so)

Since
2.16
serialVersionUIDback to summary
private static final long serialVersionUID
UNKNOWN_CONTENTback to summary
protected static final ContentReference UNKNOWN_CONTENT

Constant that may be used when source/target content is not known (or not exposed).

Note

As of 2.13 assume to contain Binary content, meaning that no content snippets will be included.

Constructor Detail

ContentReferenceback to summary
protected ContentReference(boolean isContentTextual, Object rawContent)
Annotations
@Deprecated
ContentReferenceback to summary
protected ContentReference(boolean isContentTextual, Object rawContent, int offset, int length)
Annotations
@Deprecated
ContentReferenceback to summary
protected ContentReference(boolean isContentTextual, Object rawContent, ErrorReportConfiguration errorReportConfiguration)
Since
2.16
ContentReferenceback to summary
protected ContentReference(boolean isContentTextual, Object rawContent, int offset, int length, ErrorReportConfiguration errorReportConfiguration)
Since
2.16

Method Detail

_appendback to summary
protected int _append(StringBuilder sb, String content)
_appendEscapedback to summary
protected boolean _appendEscaped(StringBuilder sb, int ctrlChar)
_truncateback to summary
protected String _truncate(CharSequence cs, int[] offsets, int maxSnippetLen)
_truncateback to summary
protected String _truncate(char[] cs, int[] offsets, int maxSnippetLen)
_truncateback to summary
protected String _truncate(byte[] b, int[] offsets, int maxSnippetLen)
_truncateOffsetsback to summary
protected void _truncateOffsets(int[] offsets, int actualLength)
appendSourceDescriptionback to summary
public StringBuilder appendSourceDescription(StringBuilder sb)

Method for appending a "source description" when content represented by this reference is read.

Parameters
sb:StringBuilder

StringBuilder to append description to

Returns:StringBuilder

StringBuilder passed as argument (for call chaining)

buildSourceDescriptionback to summary
public String buildSourceDescription()

Method for constructing a "source description" when content represented by this reference is read.

Returns:String

Description constructed

constructback to summary
public static ContentReference construct(boolean isContentTextual, Object rawContent)

Deprecated

Since 2.16. Use construct(boolean, Object, ErrorReportConfiguration) instead.

Annotations
@Deprecated
constructback to summary
public static ContentReference construct(boolean isContentTextual, Object rawContent, int offset, int length)
Annotations
@Deprecated
constructback to summary
public static ContentReference construct(boolean isContentTextual, Object rawContent, int offset, int length, ErrorReportConfiguration errorReportConfiguration)
Since
2.16
constructback to summary
public static ContentReference construct(boolean isContentTextual, Object rawContent, ErrorReportConfiguration errorReportConfiguration)
Since
2.16
contentLengthback to summary
public int contentLength()
contentOffsetback to summary
public int contentOffset()
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getRawContentback to summary
public Object getRawContent()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
hasTextualContentback to summary
public boolean hasTextualContent()
maxRawContentLengthback to summary
protected int maxRawContentLength()

Internal accessor, overridable, used for checking length (in units in which content is counted, either bytes or chars) to use for truncation (so as not to include full content for humongous sources or targets)

Returns:int

Maximum content snippet to include before truncating

See Also
ErrorReportConfiguration#getMaxRawContentLength()
rawReferenceback to summary
public static ContentReference rawReference(boolean isContentTextual, Object rawContent)

Factory method for legacy code to use for constructing instances to content about which only minimal amount of information is available. Assumed not to contain textual content (no snippet displayed).

Parameters
isContentTextual:boolean

Is raw content assumed to have textual content (true) or binary (false)

rawContent:Object

Underlying raw content access

Returns:ContentReference

Instance with minimal information about content (basically just raw content reference without offsets

rawReferenceback to summary
public static ContentReference rawReference(Object rawContent)
readObjectback to summary
private void readObject(ObjectInputStream in) throws IOException
readResolveback to summary
protected Object readResolve()
redactedback to summary
public static ContentReference redacted()

Accessor for getting a placeholder when actual content is not to be exposed: different from unknown() where content is not available to be referenced.

Returns:ContentReference

Placeholder instance to use in cases where reference is explicitly blocked, usually for security reasons.

Since
2.16
unknownback to summary
public static ContentReference unknown()

Accessor for getting a placeholder for cases where actual content is not known (or is not something that system wants to expose).

Returns:ContentReference

Placeholder "unknown" (or "empty") instance to use instead of null reference

writeObjectback to summary
private void writeObject(ObjectOutputStream out) throws IOException