Package org.jsoup.nodes
Class Range.Position
java.lang.Object
org.jsoup.nodes.Range.Position
- Enclosing class:
- Range
public static class Range.Position
extends Object
A Position describes a source offset and its line and column coordinates. Positions are available when position
tracking is enabled with
Parser.setTrackPosition( boolean) before parsing.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPosition(int pos, int lineNumber, int columnNumber) Deprecated.Use parser position tracking instead. -
Method Summary
Modifier and TypeMethodDescriptionintGets the cursor number (1-based) of the original input source that this Position was read at.booleanequals(Object o) inthashCode()booleanTest if this position was tracked during parsing.intGets the line number (1-based) of the original input source that this Position was read at.intpos()Gets the position index (0-based) of the original input source that this Position was read at.StringtoString()Gets a String presentation of this Position, in the formatline,column:pos.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
Position
@Deprecated public Position(int pos, int lineNumber, int columnNumber) Deprecated.Use parser position tracking instead. Will be removed in jsoup 1.24.1.Deprecated parser-internal position setup method, retained for source compatibility. Position objects are normally derived from a Range's retained source offsets.- Parameters:
pos- position indexlineNumber- line numbercolumnNumber- column number
-
-
Method Details
-
pos
public int pos()Gets the position index (0-based) of the original input source that this Position was read at. This tracks the total number of characters read into the source at this position, regardless of the number of preceding lines.- Returns:
- the position, or
-1if untracked.
-
lineNumber
public int lineNumber()Gets the line number (1-based) of the original input source that this Position was read at.- Returns:
- the line number, or
-1if untracked.
-
columnNumber
public int columnNumber()Gets the cursor number (1-based) of the original input source that this Position was read at. The cursor number resets to 1 on every new line.- Returns:
- the cursor number, or
-1if untracked.
-
isTracked
public boolean isTracked()Test if this position was tracked during parsing.- Returns:
- true if this was tracked during parsing, false otherwise (and all fields will be
-1).
-
toString
public String toString()Gets a String presentation of this Position, in the formatline,column:pos.- Overrides:
toStringin classObject- Returns:
- a String
-
equals
public boolean equals(Object o) - Overrides:
equalsin classObject
-
hashCode
public int hashCode()- Overrides:
hashCodein classObject
-