Package org.parboiled.support
Class IndexRange
java.lang.Object
org.parboiled.support.IndexRange
A simple immutable container for a range of indices into an underlying InputBuffer.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IndexRange
final int
The index of the character following the last character of the range.final int
The index of the first character in the range. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
hashCode()
boolean
isEmpty()
Determines whether this range contains no characters.boolean
isFollowedBy
(IndexRange other) Determines whether this range is immediated followed by the given other one.boolean
isPrecededBy
(IndexRange other) Determines whether this range immediated follows the given other one.int
length()
mergedWith
(IndexRange other) Created a new IndexRange that spans all characters between the smallest and the highest index of the two ranges.boolean
overlapsWith
(IndexRange other) Determines whether this range overlaps with the given other one.toString()
boolean
touches
(IndexRange other) Determines whether this range immediated follows or precedes the given other one.
-
Field Details
-
EMPTY
-
start
public final int startThe index of the first character in the range. -
end
public final int endThe index of the character following the last character of the range.
-
-
Constructor Details
-
IndexRange
public IndexRange(int start, int end)
-
-
Method Details
-
isEmpty
public boolean isEmpty()Determines whether this range contains no characters.- Returns:
- true if the end matches the start of the range.
-
length
public int length()- Returns:
- the number of characters covered by this range
-
overlapsWith
Determines whether this range overlaps with the given other one.- Parameters:
other
- the other range- Returns:
- true if there is at least one index that is contained in both ranges
-
isPrecededBy
Determines whether this range immediated follows the given other one.- Parameters:
other
- the other range- Returns:
- true if this range immediated follows the given other one
-
isFollowedBy
Determines whether this range is immediated followed by the given other one.- Parameters:
other
- the other range- Returns:
- true if this range is immediated followed by the given other one
-
touches
Determines whether this range immediated follows or precedes the given other one.- Parameters:
other
- the other range- Returns:
- true if this range immediated follows or precedes the given other one.
-
mergedWith
Created a new IndexRange that spans all characters between the smallest and the highest index of the two ranges.- Parameters:
other
- the other range- Returns:
- a new IndexRange instance
-
equals
-
hashCode
public int hashCode() -
toString
-