public class Position
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
column
The column number.
|
private int |
line
The line number.
|
static Position |
UNDEFINED
The "undefined position" constant used to compare to undefined
positions or remove positional information.
|
Constructor and Description |
---|
Position()
Constructs a new invalid source code position object.
|
Position(int line,
int column)
Constructs a new source code position object.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(java.lang.Object x)
Compares this position with the given object for order.
|
int |
compareTo(Position p)
Compares this position with the given object for order.
|
boolean |
equals(java.lang.Object x)
Compares this position with the given object for equality.
|
int |
getColumn()
Returns the column number of this position.
|
int |
getLine()
Returns the line number of this position.
|
int |
hashCode()
Returns the hash code of this position.
|
boolean |
isNegative()
Helper method for validity checks.
|
java.lang.String |
toString()
Returns a string representation of this object.
|
private final int line
private final int column
public static final Position UNDEFINED
Position()
public Position(int line, int column)
line
- the line number.column
- the column number.public int getLine()
public int getColumn()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object x)
equals
in class java.lang.Object
true
, if the given object is a position
equals to this position, false
otherwise.public int compareTo(java.lang.Object x)
x
- the position object to compare with.public int compareTo(Position p)
p
- the position to compare with.public boolean isNegative()
public java.lang.String toString()
toString
in class java.lang.Object