Class FilePosition

  • All Implemented Interfaces:
    Serializable

    @API(status=STABLE,
         since="1.7")
    public class FilePosition
    extends Object
    implements Serializable
    Position inside a file represented by line and column numbers.
    Since:
    1.7
    See Also:
    Serialized Form
    Implementation Note:
    This class is a copy of FilePosition, which is not accessible from this package. The decision to duplicate it is motivated by an eventual divergence between the two classes in the future.
    • 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
        Returns:
        a FilePosition with the given line number
      • 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
        Returns:
        a FilePosition with the given line and column numbers
      • fromQuery

        public static Optional<FilePosition> fromQuery​(String query)
        Create an optional FilePosition by parsing the supplied query string.

        Examples of valid query strings:

        • "line=23"
        • "line=23&column=42"
        Parameters:
        query - the query string; may be null
        Returns:
        an Optional containing a FilePosition with the parsed line and column numbers; never null but potentially empty
        Since:
        1.3
        See Also:
        from(int), from(int, int)
      • getLine

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

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

        public int hashCode()
        Overrides:
        hashCode in class Object