Class PatternParser
java.lang.Object
org.xml.sax.helpers.DefaultHandler
com.itextpdf.layout.hyphenation.PatternParser
- All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler
A SAX document handler to read and parse hyphenation patterns
from a XML file.
This work was authored by Carlos Villegas (cav@uniscope.co.jp).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate IPatternConsumerprivate int(package private) static final int(package private) static final int(package private) static final int(package private) static final intprivate Stringprivate ArrayListprivate booleanprivate charprivate XMLReaderprivate StringBuilder -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateConstruct a pattern parser.PatternParser(IPatternConsumer consumer) Construct a pattern parser. -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(char[] ch, int start, int length) (package private) static XMLReaderCreates a SAX parser using JAXPvoidendElement(String uri, String local, String raw) voidvoidprivate Stringprotected voidprivate static Stringprivate StringReturns a string of the location.private static StringgetPattern(String word) private ArrayListvoidparse(InputStream stream, String name) Parses a hyphenation pattern file.voidParses a hyphenation pattern file.private StringreadToken(StringBuilder chars) voidstartElement(String uri, String local, String raw, Attributes attrs) voidMethods inherited from class DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDeclMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContentHandler
declaration
-
Field Details
-
parser
-
currElement
private int currElement -
consumer
-
token
-
exception
-
hyphenChar
private char hyphenChar -
errMsg
-
hasClasses
private boolean hasClasses -
ELEM_CLASSES
static final int ELEM_CLASSES- See Also:
-
ELEM_EXCEPTIONS
static final int ELEM_EXCEPTIONS- See Also:
-
ELEM_PATTERNS
static final int ELEM_PATTERNS- See Also:
-
ELEM_HYPHEN
static final int ELEM_HYPHEN- See Also:
-
-
Constructor Details
-
PatternParser
private PatternParser()Construct a pattern parser. -
PatternParser
Construct a pattern parser.- Parameters:
consumer- a pattern consumer
-
-
Method Details
-
parse
Parses a hyphenation pattern file.- Parameters:
filename- the filename- Throws:
HyphenationException- In case of an exception while parsingFileNotFoundException- If the specified file is not foundIOException
-
parse
Parses a hyphenation pattern file.- Parameters:
stream- the InputStream for the filename- unique key representing country-language combination- Throws:
HyphenationException- In case of an exception while parsing
-
createParser
-
readToken
-
getPattern
-
normalizeException
-
getExceptionWord
-
getInterletterValues
-
getExternalClasses
- Throws:
SAXException- if not caught
-
startElement
public void startElement(String uri, String local, String raw, Attributes attrs) throws SAXException - Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Throws:
SAXException- if parsing of hyphenation classes resource xml has failed.
-
endElement
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler
-
characters
public void characters(char[] ch, int start, int length) - Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler
-
warning
- Specified by:
warningin interfaceErrorHandler- Overrides:
warningin classDefaultHandler
-
error
- Specified by:
errorin interfaceErrorHandler- Overrides:
errorin classDefaultHandler
-
fatalError
- Specified by:
fatalErrorin interfaceErrorHandler- Overrides:
fatalErrorin classDefaultHandler- Throws:
SAXException
-
getLocationString
Returns a string of the location.
-