Package com.fasterxml.jackson.core
Class JsonLocation
- java.lang.Object
-
- com.fasterxml.jackson.core.JsonLocation
-
- All Implemented Interfaces:
java.io.Serializable
public class JsonLocation extends java.lang.Object implements java.io.Serializable
Object that encapsulates Location information used for reporting parsing (or potentially generation) errors, as well as current location within input streams.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
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.static JsonLocation
NA
Shared immutable "N/A location" that can be returned to indicate that no location information is available.
-
Constructor Summary
Constructors Constructor Description JsonLocation(java.lang.Object srcRef, long totalChars, int lineNr, int colNr)
JsonLocation(java.lang.Object sourceRef, long totalBytes, long totalChars, int lineNr, int columnNr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object other)
long
getByteOffset()
long
getCharOffset()
int
getColumnNr()
int
getLineNr()
java.lang.Object
getSourceRef()
Reference to the original resource being read, if one available.int
hashCode()
java.lang.String
sourceDescription()
Accessor for getting a textual description of source reference (Object returned bygetSourceRef()
), as included in description returned bytoString()
.java.lang.String
toString()
-
-
-
Field Detail
-
MAX_CONTENT_SNIPPET
public static final int 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
-
NA
public static final JsonLocation NA
Shared immutable "N/A location" that can be returned to indicate that no location information is available.NOTE: before 2.9, Location was given as String "N/A"; with 2.9 it was removed so that source should be indicated as "UNKNOWN".
-
-
Method Detail
-
getSourceRef
public java.lang.Object getSourceRef()
Reference to the original resource being read, if one available. For example, when a parser has been constructed by passing aFile
instance, this method would return that File. Will return null if no such reference is available, for example whenInputStream
was used to construct the parser instance.
-
getLineNr
public int getLineNr()
- Returns:
- Line number of the location (1-based)
-
getColumnNr
public int getColumnNr()
- Returns:
- Column number of the location (1-based)
-
getCharOffset
public long getCharOffset()
- Returns:
- Character offset within underlying stream, reader or writer, if available; -1 if not.
-
getByteOffset
public long getByteOffset()
- Returns:
- Byte offset within underlying stream, reader or writer, if available; -1 if not.
-
sourceDescription
public java.lang.String sourceDescription()
Accessor for getting a textual description of source reference (Object returned bygetSourceRef()
), as included in description returned bytoString()
.NOTE: not added as a "getter" to prevent it from getting serialized.
- Since:
- 2.9
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-