PatternParser (Lucene 2.4.1 API)
Keywords: org.apache.lucene.analysis.compound.hyphenation.PatternParser class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.lucene.analysis.compound.hyphenation
Class PatternParser

    java.lang.Object
      org.xml.sax.helpers.DefaultHandler
          org.apache.lucene.analysis.compound.hyphenation.PatternParser

All Implemented Interfaces:
  PatternConsumer, ContentHandler, DTDHandler, EntityResolver, ErrorHandler

    public class PatternParser

extends DefaultHandler
implements PatternConsumer

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 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)`
`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)`
`InputSource` | `resolveEntity(String publicId, String systemId)`
`void` | `setConsumer(PatternConsumer consumer)`
`void` | `startElement(String uri, String local, String raw, Attributes attrs)`
`void` | `warning(SAXParseException ex)`

Methods inherited from class org.xml.sax.helpers.DefaultHandler
`endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PatternParser

    public PatternParser()
                  throws HyphenationException

Throws:
  `HyphenationException`

### PatternParser

    public PatternParser(PatternConsumer consumer)
                  throws HyphenationException

Throws:
  `HyphenationException`

Method Detail

### setConsumer

    public void setConsumer(PatternConsumer consumer)

### 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

### 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

### readToken

    protected String readToken(StringBuffer chars)

### getPattern

    protected static String getPattern(String word)

### normalizeException

    protected ArrayList normalizeException(ArrayList ex)

### getExceptionWord

    protected String getExceptionWord(ArrayList ex)

### getInterletterValues

    protected static String getInterletterValues(String pat)

### resolveEntity

    public InputSource resolveEntity(String publicId,
                                     String systemId)

  Specified by:
    `resolveEntity` in interface `EntityResolver`
  Overrides:
    `resolveEntity` in class `DefaultHandler`

### startElement

    public void startElement(String uri,
                             String local,
                             String raw,
                             Attributes attrs)

  Specified by:
    `startElement` in interface `ContentHandler`
  Overrides:
    `startElement` in class `DefaultHandler`
  See Also:
    `ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)`

### endElement

    public void endElement(String uri,
                           String local,
                           String raw)

  Specified by:
    `endElement` in interface `ContentHandler`
  Overrides:
    `endElement` in class `DefaultHandler`
  See Also:
    `ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)`

### characters

    public void characters(char[] ch,
                           int start,
                           int length)

  Specified by:
    `characters` in interface `ContentHandler`
  Overrides:
    `characters` in class `DefaultHandler`
  See Also:
    `ContentHandler.characters(char[], int, int)`

### warning

    public void warning(SAXParseException ex)

  Specified by:
    `warning` in interface `ErrorHandler`
  Overrides:
    `warning` in class `DefaultHandler`
  See Also:
    `ErrorHandler.warning(org.xml.sax.SAXParseException)`

### error

    public void error(SAXParseException ex)

  Specified by:
    `error` in interface `ErrorHandler`
  Overrides:
    `error` in class `DefaultHandler`
  See Also:
    `ErrorHandler.error(org.xml.sax.SAXParseException)`

### fatalError

    public void fatalError(SAXParseException ex)
                    throws SAXException

  Specified by:
    `fatalError` in interface `ErrorHandler`
  Overrides:
    `fatalError` in class `DefaultHandler`
  Throws:
    `SAXException`
  See Also:
    `ErrorHandler.fatalError(org.xml.sax.SAXParseException)`

### addClass

    public void addClass(String c)

  Description copied from interface: `PatternConsumer`
  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:
    `addClass` in interface `PatternConsumer`
  Parameters:
    `c` - character group

### addException

    public void addException(String w,
                             ArrayList e)

  Description copied from interface: `PatternConsumer`
  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 and `Hyphen` instances

  Specified by:
    `addException` in interface `PatternConsumer`

### addPattern

    public void addPattern(String p,
                           String v)

  Description copied from interface: `PatternConsumer`
  Add hyphenation patterns.

  Specified by:
    `addPattern` in interface `PatternConsumer`
  Parameters:
    `p` - the pattern
    `v` - interletter values expressed as a string of digit characters.

### main

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

  Throws:
    `Exception`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2009 Apache Software Foundation. All Rights Reserved.