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).
Constructor and Description |
---|
PatternParser()
Construct a pattern parser.
|
PatternParser(PatternConsumer consumer)
Construct a pattern parser.
|
Modifier and Type | Method and Description |
---|---|
void |
addClass(String c)
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 |
closeTestOut()
Close test out file.
|
void |
endElement(String uri,
String local,
String raw) |
void |
error(SAXParseException ex) |
void |
fatalError(SAXParseException ex) |
protected void |
getExternalClasses() |
static void |
main(String[] args)
Main entry point when used as an application.
|
void |
parse(File file)
Parses a hyphenation pattern file.
|
void |
parse(InputSource source)
Parses a hyphenation pattern file.
|
void |
parse(String filename)
Parses a hyphenation pattern file.
|
void |
setTestOut(PrintStream testOut)
Set test out stream.
|
void |
startElement(String uri,
String local,
String raw,
Attributes attrs) |
void |
warning(SAXParseException ex) |
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
public PatternParser() throws HyphenationException
HyphenationException
- if a hyphenation exception is raisedpublic PatternParser(PatternConsumer consumer) throws HyphenationException
consumer
- a pattern consumerHyphenationException
- if a hyphenation exception is raisedpublic void parse(String filename) throws HyphenationException
filename
- the filenameHyphenationException
- In case of an exception while parsingpublic void parse(File file) throws HyphenationException
file
- the pattern fileHyphenationException
- In case of an exception while parsingpublic void parse(InputSource source) throws HyphenationException
source
- the InputSource for the fileHyphenationException
- In case of an exception while parsingprotected void getExternalClasses() throws SAXException
SAXException
- if not caughtpublic void startElement(String uri, String local, String raw, Attributes attrs) throws SAXException
startElement
in interface ContentHandler
startElement
in class DefaultHandler
SAXException
public void endElement(String uri, String local, String raw)
endElement
in interface ContentHandler
endElement
in class DefaultHandler
public void characters(char[] ch, int start, int length)
characters
in interface ContentHandler
characters
in class DefaultHandler
public void warning(SAXParseException ex)
warning
in interface ErrorHandler
warning
in class DefaultHandler
public void error(SAXParseException ex)
error
in interface ErrorHandler
error
in class DefaultHandler
public void fatalError(SAXParseException ex) throws SAXException
fatalError
in interface ErrorHandler
fatalError
in class DefaultHandler
SAXException
public void addClass(String c)
addClass
in interface PatternConsumer
c
- character grouppublic void addException(String w, ArrayList e)
Hyphen
instancesaddException
in interface PatternConsumer
w
- word to add as an exceptione
- pre-hyphenated wordpublic void addPattern(String p, String v)
addPattern
in interface PatternConsumer
p
- the patternv
- interletter values expressed as a string of
digit characters.public void setTestOut(PrintStream testOut)
testOut
- the testOut to setpublic void closeTestOut()
Copyright © 2025 Apache Software Foundation. All rights reserved.