public class CharClasses extends 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()
Dump charclasses to the dump output stream
|
int |
getClassCode(int codePoint)
Returns the code of the character class the specified character belongs to.
|
int[] |
getClassCodes(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(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(List<Interval> l,
boolean caseless)
Updates the current partition, so that the specified set of characters
gets a new character class.
|
void |
makeClass(String str,
boolean caseless)
Creates a new character class for each character of the specified String.
|
void |
makeClassNot(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.
|
String |
toString()
Return a string representation of the char classes
stored in this class.
|
String |
toString(int theClass)
Return a string representation of one char class
|
public static final int maxChar
public LexScan scanner
public CharClasses()
public void init(int maxCharCode, LexScan scanner)
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)
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)
public void dump()
public String toString(int theClass)
theClass
- the index of the class topublic String toString()
public void makeClass(int singleChar, boolean caseless)
singleChar
.caseless
- if true upper/lower/title case are considered equivalentpublic void makeClass(String str, boolean caseless)
caseless
- if true upper/lower/title case are considered equivalentpublic void makeClass(List<Interval> l, boolean caseless)
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(List<Interval> l, 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)
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(List<Interval> intervalList)
intervalList
- a List of Intervals, the set of characters to get
the class codes forpublic int[] getNotClassCodes(List<Interval> intervalList)
intervalList
- a List 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.Copyright © 1998–2016. All rights reserved.