Package org.jsoup.nodes
Class Range
java.lang.Object
org.jsoup.nodes.Range
A Range tracks the source offsets where a Node starts or ends. Line and column coordinates are derived from the
line map retained during parsing. To track these positions, enable
Parser.setTrackPosition(boolean)
before parsing.- Since:
- 1.15.2
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classA Position describes a source offset and its line and column coordinates. -
Method Summary
Modifier and TypeMethodDescriptionend()Get the end position of this range, with 1-based line and column coordinates.intendPos()Get the ending source offset of this range.booleaninthashCode()booleanChecks if the range represents a node that was implicitly created / closed.booleanTest if this range has source offsets available.start()Get the start position of this range, with 1-based line and column coordinates.intstartPos()Get the starting source offset of this range.toString()Gets a String representation of this Range, in the formatline,column:pos-line,column:pos.
-
Method Details
-
start
Get the start position of this range, with 1-based line and column coordinates.- Returns:
- the start position.
-
startPos
Get the starting source offset of this range.- Returns:
- the 0-based start source offset.
- Since:
- 1.17.1
-
end
Get the end position of this range, with 1-based line and column coordinates.- Returns:
- the end position.
-
endPos
Get the ending source offset of this range.- Returns:
- the 0-based ending source offset.
- Since:
- 1.17.1
-
isTracked
Test if this range has source offsets available.- Returns:
- true if this range has source offsets, 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, bothpelements 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
-
equals
-
hashCode
-
toString
Gets a String representation of this Range, in the formatline,column:pos-line,column:pos.
-