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
public class PatternParser extends DefaultHandler implements PatternConsumer
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).
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addClass(String c)
For testing purposes only.void
addException(String w, List e)
For testing purposes only.void
addPattern(String p, String v)
For testing purposes only.void
characters(char[] ch, int start, int length)
void
endElement(String uri, String local, String raw)
void
error(SAXParseException ex)
void
fatalError(SAXParseException ex)
static void
main(String[] args)
Main entry point when used as an application.void
parse(InputSource source)
Parses a hyphenation pattern file.void
startElement(String uri, String local, String raw, Attributes attrs)
void
warning(SAXParseException ex)
-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
-
-
-
-
Method Detail
-
parse
public void parse(InputSource source) throws HyphenationException
Parses a hyphenation pattern file.- Parameters:
source
- the InputSource for the file- Throws:
HyphenationException
- In case of an exception while parsing
-
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
public void endElement(String uri, String local, String raw)
- 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
public void warning(SAXParseException ex)
- Specified by:
warning
in interfaceErrorHandler
- Overrides:
warning
in classDefaultHandler
-
error
public void error(SAXParseException ex)
- Specified by:
error
in interfaceErrorHandler
- Overrides:
error
in classDefaultHandler
-
fatalError
public void fatalError(SAXParseException ex) throws SAXException
- Specified by:
fatalError
in interfaceErrorHandler
- Overrides:
fatalError
in classDefaultHandler
- Throws:
SAXException
-
addClass
public void addClass(String c)
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
public void addException(String w, List e)
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
public void addPattern(String p, String v)
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.
-
-