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
ConstructorsConstructorDescriptionConstruct a pattern parser.PatternParser(PatternConsumer consumer) Construct a pattern parser. -
Method Summary
Modifier and TypeMethodDescriptionvoidFor testing purposes only.voidaddException(String w, ArrayList e) For testing purposes only.voidaddPattern(String p, String v) For testing purposes only.voidcharacters(char[] ch, int start, int length) voidClose test out file.voidendElement(String uri, String local, String raw) voidvoidprotected voidstatic voidMain entry point when used as an application.voidParses a hyphenation pattern file.voidParses a hyphenation pattern file.voidparse(InputSource source) Parses a hyphenation pattern file.voidsetTestOut(PrintStream testOut) Set test out stream.voidstartElement(String uri, String local, String raw, Attributes attrs) voidMethods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDeclMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Throws:
SAXException
-
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
-
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:
addClassin 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 andHypheninstances- Specified by:
addExceptionin interfacePatternConsumer- Parameters:
w- word to add as an exceptione- pre-hyphenated word
-
addPattern
For testing purposes only. Add hyphenation patterns.- Specified by:
addPatternin 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
-