- java.lang.Object
-
- swim.codec.Tag
-
- swim.codec.Mark
-
- All Implemented Interfaces:
Comparable<Mark>
,Debug
,Display
public final class Mark extends Tag implements Comparable<Mark>
Description of a source position, identified by byte offset, line, and column number, with an optional note.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Mark
at(long offset, int line, int column)
Returns a newMark
at the given zero-based byteoffset
, one-basedline
number, and one-basedcolumn
number, with no attached note.static Mark
at(long offset, int line, int column, String note)
Returns a newMark
at the given zero-based byteoffset
, one-basedline
number, and one-basedcolumn
number, with the attachednote
.int
column()
Returns the one-based column number of this position.int
compareTo(Mark that)
<T> Output<T>
debug(Output<T> output)
Writes a developer readable, debug-formatted string representation of this object tooutput
.<T> Output<T>
display(Output<T> output)
Writes a human readable, display-formatted string representation of this object tooutput
.Mark
end()
Returns the last source position covered by thisTag
.boolean
equals(Object other)
int
hashCode()
int
line()
Returns the one-based line number of this position.Mark
max(Mark that)
Returnsthis
position, if its byte offset is greater than or equal tothat
position; otherwise returnsthat
position.Mark
min(Mark that)
Returnsthis
position, if its byte offset is less than or equal tothat
position; otherwise returnsthat
position.String
note()
Returns the note attached to the marked position, ornull
if this position has no attached note.long
offset()
Returns the zero-based byte offset of this position.Mark
shift(Mark mark)
Returns the position of thisTag
relative to the givenmark
.Mark
start()
Returns the first source position covered by thisTag
.String
toString()
Tag
union(Tag other)
Returns aTag
that includes all source locations covered by both this tag, and someother
tag.static Mark
zero()
Returns aMark
at byte offset0
, line1
, and column1
, with no attached note.
-
-
-
Method Detail
-
offset
public long offset()
Returns the zero-based byte offset of this position.
-
line
public int line()
Returns the one-based line number of this position.
-
column
public int column()
Returns the one-based column number of this position.
-
note
public String note()
Returns the note attached to the marked position, ornull
if this position has no attached note.
-
min
public Mark min(Mark that)
Returnsthis
position, if its byte offset is less than or equal tothat
position; otherwise returnsthat
position.
-
max
public Mark max(Mark that)
Returnsthis
position, if its byte offset is greater than or equal tothat
position; otherwise returnsthat
position.
-
start
public Mark start()
Description copied from class:Tag
Returns the first source position covered by thisTag
.
-
end
public Mark end()
Description copied from class:Tag
Returns the last source position covered by thisTag
.
-
union
public Tag union(Tag other)
Description copied from class:Tag
Returns aTag
that includes all source locations covered by both this tag, and someother
tag.
-
shift
public Mark shift(Mark mark)
Description copied from class:Tag
Returns the position of thisTag
relative to the givenmark
.
-
compareTo
public int compareTo(Mark that)
- Specified by:
compareTo
in interfaceComparable<Mark>
-
display
public <T> Output<T> display(Output<T> output)
Description copied from interface:Display
Writes a human readable, display-formatted string representation of this object tooutput
.
-
debug
public <T> Output<T> debug(Output<T> output)
Description copied from interface:Debug
Writes a developer readable, debug-formatted string representation of this object tooutput
.
-
zero
public static Mark zero()
Returns aMark
at byte offset0
, line1
, and column1
, with no attached note.
-
at
public static Mark at(long offset, int line, int column, String note)
Returns a newMark
at the given zero-based byteoffset
, one-basedline
number, and one-basedcolumn
number, with the attachednote
.
-
at
public static Mark at(long offset, int line, int column)
Returns a newMark
at the given zero-based byteoffset
, one-basedline
number, and one-basedcolumn
number, with no attached note.
-
-