Package org.apache.fop.hyphenation
Class PatternParser
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.apache.fop.hyphenation.PatternParser
- All Implemented Interfaces:
PatternConsumer
,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).
-
Constructor Summary
ConstructorDescriptionConstruct a pattern parser.PatternParser
(PatternConsumer consumer) Construct a pattern parser. -
Method Summary
Modifier and TypeMethodDescriptionvoid
For testing purposes only.void
addException
(String w, ArrayList e) For testing purposes only.void
addPattern
(String p, String v) For testing purposes only.void
characters
(char[] ch, int start, int length) void
Close test out file.void
endElement
(String uri, String local, String raw) void
void
protected void
static void
Main entry point when used as an application.void
Parses a hyphenation pattern file.void
Parses a hyphenation pattern file.void
parse
(InputSource source) Parses a hyphenation pattern file.void
setTestOut
(PrintStream testOut) Set test out stream.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
-
Constructor Details
-
PatternParser
Construct a pattern parser.- Throws:
HyphenationException
- if a hyphenation exception is raised
-
PatternParser
Construct a pattern parser.- Parameters:
consumer
- a pattern consumer- Throws:
HyphenationException
- if a hyphenation exception is raised
-
-
Method Details
-
parse
Parses a hyphenation pattern file.- Parameters:
filename
- the filename- Throws:
HyphenationException
- In case of an exception while parsing
-
parse
Parses a hyphenation pattern file.- Parameters:
file
- the pattern file- Throws:
HyphenationException
- In case of an exception while parsing
-
parse
Parses a hyphenation pattern file.- Parameters:
source
- the InputSource for the file- Throws:
HyphenationException
- In case of an exception while parsing
-
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
-
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
-
addClass
For testing purposes only. Add a character class. A character class defines characters that are considered equivalent for the purpose of hyphenation (e.g. "aA"). It usually means to ignore case.- Specified by:
addClass
in interfacePatternConsumer
- Parameters:
c
- character group
-
addException
For testing purposes only. Add a hyphenation exception. An exception replaces the result obtained by the algorithm for cases for which this fails or the user wants to provide his own hyphenation. A hyphenatedword is a vector of alternating String's andHyphen
instances- Specified by:
addException
in interfacePatternConsumer
- Parameters:
w
- word to add as an exceptione
- pre-hyphenated word
-
addPattern
For testing purposes only. Add hyphenation patterns.- Specified by:
addPattern
in interfacePatternConsumer
- Parameters:
p
- the patternv
- interletter values expressed as a string of digit characters.
-
setTestOut
Set test out stream.- Parameters:
testOut
- the testOut to set
-
closeTestOut
public void closeTestOut()Close test out file. -
main
Main entry point when used as an application.- Parameters:
args
- array of command line arguments- Throws:
Exception
- in case of uncaught exception
-