Package org.apache.fop.hyphenation
Class PatternParser
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.apache.fop.hyphenation.PatternParser
-
- All Implemented Interfaces:
PatternConsumer,org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.EntityResolver,org.xml.sax.ErrorHandler
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 Summary
Constructors Constructor Description PatternParser()Construct a pattern parser.PatternParser(PatternConsumer consumer)Construct a pattern parser.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddClass(java.lang.String c)For testing purposes only.voidaddException(java.lang.String w, java.util.ArrayList e)For testing purposes only.voidaddPattern(java.lang.String p, java.lang.String v)For testing purposes only.voidcharacters(char[] ch, int start, int length)voidcloseTestOut()Close test out file.voidendElement(java.lang.String uri, java.lang.String local, java.lang.String raw)voiderror(org.xml.sax.SAXParseException ex)voidfatalError(org.xml.sax.SAXParseException ex)protected voidgetExternalClasses()static voidmain(java.lang.String[] args)Main entry point when used as an application.voidparse(java.io.File file)Parses a hyphenation pattern file.voidparse(java.lang.String filename)Parses a hyphenation pattern file.voidparse(org.xml.sax.InputSource source)Parses a hyphenation pattern file.voidsetTestOut(java.io.PrintStream testOut)Set test out stream.voidstartElement(java.lang.String uri, java.lang.String local, java.lang.String raw, org.xml.sax.Attributes attrs)voidwarning(org.xml.sax.SAXParseException ex)
-
-
-
Constructor Detail
-
PatternParser
public PatternParser() throws HyphenationExceptionConstruct a pattern parser.- Throws:
HyphenationException- if a hyphenation exception is raised
-
PatternParser
public PatternParser(PatternConsumer consumer) throws HyphenationException
Construct a pattern parser.- Parameters:
consumer- a pattern consumer- Throws:
HyphenationException- if a hyphenation exception is raised
-
-
Method Detail
-
parse
public void parse(java.lang.String filename) throws HyphenationExceptionParses a hyphenation pattern file.- Parameters:
filename- the filename- Throws:
HyphenationException- In case of an exception while parsing
-
parse
public void parse(java.io.File file) throws HyphenationExceptionParses a hyphenation pattern file.- Parameters:
file- the pattern file- Throws:
HyphenationException- In case of an exception while parsing
-
parse
public void parse(org.xml.sax.InputSource source) throws HyphenationExceptionParses a hyphenation pattern file.- Parameters:
source- the InputSource for the file- Throws:
HyphenationException- In case of an exception while parsing
-
getExternalClasses
protected void getExternalClasses() throws org.xml.sax.SAXException- Throws:
org.xml.sax.SAXException- if not caught
-
startElement
public void startElement(java.lang.String uri, java.lang.String local, java.lang.String raw, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException- Specified by:
startElementin interfaceorg.xml.sax.ContentHandler- Overrides:
startElementin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
endElement
public void endElement(java.lang.String uri, java.lang.String local, java.lang.String raw)- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler- Overrides:
endElementin classorg.xml.sax.helpers.DefaultHandler
-
characters
public void characters(char[] ch, int start, int length)- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler- Overrides:
charactersin classorg.xml.sax.helpers.DefaultHandler
-
warning
public void warning(org.xml.sax.SAXParseException ex)
- Specified by:
warningin interfaceorg.xml.sax.ErrorHandler- Overrides:
warningin classorg.xml.sax.helpers.DefaultHandler
-
error
public void error(org.xml.sax.SAXParseException ex)
- Specified by:
errorin interfaceorg.xml.sax.ErrorHandler- Overrides:
errorin classorg.xml.sax.helpers.DefaultHandler
-
fatalError
public void fatalError(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException- Specified by:
fatalErrorin interfaceorg.xml.sax.ErrorHandler- Overrides:
fatalErrorin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
addClass
public void addClass(java.lang.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:
addClassin interfacePatternConsumer- Parameters:
c- character group
-
addException
public void addException(java.lang.String w, java.util.ArrayList 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 andHypheninstances- Specified by:
addExceptionin interfacePatternConsumer- Parameters:
w- word to add as an exceptione- pre-hyphenated word
-
addPattern
public void addPattern(java.lang.String p, java.lang.String v)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
public void setTestOut(java.io.PrintStream testOut)
Set test out stream.- Parameters:
testOut- the testOut to set
-
closeTestOut
public void closeTestOut()
Close test out file.
-
main
public static void main(java.lang.String[] args) throws java.lang.ExceptionMain entry point when used as an application.- Parameters:
args- array of command line arguments- Throws:
java.lang.Exception- in case of uncaught exception
-
-