public class CharClasses
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
maxChar
the largest character that can be used in char classes
|
LexScan |
scanner |
Constructor and Description |
---|
CharClasses()
Constructs a new CharClasses object.
|
Modifier and Type | Method and Description |
---|---|
void |
check()
Check consistency of the stored classes [debug].
|
void |
dump()
Dumps charclasses to the dump output stream.
|
int |
getClassCode(int codePoint)
Returns the code of the character class the specified character belongs to.
|
int[] |
getClassCodes(java.util.List<Interval> intervalList)
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 CharClassIntervals in this char class collection.
|
int |
getMaxCharCode()
Returns the greatest Unicode value of the current input character set.
|
int[] |
getNotClassCodes(java.util.List<Interval> intervalList)
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 |
init(int maxCharCode,
LexScan scanner)
Provides space for classes of characters from 0 to maxCharCode.
|
void |
makeClass(int 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.util.List<Interval> l,
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 |
makeClassNot(java.util.List<Interval> l,
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 maxCharCode)
Sets the largest Unicode value of the current input character set.
|
java.lang.String |
toString()
Returns a string representation of the char classes stored in this class.
|
java.lang.String |
toString(int theClass)
Returns a string representation of one char class
|
public static final int maxChar
public LexScan scanner
public CharClasses()
CharClasses.init() is delayed until UnicodeProperties.init() has been called, since the max char code won't be known until then.
public void init(int maxCharCode, LexScan scanner)
Initially all characters are in class 0.
maxCharCode
- the last character code to be considered. (127 for 7bit Lexers, 255 for 8bit
Lexers and UnicodeProperties.getMaximumCodePoint() for Unicode Lexers).scanner
- the scanner containing the UnicodeProperties instance from which caseless
partitions are obtained.public int getMaxCharCode()
public void setMaxCharCode(int maxCharCode)
maxCharCode
- the largest character code, used for the scanner (i.e. %7bit, %8bit, %16bit
etc.)public int getNumClasses()
public void makeClass(IntCharSet set, boolean caseless)
Characters that are elements of 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(int codePoint)
codePoint
- code point.public void dump()
public java.lang.String toString(int theClass)
theClass
- the index of the class toString
object.public java.lang.String toString()
Enumerates the classes by index.
toString
in class java.lang.Object
public void makeClass(int singleChar, boolean caseless)
singleChar
.caseless
- if true upper/lower/title case are considered equivalentsingleChar
- character.public void makeClass(java.lang.String str, boolean caseless)
caseless
- if true upper/lower/title case are considered equivalentstr
- set of characters.public void makeClass(java.util.List<Interval> l, boolean caseless)
Characters that are elements of the set l
are not in the same equivalence class
with characters that are not elements of the set l
.
l
- a List of Interval objects. This List represents a set of characters. The set of
characters is the union of all intervals in the List.caseless
- if true upper/lower/title case are considered equivalentpublic void makeClassNot(java.util.List<Interval> l, boolean caseless)
Characters that are elements of the set 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)
l
- a List of Interval objects. This List represents a set of characters. The set of
characters is the union of all intervals in the List.caseless
- if true upper/lower/title case are considered equivalentpublic int[] getClassCodes(java.util.List<Interval> intervalList)
intervalList
- a List of Intervals, the set of characters to get the class codes forpublic int[] getNotClassCodes(java.util.List<Interval> intervalList)
intervalList
- a List of Intervals, the complement of the set of characters to get the
class codes forpublic void check()
all classes must be disjoint, checks if all characters have a class assigned.
public CharClassInterval[] getIntervals()
The array is ordered by char code, i.e. result[i+1].start = result[i].end+1
Each CharClassInterval contains the number of the char class it belongs to.
CharClassInterval
in this char class collection.Copyright © 1998–2019. All rights reserved.