public final class NormalizationChecker extends java.lang.Object implements CharacterHandler
| Modifier and Type | Field and Description |
|---|---|
private boolean |
alreadyComplainedAboutThisRun
Indicates whether the current run has already caused an error.
|
private boolean |
atStartOfRun
Indicates whether the checker the next call to
characters()
is the first call in a run. |
private char[] |
buf
A buffer for holding sequences overlap the SAX buffer boundary.
|
private char[] |
bufHolder
A holder for the original buffer (for the memory leak prevention
mechanism).
|
private static com.ibm.icu.text.UnicodeSet |
COMPOSING_CHARACTERS
A thread-safe set of composing characters as per Charmod Norm.
|
private org.xml.sax.ErrorHandler |
errorHandler |
private org.xml.sax.Locator |
locator |
private int |
pos
The current used length of the buffer, i.e.
|
| Constructor and Description |
|---|
NormalizationChecker(org.xml.sax.Locator locator)
Constructor with mode selection.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
appendToBuf(char[] ch,
int start,
int end)
Appends a slice of an UTF-16 code unit array to the internal
buffer.
|
void |
characters(char[] ch,
int start,
int length)
Receive notification of a run of UTF-16 code units.
|
void |
end()
Signals the end of the stream.
|
void |
err(java.lang.String message)
Emit an error.
|
private void |
errAboutTextRun()
Emits an error stating that the current text run or the source
text is not in NFC.
|
private static boolean |
isComposingChar(int c)
Returns
true if the argument is a composing character
and false otherwise. |
private static boolean |
isComposingCharOrSurrogate(char c)
Returns
true if the argument is a composing BMP character
or a surrogate and false otherwise. |
void |
setErrorHandler(org.xml.sax.ErrorHandler errorHandler) |
void |
start()
Signals the start of the stream.
|
private org.xml.sax.ErrorHandler errorHandler
private org.xml.sax.Locator locator
private static final com.ibm.icu.text.UnicodeSet COMPOSING_CHARACTERS
private char[] buf
private char[] bufHolder
private int pos
private boolean atStartOfRun
characters()
is the first call in a run.private boolean alreadyComplainedAboutThisRun
public NormalizationChecker(org.xml.sax.Locator locator)
sourceTextMode - whether the source text-related messages
should be enabled.public void err(java.lang.String message)
throws org.xml.sax.SAXException
message - the error messageorg.xml.sax.SAXException - if something goes wrongprivate static boolean isComposingCharOrSurrogate(char c)
true if the argument is a composing BMP character
or a surrogate and false otherwise.c - a UTF-16 code unittrue if the argument is a composing BMP character
or a surrogate and false otherwiseprivate static boolean isComposingChar(int c)
true if the argument is a composing character
and false otherwise.c - a Unicode code pointtrue if the argument is a composing character
false otherwisepublic void start()
CharacterHandlerstart in interface CharacterHandlerCharacterHandler.start()public void characters(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
CharacterHandlercharacters in interface CharacterHandlerch - the bufferstart - start index in the bufferlength - the number of characters to process starting from startorg.xml.sax.SAXException - if things go wrongCharacterHandler.characters(char[], int, int)private void errAboutTextRun()
throws org.xml.sax.SAXException
org.xml.sax.SAXException - if the ErrorHandler throwsprivate void appendToBuf(char[] ch,
int start,
int end)
ch - the array from which to copystart - the index of the first element that is copiedend - the index of the first element that is not copiedpublic void end()
throws org.xml.sax.SAXException
CharacterHandlerend in interface CharacterHandlerorg.xml.sax.SAXException - if things go wrongCharacterHandler.end()public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)