public final class Reference extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<Reference>
| Constructor and Description |
|---|
Reference()
Construct a new reference with the position
0 and 0 length. |
Reference(int position)
Construct a new reference wit the given
position and 0 length. |
Reference(int position,
int length)
Construct a new reference that starts at the given
position and has the
given length. |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(@NotNull Reference reference)
A reference is greater that another reference when it has a position less that the
other.
|
boolean |
equals(@Nullable java.lang.Object object)
A reference is equals another object, if that object is a reference and has the
same
position() and length() of this source. |
int |
hashCode()
The hash code of a reference is calculated as follows.
|
int |
length()
The length of this reference.
|
int |
position()
Return where this reference starts at its document.
|
@NotNull Reference |
subReference(int position)
Slice this reference from the given
position to the end of this reference. |
@NotNull Reference |
subReference(int position,
int length)
Slice this reference from the given
position and limit it with the given
length. |
@NotNull java.lang.String |
toString()
Returns a string representation of this reference.
|
public Reference()
0 and 0 length.public Reference(int position)
position and 0 length.position - the position of the constructed reference.java.lang.IllegalArgumentException - if the given position is negative.public Reference(int position,
int length)
position and has the
given length.position - the position where the constructed reference will start.length - the length of the constructed reference.java.lang.IllegalArgumentException - if the given position or length is
negative.@Contract(pure=true)
public int compareTo(@NotNull
@NotNull Reference reference)
compareTo in interface java.lang.Comparable<Reference>reference - the reference to be compare to this reference.reference.
-1 if this reference is less than the given reference. 1
if this reference is greater. 0 if they are equal.java.lang.NullPointerException - if the given reference is null.@Contract(value="null->false",
pure=true)
public boolean equals(@Nullable
@Nullable java.lang.Object object)
position() and length() of this source.
equals = object instanceof Reference &&
object.position == this.position &&
object.length == this.length
equals in class java.lang.Objectobject - the object to be matched.@Contract(pure=true) public int hashCode()
hashCode = <Position> + <Length>
hashCode in class java.lang.Object@NotNull @Contract(pure=true) public @NotNull java.lang.String toString()
toString = (<Position>, <Length>)
toString in class java.lang.Object@Contract(pure=true) public int length()
@Contract(pure=true) public int position()
@NotNull
@Contract(value="_->new",
pure=true)
public @NotNull Reference subReference(int position)
position to the end of this reference.position - the position where the new slice reference will have relative to
this reference.position relative to this reference.java.lang.IllegalArgumentException - if the given position is negative.java.lang.IndexOutOfBoundsException - if position > this.length().java.lang.IllegalStateException - if this reference is a deserialized reference.@NotNull
@Contract(value="_,_->new",
pure=true)
public @NotNull Reference subReference(int position,
int length)
position and limit it with the given
length.position - the position where the new slice reference will have relative to
this reference.length - the length of the new slice reference.position
relative to this reference and have the given length.java.lang.IllegalArgumentException - if the given position or length
is negative.java.lang.IndexOutOfBoundsException - if position + length > this.length().java.lang.IllegalStateException - if this reference is a deserialized reference.