Package com.itextpdf.layout.hyphenation
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 IPatternConsumer
private int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
private String
private ArrayList
private boolean
private char
private XMLReader
private StringBuilder
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Construct a pattern parser.PatternParser
(IPatternConsumer consumer) Construct a pattern parser. -
Method Summary
Modifier and TypeMethodDescriptionvoid
characters
(char[] ch, int start, int length) (package private) static XMLReader
Creates a SAX parser using JAXPvoid
endElement
(String uri, String local, String raw) void
void
private String
protected void
private static String
private String
Returns a string of the location.private static String
getPattern
(String word) private ArrayList
void
parse
(InputStream stream, String name) Parses a hyphenation pattern file.void
Parses a hyphenation pattern file.private String
readToken
(StringBuilder chars) void
startElement
(String uri, String local, String raw, Attributes attrs) void
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.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 found
-
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
Creates a SAX parser using JAXP- Returns:
- the created SAX parser
-
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:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
- if parsing of hyphenation classes resource xml has failed.
-
endElement
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
-
characters
public void characters(char[] ch, int start, int length) - Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
-
warning
- Specified by:
warning
in interfaceErrorHandler
- Overrides:
warning
in classDefaultHandler
-
error
- Specified by:
error
in interfaceErrorHandler
- Overrides:
error
in classDefaultHandler
-
fatalError
- Specified by:
fatalError
in interfaceErrorHandler
- Overrides:
fatalError
in classDefaultHandler
- Throws:
SAXException
-
getLocationString
Returns a string of the location.
-