public class PatternParser extends org.xml.sax.helpers.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(java.lang.String c)
For testing purposes only.
|
void |
addException(java.lang.String w,
java.util.ArrayList e)
For testing purposes only.
|
void |
addPattern(java.lang.String p,
java.lang.String v)
For testing purposes only.
|
void |
characters(char[] ch,
int start,
int length) |
void |
closeTestOut()
Close test out file.
|
void |
endElement(java.lang.String uri,
java.lang.String local,
java.lang.String raw) |
void |
error(org.xml.sax.SAXParseException ex) |
void |
fatalError(org.xml.sax.SAXParseException ex) |
protected void |
getExternalClasses() |
static void |
main(java.lang.String[] args)
Main entry point when used as an application.
|
void |
parse(java.io.File file)
Parses a hyphenation pattern file.
|
void |
parse(org.xml.sax.InputSource source)
Parses a hyphenation pattern file.
|
void |
parse(java.lang.String filename)
Parses a hyphenation pattern file.
|
void |
setTestOut(java.io.PrintStream testOut)
Set test out stream.
|
void |
startElement(java.lang.String uri,
java.lang.String local,
java.lang.String raw,
org.xml.sax.Attributes attrs) |
void |
warning(org.xml.sax.SAXParseException ex) |
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(java.lang.String filename) throws HyphenationException
filename
- the filenameHyphenationException
- In case of an exception while parsingpublic void parse(java.io.File file) throws HyphenationException
file
- the pattern fileHyphenationException
- In case of an exception while parsingpublic void parse(org.xml.sax.InputSource source) throws HyphenationException
source
- the InputSource for the fileHyphenationException
- In case of an exception while parsingprotected void getExternalClasses() throws org.xml.sax.SAXException
org.xml.sax.SAXException
- if not caughtpublic void startElement(java.lang.String uri, java.lang.String local, java.lang.String raw, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
startElement
in interface org.xml.sax.ContentHandler
startElement
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void endElement(java.lang.String uri, java.lang.String local, java.lang.String raw)
endElement
in interface org.xml.sax.ContentHandler
endElement
in class org.xml.sax.helpers.DefaultHandler
public void characters(char[] ch, int start, int length)
characters
in interface org.xml.sax.ContentHandler
characters
in class org.xml.sax.helpers.DefaultHandler
public void warning(org.xml.sax.SAXParseException ex)
warning
in interface org.xml.sax.ErrorHandler
warning
in class org.xml.sax.helpers.DefaultHandler
public void error(org.xml.sax.SAXParseException ex)
error
in interface org.xml.sax.ErrorHandler
error
in class org.xml.sax.helpers.DefaultHandler
public void fatalError(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException
fatalError
in interface org.xml.sax.ErrorHandler
fatalError
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void addClass(java.lang.String c)
addClass
in interface PatternConsumer
c
- character grouppublic void addException(java.lang.String w, java.util.ArrayList e)
Hyphen
instancesaddException
in interface PatternConsumer
w
- word to add as an exceptione
- pre-hyphenated wordpublic void addPattern(java.lang.String p, java.lang.String v)
addPattern
in interface PatternConsumer
p
- the patternv
- interletter values expressed as a string of
digit characters.public void setTestOut(java.io.PrintStream testOut)
testOut
- the testOut to setpublic void closeTestOut()
public static void main(java.lang.String[] args) throws java.lang.Exception
args
- array of command line argumentsjava.lang.Exception
- in case of uncaught exceptionCopyright 1999-2017 The Apache Software Foundation. All Rights Reserved.