Module swim.codec
Package swim.codec

Class 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

    Modifier and Type
    Method
    Description
    static Mark
    at(long offset, int line, int column)
    Returns a new Mark at the given zero-based byte offset, one-based line number, and one-based column number, with no attached note.
    static Mark
    at(long offset, int line, int column, String note)
    Returns a new Mark at the given zero-based byte offset, one-based line number, and one-based column number, with the attached note.
    int
    Returns the one-based column number of this position.
    int
     
    <T> Output<T>
    debug(Output<T> output)
    Writes a developer readable, debug-formatted string representation of this object to output.
    <T> Output<T>
    display(Output<T> output)
    Writes a human readable, display-formatted string representation of this object to output.
    end()
    Returns the last source position covered by this Tag.
    boolean
    equals(Object other)
     
    int
     
    int
    Returns the one-based line number of this position.
    max(Mark that)
    Returns this position, if its byte offset is greater than or equal to that position; otherwise returns that position.
    min(Mark that)
    Returns this position, if its byte offset is less than or equal to that position; otherwise returns that position.
    Returns the note attached to the marked position, or null if this position has no attached note.
    long
    Returns the zero-based byte offset of this position.
    shift(Mark mark)
    Returns the position of this Tag relative to the given mark.
    Returns the first source position covered by this Tag.
     
    union(Tag other)
    Returns a Tag that includes all source locations covered by both this tag, and some other tag.
    static Mark
    Returns a Mark at byte offset 0, line 1, and column 1, with no attached note.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • 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, or null if this position has no attached note.
    • min

      public Mark min(Mark that)
      Returns this position, if its byte offset is less than or equal to that position; otherwise returns that position.
    • max

      public Mark max(Mark that)
      Returns this position, if its byte offset is greater than or equal to that position; otherwise returns that position.
    • start

      public Mark start()
      Description copied from class: Tag
      Returns the first source position covered by this Tag.
      Specified by:
      start in class Tag
    • end

      public Mark end()
      Description copied from class: Tag
      Returns the last source position covered by this Tag.
      Specified by:
      end in class Tag
    • union

      public Tag union(Tag other)
      Description copied from class: Tag
      Returns a Tag that includes all source locations covered by both this tag, and some other tag.
      Specified by:
      union in class Tag
    • shift

      public Mark shift(Mark mark)
      Description copied from class: Tag
      Returns the position of this Tag relative to the given mark.
      Specified by:
      shift in class Tag
    • compareTo

      public int compareTo(Mark that)
      Specified by:
      compareTo in interface Comparable<Mark>
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • 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 to output.
      Specified by:
      display in interface Display
      Returns:
      the continuation of the output.
    • 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 to output.
      Specified by:
      debug in interface Debug
      Returns:
      the continuation of the output.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • zero

      public static Mark zero()
      Returns a Mark at byte offset 0, line 1, and column 1, with no attached note.
    • at

      public static Mark at(long offset, int line, int column, String note)
      Returns a new Mark at the given zero-based byte offset, one-based line number, and one-based column number, with the attached note.
    • at

      public static Mark at(long offset, int line, int column)
      Returns a new Mark at the given zero-based byte offset, one-based line number, and one-based column number, with no attached note.