Class FilePosition

  • All Implemented Interfaces:
    java.io.Serializable


    @API(status=STABLE,
         since="1.0")
    public class FilePosition
    extends java.lang.Object
    implements java.io.Serializable
    Position inside a file represented by line and column numbers.
    Since:
    1.0
    See Also:
    Serialized Form
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      static FilePosition from​(int line)
      Create a new FilePosition using the supplied line number and an undefined column number.
      static FilePosition from​(int line, int column)
      Create a new FilePosition using the supplied line and column numbers.
      java.util.Optional<java.lang.Integer> getColumn​()
      Get the column number of this FilePosition, if available.
      int getLine​()
      Get the line number of this FilePosition.
      int hashCode​()  
      java.lang.String toString​()  
      • Methods inherited from class java.lang.Object

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

      • from

        public static FilePosition from​(int line)
        Create a new FilePosition using the supplied line number and an undefined column number.
        Parameters:
        line - the line number; must be greater than zero
      • from

        public static FilePosition from​(int line,
                                        int column)
        Create a new FilePosition using the supplied line and column numbers.
        Parameters:
        line - the line number; must be greater than zero
        column - the column number; must be greater than zero
      • getLine

        public int getLine​()
        Get the line number of this FilePosition.
        Returns:
        the line number
      • getColumn

        public java.util.Optional<java.lang.Integer> getColumn​()
        Get the column number of this FilePosition, if available.
        Returns:
        an Optional containing the column number; never null but potentially empty
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode​()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString​()
        Overrides:
        toString in class java.lang.Object