|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xml.sax.helpers.DefaultHandler org.apache.lucene.analysis.compound.hyphenation.PatternParser
public class PatternParser
A SAX document handler to read and parse hyphenation patterns from a XML file. This class has been taken from the Apache FOP project (http://xmlgraphics.apache.org/fop/). They have been slightly modified.
Constructor Summary | |
---|---|
PatternParser()
|
|
PatternParser(PatternConsumer consumer)
|
Method Summary | |
---|---|
void |
addClass(String c)
Add a character class. |
void |
addException(String w,
ArrayList<Object> e)
Add a hyphenation exception. |
void |
addPattern(String p,
String v)
Add hyphenation patterns. |
void |
characters(char[] ch,
int start,
int length)
|
void |
endElement(String uri,
String local,
String raw)
|
protected String |
getExceptionWord(ArrayList<?> ex)
|
protected static String |
getInterletterValues(String pat)
|
protected static String |
getPattern(String word)
|
static void |
main(String[] args)
|
protected ArrayList<Object> |
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)
|
InputSource |
resolveEntity(String publicId,
String systemId)
|
void |
setConsumer(PatternConsumer consumer)
|
void |
startElement(String uri,
String local,
String raw,
Attributes attrs)
|
Methods inherited from class org.xml.sax.helpers.DefaultHandler |
---|
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PatternParser() throws HyphenationException
HyphenationException
public PatternParser(PatternConsumer consumer) throws HyphenationException
HyphenationException
Method Detail |
---|
public void setConsumer(PatternConsumer consumer)
public void parse(String filename) throws HyphenationException
filename
- the filename
HyphenationException
- In case of an exception while parsingpublic void parse(File file) throws HyphenationException
file
- the pattern file
HyphenationException
- In case of an exception while parsingpublic void parse(InputSource source) throws HyphenationException
source
- the InputSource for the file
HyphenationException
- In case of an exception while parsingprotected String readToken(StringBuffer chars)
protected static String getPattern(String word)
protected ArrayList<Object> normalizeException(ArrayList<?> ex)
protected String getExceptionWord(ArrayList<?> ex)
protected static String getInterletterValues(String pat)
public InputSource resolveEntity(String publicId, String systemId)
resolveEntity
in interface EntityResolver
resolveEntity
in class DefaultHandler
public void startElement(String uri, String local, String raw, Attributes attrs)
startElement
in interface ContentHandler
startElement
in class DefaultHandler
ContentHandler.startElement(java.lang.String,
java.lang.String, java.lang.String, org.xml.sax.Attributes)
public void endElement(String uri, String local, String raw)
endElement
in interface ContentHandler
endElement
in class DefaultHandler
ContentHandler.endElement(java.lang.String,
java.lang.String, java.lang.String)
public void characters(char[] ch, int start, int length)
characters
in interface ContentHandler
characters
in class DefaultHandler
ContentHandler.characters(char[], int, int)
public void addClass(String c)
PatternConsumer
addClass
in interface PatternConsumer
c
- character grouppublic void addException(String w, ArrayList<Object> e)
PatternConsumer
Hyphen
instances
addException
in interface PatternConsumer
public void addPattern(String p, String v)
PatternConsumer
addPattern
in interface PatternConsumer
p
- the patternv
- interletter values expressed as a string of digit characters.public static void main(String[] args) throws Exception
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |