Package org.jsoup.nodes
Class Range
java.lang.Object
org.jsoup.nodes.Range
A Range object tracks the character positions in the original input source where a Node starts or ends. If you want to
track these positions, tracking must be enabled in the Parser with
Parser.setTrackPosition(boolean)
.- Since:
- 1.15.2
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A Position object tracks the character position in the original input source where a Node starts or ends. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Range.Position
private static final String
private static final String
private final Range.Position
private static final Range
private static final Range.Position
-
Constructor Summary
ConstructorsConstructorDescriptionRange
(Range.Position start, Range.Position end) Creates a new Range with start and end Positions. -
Method Summary
Modifier and TypeMethodDescriptionend()
Get the end position of this node.boolean
int
hashCode()
boolean
Test if this source range was tracked during parsing.(package private) static Range
Retrieves the source range for a given Node.start()
Get the start position of this node.toString()
Gets a String presentation of this Range, in the formatline,column:pos-line,column:pos
.void
Internal jsoup method, called by the TreeBuilder.
-
Field Details
-
start
-
end
-
RangeKey
-
EndRangeKey
-
UntrackedPos
-
Untracked
-
-
Constructor Details
-
Range
Creates a new Range with start and end Positions. Called by TreeBuilder when position tracking is on.- Parameters:
start
- the start positionend
- the end position
-
-
Method Details
-
start
Get the start position of this node.- Returns:
- the start position
-
end
Get the end position of this node.- Returns:
- the end position
-
isTracked
public boolean isTracked()Test if this source range was tracked during parsing.- Returns:
- true if this was tracked during parsing, false otherwise (and all fields will be
-1
).
-
of
Retrieves the source range for a given Node.- Parameters:
node
- the node to retrieve the position forstart
- if this is the starting range.false
for Element end tags.- Returns:
- the Range, or the Untracked (-1) position if tracking is disabled.
-
track
Internal jsoup method, called by the TreeBuilder. Tracks a Range for a Node.- Parameters:
node
- the node to associate this position tostart
- if this is the starting range.false
for Element end tags.
-
equals
-
hashCode
public int hashCode() -
toString
Gets a String presentation of this Range, in the formatline,column:pos-line,column:pos
.
-