Class JsonLocation

  • All Implemented Interfaces:

    public class JsonLocation
    extends Object
    implements 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 Detail


        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.
        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".

    • Constructor Detail

      • JsonLocation

        public JsonLocation​(Object srcRef,
                            long totalChars,
                            int lineNr,
                            int colNr)
      • JsonLocation

        public JsonLocation​(Object sourceRef,
                            long totalBytes,
                            long totalChars,
                            int lineNr,
                            int columnNr)
    • Method Detail

      • getSourceRef

        public Object getSourceRef()
        Reference to the original resource being read, if one available. For example, when a parser has been constructed by passing a File instance, this method would return that File. Will return null if no such reference is available, for example when InputStream was used to construct the parser instance.
        Source reference this location was constructed with, if any; null if none
      • getLineNr

        public int getLineNr()
        Line number of the location (1-based)
      • getColumnNr

        public int getColumnNr()
        Column number of the location (1-based)
      • getCharOffset

        public long getCharOffset()
        Character offset within underlying stream, reader or writer, if available; -1 if not.
      • getByteOffset

        public long getByteOffset()
        Byte offset within underlying stream, reader or writer, if available; -1 if not.
      • sourceDescription

        public String sourceDescription()
        Accessor for getting a textual description of source reference (Object returned by getSourceRef()), as included in description returned by toString().

        NOTE: not added as a "getter" to prevent it from getting serialized.

        Description of the source reference (see getSourceRef()
      • hashCode

        public int hashCode()
        hashCode in class Object