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

      All Methods Static Methods Instance Methods Concrete Methods 
      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 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 to output.
      <T> Output<T> display​(Output<T> output)
      Writes a human readable, display-formatted string representation of this object to output.
      Mark end()
      Returns the last source position covered by this Tag.
      boolean equals​(Object other)  
      int hashCode()  
      int line()
      Returns the one-based line number of this position.
      Mark max​(Mark that)
      Returns this position, if its byte offset is greater than or equal to that position; otherwise returns that position.
      Mark min​(Mark that)
      Returns this position, if its byte offset is less than or equal to that position; otherwise returns that position.
      String note()
      Returns the note attached to the marked position, or null 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 this Tag relative to the given mark.
      Mark start()
      Returns the first source position covered by this Tag.
      String toString()  
      Tag union​(Tag other)
      Returns a Tag that includes all source locations covered by both this tag, and some other tag.
      static Mark zero()
      Returns a Mark at byte offset 0, line 1, and column 1, 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, 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
      • 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.
      • 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.