Class Location

java.lang.Object
org.ec4j.core.parser.Location

public class Location extends Object
An immutable object that represents a location in the parsed text.
  • Field Details

    • column

      private final int column
      The column number, starting at 1.
    • line

      private final int line
      The line number, starting at 1.
    • offset

      private final int offset
      The absolute character index, starting at 0.
  • Constructor Details

    • Location

      public Location(int offset, int line, int column)
  • Method Details

    • parse

      public static Location parse(String locationString)
      Parses a Location from a String that has the format defined by toString(). Should make it easier to write tests.
      Parameters:
      locationString - the location string to parse
      Returns:
      a new Location parsed out of the given locationString
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getColumn

      public int getColumn()
      Returns:
      the column number, the first column is 1
    • getLine

      public int getLine()
      Returns:
      the line number, the first line is 1
    • getOffset

      public int getOffset()
      Returns:
      an absolute index within the file; the first offset is 0
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object