public class CharClasses
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static char |
maxChar
the largest character that can be used in char classes
|
Constructor and Description |
---|
CharClasses(int maxCharCode)
Constructs a new CharClass object that provides space for
classes of characters from 0 to maxCharCode.
|
Modifier and Type | Method and Description |
---|---|
void |
check()
Check consistency of the stored classes [debug].
|
void |
dump()
Dump charclasses to the dump output stream
|
int |
getClassCode(char letter)
Returns the code of the character class the specified character belongs to.
|
int[] |
getClassCodes(java.util.Vector intervallVec)
Returns an array that contains the character class codes of all characters
in the specified set of input characters.
|
CharClassInterval[] |
getIntervals()
Returns an array of all CharClassIntervalls in this
char class collection.
|
char |
getMaxCharCode()
Returns the greatest Unicode value of the current input character set.
|
int[] |
getNotClassCodes(java.util.Vector intervallVec)
Returns an array that contains the character class codes of all characters
that are not in the specified set of input characters.
|
int |
getNumClasses()
Returns the current number of character classes.
|
void |
makeClass(char singleChar,
boolean caseless)
Creates a new character class for the single character
singleChar . |
void |
makeClass(IntCharSet set,
boolean caseless)
Updates the current partition, so that the specified set of characters
gets a new character class.
|
void |
makeClass(java.lang.String str,
boolean caseless)
Creates a new character class for each character of the specified String.
|
void |
makeClass(java.util.Vector v,
boolean caseless)
Updates the current partition, so that the specified set of characters
gets a new character class.
|
void |
makeClassNot(java.util.Vector v,
boolean caseless)
Updates the current partition, so that the set of all characters not contained in the specified
set of characters gets a new character class.
|
void |
setMaxCharCode(int charCode)
Sets the largest Unicode value of the current input character set.
|
java.lang.String |
toString()
Return a string representation of the char classes
stored in this class.
|
java.lang.String |
toString(int theClass)
Return a string representation of one char class
|
public static final char maxChar
public CharClasses(int maxCharCode)
maxCharCode
- the last character code to be
considered. (127 for 7bit Lexers,
255 for 8bit Lexers and 0xFFFF
for Unicode Lexers).public char getMaxCharCode()
public void setMaxCharCode(int charCode)
charCode
- the largest character code, used for the scanner
(i.e. %7bit, %8bit, %16bit etc.)public int getNumClasses()
public void makeClass(IntCharSet set, boolean caseless)
set
are not in the same
equivalence class with characters that are not elements of set
.set
- the set of characters to distinguish from the restcaseless
- if true upper/lower/title case are considered equivalentpublic int getClassCode(char letter)
public void dump()
public java.lang.String toString(int theClass)
theClass
- the index of the class topublic java.lang.String toString()
toString
in class java.lang.Object
public void makeClass(char singleChar, boolean caseless)
singleChar
.caseless
- if true upper/lower/title case are considered equivalentpublic void makeClass(java.lang.String str, boolean caseless)
caseless
- if true upper/lower/title case are considered equivalentpublic void makeClass(java.util.Vector v, boolean caseless)
v
are not in the same
equivalence class with characters that are not elements of the set v
.v
- a Vector of Interval objects.
This Vector represents a set of characters. The set of characters is
the union of all intervals in the Vector.caseless
- if true upper/lower/title case are considered equivalentpublic void makeClassNot(java.util.Vector v, boolean caseless)
v
are not in the same
equivalence class with characters that are not elements of the set v
.
This method is equivalent to makeClass(v)
v
- a Vector of Interval objects.
This Vector represents a set of characters. The set of characters is
the union of all intervals in the Vector.caseless
- if true upper/lower/title case are considered equivalentpublic int[] getClassCodes(java.util.Vector intervallVec)
intervallVec
- a Vector of Intervals, the set of characters to get
the class codes forpublic int[] getNotClassCodes(java.util.Vector intervallVec)
intervallVec
- a Vector of Intervals, the complement of the
set of characters to get the class codes forpublic void check()
public CharClassInterval[] getIntervals()
result[i+1].start = result[i].end+1
Each CharClassInterval contains the number of the
char class it belongs to.