PatternParser (Lucene 10.5.0 common API)
Description: declaration: package: org.apache.lucene.analysis.compound.hyphenation, class: PatternParser

Package 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:
  `ContentHandler`, `DTDHandler`, `EntityResolver`, `ErrorHandler`

public class PatternParser extends DefaultHandler
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

  Constructors
  Constructor
  Description
  `PatternParser()`
  `PatternParser(PatternConsumer consumer)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `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)`
  `protected ArrayList<Object>`
  `normalizeException(ArrayList<?> ex)`
  `void`
  `parse(String filename)`
  Parses a hyphenation pattern file.
  `void`
  `parse(InputSource source)`
  Parses a hyphenation pattern file.
  `protected String`
  `readToken(StringBuilder 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`

  ### Methods inherited from interface org.xml.sax.ContentHandler

  `declaration`

- ## Constructor Details

  - ### PatternParser

    public PatternParser()

  - ### PatternParser

    public PatternParser(PatternConsumer consumer)

- ## Method Details

  - ### setConsumer

    public void setConsumer(PatternConsumer consumer)

  - ### parse

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

  - ### parse

    public void parse(InputSource source) throws IOException
    Parses a hyphenation pattern file.
    Parameters:
      `source` - the InputSource for the file
    Throws:
      `IOException` - In case of an exception while parsing

  - ### readToken

    protected String readToken(StringBuilder chars)

  - ### getPattern

    protected static String getPattern(String word)

  - ### normalizeException

    protected ArrayList<Object> normalizeException(ArrayList<?> ex)

  - ### getExceptionWord

    protected String getExceptionWord(ArrayList<?> ex)

  - ### getInterletterValues

    protected static String getInterletterValues(String pat)

  - ### resolveEntity

    public InputSource resolveEntity(String publicId, String systemId) throws SAXException
    Specified by:
      `resolveEntity` in interface `EntityResolver`
    Overrides:
      `resolveEntity` in class `DefaultHandler`
    Throws:
      `SAXException`

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