java.lang.Object
java.lang.Record
org.elasticsearch.xcontent.XContentLocation
Simple data structure representing the line and column number of a position
in some XContent e.g. JSON. Locations are typically used to communicate the
position of a parsing error to end users and consequently have line and
column numbers starting from 1.
The optional byteOffset field holds the absolute byte position
within the source stream (-1 when not available). Byte offsets are
used for programmatic byte-range slicing and are not included in the
human-readable toString() output.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionXContentLocation(int lineNumber, int columnNumber) Backward-compatible constructor that setsbyteOffsetto-1(not available).XContentLocation(int lineNumber, int columnNumber, long byteOffset) Creates an instance of aXContentLocationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the value of thebyteOffsetrecord component.intReturns the value of thecolumnNumberrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanReturnstrueif the byte offset is available (non-negative).booleanReturnstrueif the column number is valid (1-based, so must be ≥ 1).booleanReturnstrueif the line number is valid (1-based, so must be ≥ 1).intReturns the value of thelineNumberrecord component.toString()Returns a string representation of this record class.
-
Field Details
-
UNKNOWN
-
-
Constructor Details
-
XContentLocation
public XContentLocation(int lineNumber, int columnNumber) Backward-compatible constructor that setsbyteOffsetto-1(not available). -
XContentLocation
public XContentLocation(int lineNumber, int columnNumber, long byteOffset) Creates an instance of aXContentLocationrecord class.- Parameters:
lineNumber- the value for thelineNumberrecord componentcolumnNumber- the value for thecolumnNumberrecord componentbyteOffset- the value for thebyteOffsetrecord component
-
-
Method Details
-
hasValidLineNumber
public boolean hasValidLineNumber()Returnstrueif the line number is valid (1-based, so must be ≥ 1). -
hasValidColumnNumber
public boolean hasValidColumnNumber()Returnstrueif the column number is valid (1-based, so must be ≥ 1). -
hasValidByteOffset
public boolean hasValidByteOffset()Returnstrueif the byte offset is available (non-negative). -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
lineNumber
public int lineNumber()Returns the value of thelineNumberrecord component.- Returns:
- the value of the
lineNumberrecord component
-
columnNumber
public int columnNumber()Returns the value of thecolumnNumberrecord component.- Returns:
- the value of the
columnNumberrecord component
-
byteOffset
public long byteOffset()Returns the value of thebyteOffsetrecord component.- Returns:
- the value of the
byteOffsetrecord component
-