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
Modifier and TypeClassDescriptionstatic class
static class
A Position object tracks the character position in the original input source where a Node starts or ends. -
Constructor Summary
ConstructorDescriptionRange
(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.int
endPos()
Get the ending cursor position of this range.boolean
int
hashCode()
boolean
Checks if the range represents a node that was implicitly created / closed.boolean
Test if this source range was tracked during parsing.start()
Get the start position of this node.int
startPos()
Get the starting cursor position of this range.toString()
Gets a String presentation of this Range, in the formatline,column:pos-line,column:pos
.void
Deprecated.no-op; internal method moved out of visibility
-
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
-
startPos
Get the starting cursor position of this range.- Returns:
- the 0-based start cursor position.
- Since:
- 1.17.1
-
end
Get the end position of this node.- Returns:
- the end position
-
endPos
Get the ending cursor position of this range.- Returns:
- the 0-based ending cursor position.
- Since:
- 1.17.1
-
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
).
-
isImplicit
Checks if the range represents a node that was implicitly created / closed.For example, with HTML of
<p>One<p>Two
, bothp
elements will have an explicitNode.sourceRange()
but an implicitElement.endSourceRange()
marking the end position, as neither have closing</p>
tags. The TextNodes will have explicit sourceRanges.A range is considered implicit if its start and end positions are the same.
- Returns:
- true if the range is tracked and its start and end positions are the same, false otherwise.
- Since:
- 1.17.1
-
track
Deprecated.no-op; internal method moved out of visibility -
equals
-
hashCode
-
toString
Gets a String presentation of this Range, in the formatline,column:pos-line,column:pos
.
-