org.apache.fop.hyphenation

Class PatternParser

Implemented Interfaces:
PatternConsumer

public class PatternParser
extends DefaultHandler
implements PatternConsumer

A SAX document handler to read and parse hyphenation patterns from a XML file.
Author:
Carlos Villegas

Constructor Summary

PatternParser()
PatternParser(PatternConsumer consumer)

Method Summary

void
addClass(String c)
void
addException(String w, ArrayList e)
void
addPattern(String p, String v)
void
characters(ch[] , int start, int length)
void
endElement(String uri, String local, String raw)
void
error(SAXParseException ex)
void
fatalError(SAXParseException ex)
protected String
getExceptionWord(ArrayList ex)
protected static String
getInterletterValues(String pat)
protected static String
getPattern(String word)
static void
main(String[] args)
protected ArrayList
normalizeException(ArrayList ex)
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.
protected String
readToken(StringBuffer chars)
void
setConsumer(PatternConsumer consumer)
void
startElement(String uri, String local, String raw, Attributes attrs)
void
warning(SAXParseException ex)

Constructor Details

PatternParser

public PatternParser()
            throws HyphenationException

PatternParser

public PatternParser(PatternConsumer consumer)
            throws HyphenationException

Method Details

addClass

public void addClass(String c)
Specified by:
addClass in interface PatternConsumer

addException

public void addException(String w,
                         ArrayList e)
Specified by:
addException in interface PatternConsumer

addPattern

public void addPattern(String p,
                       String v)
Specified by:
addPattern in interface PatternConsumer

characters

public void characters(ch[] ,
                       int start,
                       int length)
See Also:
org.xml.sax.ContentHandler.characters(char[], int, int)

endElement

public void endElement(String uri,
                       String local,
                       String raw)
See Also:
org.xml.sax.ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

error

public void error(SAXParseException ex)
See Also:
org.xml.sax.ErrorHandler.error(org.xml.sax.SAXParseException)

fatalError

public void fatalError(SAXParseException ex)
            throws SAXException
See Also:
org.xml.sax.ErrorHandler.fatalError(org.xml.sax.SAXParseException)

getExceptionWord

protected String getExceptionWord(ArrayList ex)

getInterletterValues

protected static String getInterletterValues(String pat)

getPattern

protected static String getPattern(String word)

main

public static void main(String[] args)
            throws Exception

normalizeException

protected ArrayList normalizeException(ArrayList ex)

parse

public void parse(File file)
            throws HyphenationException
Parses a hyphenation pattern file.
Parameters:
file - the pattern file
Throws:
HyphenationException - In case of an exception while parsing

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

parse

public void parse(String filename)
            throws HyphenationException
Parses a hyphenation pattern file.
Parameters:
filename - the filename
Throws:
HyphenationException - In case of an exception while parsing

readToken

protected String readToken(StringBuffer chars)

setConsumer

public void setConsumer(PatternConsumer consumer)

startElement

public void startElement(String uri,
                         String local,
                         String raw,
                         Attributes attrs)
See Also:
org.xml.sax.ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

warning

public void warning(SAXParseException ex)
See Also:
org.xml.sax.ErrorHandler.warning(org.xml.sax.SAXParseException)

Copyright 1999-2007 The Apache Software Foundation. All Rights Reserved.