public class CharacterSet
extends java.lang.Object
Ranges can be constructed from a literal string, from a range of Unicode codepoints, or via Unicode character classes.
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Tests for the equality of two
CharacterSet objects. |
java.lang.String |
getCharacters()
What characters are in the set?
|
int |
getRangeFrom()
Where does the range begin?
|
int |
getRangeTo()
Where does the range end?
|
java.lang.String |
getUnicodeCharacterClass()
What is the Unicode character class?
|
boolean |
isRange()
Does this character set represent a range of Unicode code points?
|
boolean |
isSetOfCharacters()
Does this character set represent a specific set of characters?
|
boolean |
isUnicodeCharacterClass()
Does this character set represent a Unicode character class?
|
static CharacterSet |
literal(java.lang.String literal)
Construct a character set containing each of the characters in the literal string.
|
boolean |
matches(int codepoint)
Test if a code point occurs in the set.
|
static CharacterSet |
range(int first,
int last)
Construct a character set containing each of the characters in the specified range, inclusive.
|
java.lang.String |
toString() |
static CharacterSet |
unicodeClass(java.lang.String charClass)
Construct a character set representing the specified Unicode character class.
|
public boolean isRange()
public int getRangeFrom()
Ranges are inclusive. There result of this method is undefined if isRange()
returns false.
public int getRangeTo()
Ranges are inclusive. There result of this method is undefined if isRange()
returns false.
public boolean isSetOfCharacters()
public java.lang.String getCharacters()
If this character set represents a set of characters, this method returns them as a string. Otherwise, it returns null.
public boolean isUnicodeCharacterClass()
public java.lang.String getUnicodeCharacterClass()
Returns the one or two character string that defines the character class. Returns null if this character set does not represent a Unicode character class.
public static CharacterSet literal(java.lang.String literal)
literal
- The string of characters.java.lang.NullPointerException
- if the literal is null.java.lang.IllegalArgumentException
- if the literal is the empty string.public static CharacterSet range(int first, int last)
first
- The first codepoint.last
- The last codepoint.java.lang.IllegalArgumentException
- if the range is invalid.public static CharacterSet unicodeClass(java.lang.String charClass)
charClass
- The character class, for example "L", or "Nd".java.lang.NullPointerException
- if the charClass is null.java.lang.IllegalArgumentException
- if the charClass is less than 1 or more than 2 characters long.public boolean equals(java.lang.Object obj)
CharacterSet
objects.
Two CharacterSet
objects are equal only if they identify the same characters
expressed in the same way. A set created from the literal "0123456789" is not equal to
a set created from the range '0' to '9'.
equals
in class java.lang.Object
obj
- A CharacterSet to test for equality against.public boolean matches(int codepoint)
codepoint
- The Unicode codepoint to test.public java.lang.String toString()
toString
in class java.lang.Object