|
public final class CharRange implements java.io.Serializable A contiguous range of characters, optionally negated. Instances are immutable. Constructor Detailpublic CharRange(char ch) Constructs a CharRange over a single character. Parameters: chonly character in this range public CharRange(char ch, boolean negated) Constructs a CharRange over a single character, optionally negating the range. A negated range includes everything except the specified char. Parameters: chonly character in this range negatedtrue to express everything except the range public CharRange(char start, char end) Constructs a CharRange over a set of characters. Parameters: startfirst character, inclusive, in this range endlast character, inclusive, in this range public CharRange(char start, char end, boolean negated) 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: startfirst character, inclusive, in this range endlast character, inclusive, in this range negatedtrue to express everything except the range Method Detailpublic char getStart() Gets the start character for this character range. Returns: the start char (inclusive) public char getEnd() Gets the end character for this character range. Returns: the end char (inclusive) public boolean isNegated() Is this CharRange negated. A negated range includes everything except that defined by the start and end characters. Returns: true is negated public boolean contains(char ch) Is the character specified contained in this range. Parameters: chthe character to check Returns: true if this range contains the input character public boolean contains(CharRange range) Are all the characters of the passed in range contained in this range. Parameters: rangethe range to check against Returns: true if this range entirely contains the input range Throws: java.lang.IllegalArgumentExceptionif null input public boolean equals(java.lang.Object obj) Compares two CharRange objects, returning true if they represent exactly the same range of characters defined in the same way. Parameters: objthe object to compare to Returns: true if equal public int hashCode() Gets a hashCode compatable with the equals method. Returns: a suitable hashCode public java.lang.String toString() Gets a string representation of the character range. Returns: string representation of this range |
|