public class ContentReference extends Object implements Serializable
JsonLocation
)
objections, most commonly to be printed out as part of Exception
messages.Modifier and Type | Field and Description |
---|---|
protected 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 int |
_length
For static content, indicates length of content in
the static array.
|
protected int |
_offset
For static content, indicates offset from the beginning
of static array.
|
protected Object |
_rawContent
Reference to the actual underlying content.
|
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.
|
protected static ContentReference |
UNKNOWN_CONTENT
Constant that may be used when source/target content is not known
(or not exposed).
|
Modifier | Constructor and Description |
---|---|
protected |
ContentReference(boolean isContentTextual,
Object rawContent) |
protected |
ContentReference(boolean isContentTextual,
Object rawContent,
int offset,
int length) |
Modifier and Type | Method and Description |
---|---|
protected int |
_append(StringBuilder sb,
String content) |
protected boolean |
_appendEscaped(StringBuilder sb,
int ctrlChar) |
protected String |
_truncate(byte[] b,
int[] offsets,
int maxSnippetLen) |
protected String |
_truncate(char[] cs,
int[] offsets,
int maxSnippetLen) |
protected String |
_truncate(CharSequence cs,
int[] offsets,
int maxSnippetLen) |
protected void |
_truncateOffsets(int[] offsets,
int actualLength) |
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() |
protected int |
maxContentSnippetLength()
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)
|
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) |
protected Object |
readResolve() |
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).
|
protected static final ContentReference UNKNOWN_CONTENT
NOTE: As of 2.13 assume to contain Binary content, meaning that no content snippets will be included.
public static final int DEFAULT_MAX_CONTENT_SNIPPET
protected final transient Object _rawContent
protected final int _offset
-1
if not in use.protected final int _length
-1
if not in use.protected final boolean _isContentTextual
protected ContentReference(boolean isContentTextual, Object rawContent)
protected ContentReference(boolean isContentTextual, Object rawContent, int offset, int length)
public static ContentReference unknown()
null
referencepublic static ContentReference construct(boolean isContentTextual, Object rawContent)
public static ContentReference construct(boolean isContentTextual, Object rawContent, int offset, int length)
public static ContentReference rawReference(boolean isContentTextual, Object rawContent)
isContentTextual
- Is raw content assumed to have textual content
(true
) or binary (false
)rawContent
- Underlying raw content accesspublic static ContentReference rawReference(Object rawContent)
protected Object readResolve()
public boolean hasTextualContent()
public Object getRawContent()
public int contentOffset()
public int contentLength()
protected int maxContentSnippetLength()
public String buildSourceDescription()
public StringBuilder appendSourceDescription(StringBuilder sb)
sb
- StringBuilder to append description toprotected 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)
protected int _append(StringBuilder sb, String content)
protected boolean _appendEscaped(StringBuilder sb, int ctrlChar)
Copyright © 2008–2021 FasterXML. All rights reserved.