|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.whattf.checker.Checker
org.whattf.checker.NormalizationChecker
public final class NormalizationChecker
Checks that the following constructs do not start with a composing character:
Checks that the following constructs are in the Unicode Normalization Form C. (It is assumed the normalization of the rest of the constructs is enforced by other means, such as checking the document source for normalization.)
All Strings must be valid UTF-16!
This class can also be used as a source code mode where the source
code of the document is fed to characters(). The mode
modifies the error messages appropriately.
| Field Summary | |
|---|---|
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 int |
pos
The current used length of the buffer, i.e. |
private boolean |
sourceTextMode
Indicates whether error messages related to source code checking should be used. |
| Constructor Summary | |
|---|---|
NormalizationChecker()
Constructor for non-source mode. |
|
NormalizationChecker(boolean sourceTextMode)
Constructor with mode selection. |
|
| Method Summary | |
|---|---|
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)
In the normal mode, this method has the usual SAX semantics. |
void |
endElement(String uri,
String localName,
String qName)
|
private void |
errAboutTextRun()
Emits an error stating that the current text run or the source text is not in NFC. |
void |
flush()
Called to indicate the end of a run of characters. |
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 |
processingInstruction(String target,
String data)
|
void |
reset()
Does nothing. |
void |
startElement(String uri,
String localName,
String qName,
Attributes atts)
|
void |
startPrefixMapping(String prefix,
String uri)
|
static boolean |
startsWithComposingChar(String str)
Returns true if the argument starts with a composing
character and false otherwise. |
| Methods inherited from class org.whattf.checker.Checker |
|---|
endDocument, endPrefixMapping, err, err, getDocumentLocator, getErrorHandler, ignorableWhitespace, setDocumentLocator, setErrorHandler, skippedEntity, startDocument, warn, warn |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
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
private final boolean sourceTextMode
| Constructor Detail |
|---|
public NormalizationChecker()
public NormalizationChecker(boolean sourceTextMode)
sourceTextMode - whether the source text-related messages
should be enabled.| Method Detail |
|---|
private 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 unit
true 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 point
true if the argument is a composing character
false otherwise
public static boolean startsWithComposingChar(String str)
throws SAXException
true if the argument starts with a composing
character and false otherwise.
str - a string
true if the argument starts with a composing
character and false otherwise.
SAXException - on malformed UTF-16public void reset()
Checker
reset in class CheckerChecker.reset()
public void characters(char[] ch,
int start,
int length)
throws SAXException
characters in interface ContentHandlercharacters in class CheckerSAXExceptionChecker.characters(char[], int, int)
private void errAboutTextRun()
throws SAXException
SAXException - if the ErrorHandler throws
private 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 copied
public void endElement(String uri,
String localName,
String qName)
throws SAXException
endElement in interface ContentHandlerendElement in class CheckerSAXExceptionChecker.endElement(java.lang.String,
java.lang.String, java.lang.String)
public void processingInstruction(String target,
String data)
throws SAXException
processingInstruction in interface ContentHandlerprocessingInstruction in class CheckerSAXExceptionChecker.processingInstruction(java.lang.String,
java.lang.String)
public void startElement(String uri,
String localName,
String qName,
Attributes atts)
throws SAXException
startElement in interface ContentHandlerstartElement in class CheckerSAXExceptionChecker.startElement(java.lang.String,
java.lang.String, java.lang.String, org.xml.sax.Attributes)
public void startPrefixMapping(String prefix,
String uri)
throws SAXException
startPrefixMapping in interface ContentHandlerstartPrefixMapping in class CheckerSAXExceptionChecker.startPrefixMapping(java.lang.String, java.lang.String)
public void flush()
throws SAXException
characters().
SAXException - if the ErrorHandler throws.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||