java.lang.Object
tools.jackson.core.TokenStreamLocation
- All Implemented Interfaces:
Serializable
Object that encapsulates Location information used for reporting
parsing (or potentially generation) errors, as well as current location
within input streams.
NOTE: users should be careful if using equals(java.lang.Object) implementation as
it may or may not compare underlying "content reference" for equality.
Instead if would make sense to explicitly implementing equality checks
using specific criteria caller desires
NOTE: in Jackson 2.x this type was named JsonLocation
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intprotected final ContentReferenceReference to input source; never null (but may be that ofContentReference.unknown()).protected final intprotected StringLazily constructed description for source; constructed if and whensourceDescription()is called, retained.protected final longprotected final longstatic final TokenStreamLocationShared immutable "N/A location" that can be returned to indicate that no location information is available. -
Constructor Summary
ConstructorsConstructorDescriptionTokenStreamLocation(ContentReference contentRef, long totalChars, int lineNr, int colNr) TokenStreamLocation(ContentReference contentRef, long totalBytes, long totalChars, int lineNr, int columnNr) -
Method Summary
Modifier and TypeMethodDescriptionAccessor for information about the original input source content is being read from.booleanlonglongintAccess for getting column offset of this location, if available.intAccess for getting line number of this location, if available.inthashCode()Accessor for a brief summary of Location offsets (line number, column position, or byte offset, if available).Accessor for getting a textual description of source reference (Object returned bycontentReference()), as included in description returned bytoString().toString()
-
Field Details
-
NA
Shared immutable "N/A location" that can be returned to indicate that no location information is available. -
_totalBytes
protected final long _totalBytes -
_totalChars
protected final long _totalChars -
_lineNr
protected final int _lineNr -
_columnNr
protected final int _columnNr -
_contentReference
Reference to input source; never null (but may be that ofContentReference.unknown()). -
_sourceDescription
Lazily constructed description for source; constructed if and whensourceDescription()is called, retained.- Since:
- 2.13
-
-
Constructor Details
-
TokenStreamLocation
-
TokenStreamLocation
public TokenStreamLocation(ContentReference contentRef, long totalBytes, long totalChars, int lineNr, int columnNr)
-
-
Method Details
-
contentReference
Accessor for information about the original input source content is being read from. Returned reference is nevernullbut may not contain useful information.NOTE: not getter, on purpose, to avoid inclusion if serialized using default Jackson serializer.
- Returns:
- Object with information about input source.
-
getLineNr
public int getLineNr()Access for getting line number of this location, if available. Note that line number is typically not available for binary formats.- Returns:
- Line number of the location (1-based), if available;
-1if not.
-
getColumnNr
public int getColumnNr()Access for getting column offset of this location, if available. Note that column position is typically not available for binary formats. Note: this returns an offset that is in units of input, so forbyte-based input sources (likeInputStream) this does not take into account multi-byte characters: one logical character can be 1, 2 or 3 bytes long. To calculate column position in characters eitherchar-based input source (likeReader) needs to be used, or content needs to be explicitly decoded.- Returns:
- Column offset of the location (1-based), if available;
-1if not.
-
getCharOffset
public long getCharOffset()- Returns:
- Character offset within underlying stream, reader or writer,
if available;
-1if not.
-
getByteOffset
public long getByteOffset()- Returns:
- Byte offset within underlying stream, reader or writer,
if available;
-1if not.
-
sourceDescription
Accessor for getting a textual description of source reference (Object returned bycontentReference()), as included in description returned bytoString().Note: implementation will simply call
ContentReference.buildSourceDescription())NOTE: not added as a "getter" to prevent it from getting serialized.
- Returns:
- Description of the source reference (see
contentReference()
-
offsetDescription
Accessor for a brief summary of Location offsets (line number, column position, or byte offset, if available).- Returns:
- Description of available relevant location offsets; combination of line number and column position or byte offset
-
appendOffsetDescription
-
hashCode
public int hashCode() -
equals
-
toString
-
toString
-