org.apache.commons.lang
public final class CharRange extends Object implements Serializable
A contiguous range of characters, optionally negated.
Instances are immutable.
Since: 1.0
Version: $Id: CharRange.java 471626 2006-11-06 04:02:09Z bayard $
Constructor Summary | |
---|---|
CharRange(char ch) Constructs a | |
CharRange(char ch, boolean negated) Constructs a A negated range includes everything except the specified char. | |
CharRange(char start, char end) Constructs a | |
CharRange(char start, char end, boolean negated) Constructs a A negated range includes everything except that defined by the start and end characters. If start and end are in the wrong order, they are reversed. |
Method Summary | |
---|---|
boolean | contains(char ch) Is the character specified contained in this range. |
boolean | contains(CharRange range) Are all the characters of the passed in range contained in this range. |
boolean | equals(Object obj) Compares two CharRange objects, returning true if they represent exactly the same range of characters defined in the same way. |
char | getEnd() Gets the end character for this character range. |
char | getStart() Gets the start character for this character range. |
int | hashCode() Gets a hashCode compatible with the equals method. |
boolean | isNegated() Is this A negated range includes everything except that defined by the start and end characters. |
String | toString() Gets a string representation of the character range. |
Constructs a CharRange
over a single character.
Parameters: ch only character in this range
Constructs a CharRange
over a single character,
optionally negating the range.
A negated range includes everything except the specified char.
Parameters: ch only character in this range negated true to express everything except the range
Constructs a CharRange
over a set of characters.
Parameters: start first character, inclusive, in this range end last character, inclusive, in this range
Constructs a CharRange
over a set of characters,
optionally negating the range.
A negated range includes everything except that defined by the start and end characters.
If start and end are in the wrong order, they are reversed.
Thus a-e
is the same as e-a
.
Parameters: start first character, inclusive, in this range end last character, inclusive, in this range negated true to express everything except the range
Is the character specified contained in this range.
Parameters: ch the character to check
Returns: true
if this range contains the input character
Are all the characters of the passed in range contained in this range.
Parameters: range the range to check against
Returns: true
if this range entirely contains the input range
Throws: IllegalArgumentException if null
input
Compares two CharRange objects, returning true if they represent exactly the same range of characters defined in the same way.
Parameters: obj the object to compare to
Returns: true if equal
Gets the end character for this character range.
Returns: the end char (inclusive)
Gets the start character for this character range.
Returns: the start char (inclusive)
Gets a hashCode compatible with the equals method.
Returns: a suitable hashCode
Is this CharRange
negated.
A negated range includes everything except that defined by the start and end characters.
Returns: true
is negated
Gets a string representation of the character range.
Returns: string representation of this range