Package com.fasterxml.jackson.core.io
Class ContentReference
- java.lang.Object
-
- com.fasterxml.jackson.core.io.ContentReference
-
- All Implemented Interfaces:
Serializable
public class ContentReference extends Object implements Serializable
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 (seeJsonLocation
) objections, most commonly to be printed out as part ofException
messages.- Since:
- 2.13
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringBuilder
appendSourceDescription(StringBuilder sb)
Method for appending a "source description" when content represented by this reference is read.String
buildSourceDescription()
Method for constructing a "source description" when content represented by this reference is read.static ContentReference
construct(boolean isContentTextual, Object rawContent)
static ContentReference
construct(boolean isContentTextual, Object rawContent, int offset, int length)
int
contentLength()
int
contentOffset()
boolean
equals(Object other)
Object
getRawContent()
int
hashCode()
boolean
hasTextualContent()
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.static ContentReference
rawReference(Object rawContent)
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).
-
-
-
Field Detail
-
DEFAULT_MAX_CONTENT_SNIPPET
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.- Since:
- 2.9
- See Also:
- Constant Field Values
-
-
Method Detail
-
unknown
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:
- Placeholder "unknown" (or "empty") instance to use instead of
null
reference
-
construct
public static ContentReference construct(boolean isContentTextual, Object rawContent)
-
construct
public static ContentReference construct(boolean isContentTextual, Object rawContent, int offset, int length)
-
rawReference
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
- Is raw content assumed to have textual content (true
) or binary (false
)rawContent
- Underlying raw content access- Returns:
- Instance with minimal information about content (basically just raw content reference without offsets
-
rawReference
public static ContentReference rawReference(Object rawContent)
-
hasTextualContent
public boolean hasTextualContent()
-
getRawContent
public Object getRawContent()
-
contentOffset
public int contentOffset()
-
contentLength
public int contentLength()
-
buildSourceDescription
public String buildSourceDescription()
Method for constructing a "source description" when content represented by this reference is read.- Returns:
- Description constructed
-
appendSourceDescription
public StringBuilder appendSourceDescription(StringBuilder sb)
Method for appending a "source description" when content represented by this reference is read.- Parameters:
sb
- StringBuilder to append description to- Returns:
- StringBuilder passed as argument (for call chaining)
-
-