Package org.apache.fop.hyphenation
Class PatternParser
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.apache.fop.hyphenation.PatternParser
- All Implemented Interfaces:
PatternConsumer,ContentHandler,DTDHandler,EntityResolver,ErrorHandler
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).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate PatternConsumerprivate int(package private) static final int(package private) static final int(package private) static final int(package private) static final intprivate Stringprivate ArrayListprivate booleanprivate charprivate XMLReaderprivate PrintStreamprivate StringBuffer -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a pattern parser.PatternParser(PatternConsumer consumer) Construct a pattern parser. -
Method Summary
Modifier and TypeMethodDescriptionvoidFor testing purposes only.voidaddException(String w, ArrayList e) For testing purposes only.voidaddPattern(String p, String v) For testing purposes only.voidcharacters(char[] ch, int start, int length) voidClose test out file.(package private) static XMLReaderCreates a SAX parser using JAXPvoidendElement(String uri, String local, String raw) voidvoidprivate Stringprotected voidprivate static Stringprivate StringReturns a string of the location.private static StringgetPattern(String word) static voidMain entry point when used as an application.private ArrayListvoidParses a hyphenation pattern file.voidParses a hyphenation pattern file.voidparse(InputSource source) Parses a hyphenation pattern file.private StringreadToken(StringBuffer chars) voidsetTestOut(PrintStream testOut) Set test out stream.voidstartElement(String uri, String local, String raw, Attributes attrs) voidMethods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
-
Field Details
-
parser
-
currElement
private int currElement -
consumer
-
token
-
exception
-
hyphenChar
private char hyphenChar -
errMsg
-
hasClasses
private boolean hasClasses -
ELEM_CLASSES
static final int ELEM_CLASSES- See Also:
-
ELEM_EXCEPTIONS
static final int ELEM_EXCEPTIONS- See Also:
-
ELEM_PATTERNS
static final int ELEM_PATTERNS- See Also:
-
ELEM_HYPHEN
static final int ELEM_HYPHEN- See Also:
-
testOut
-
-
Constructor Details
-
PatternParser
Construct a pattern parser.- Throws:
HyphenationException- if a hyphenation exception is raised
-
PatternParser
Construct a pattern parser.- Parameters:
consumer- a pattern consumer- Throws:
HyphenationException- if a hyphenation exception is raised
-
-
Method Details
-
parse
Parses a hyphenation pattern file.- Parameters:
filename- the filename- Throws:
HyphenationException- In case of an exception while parsing
-
parse
Parses a hyphenation pattern file.- Parameters:
file- the pattern file- Throws:
HyphenationException- In case of an exception while parsing
-
parse
Parses a hyphenation pattern file.- Parameters:
source- the InputSource for the file- Throws:
HyphenationException- In case of an exception while parsing
-
createParser
Creates a SAX parser using JAXP- Returns:
- the created SAX parser
-
readToken
-
getPattern
-
normalizeException
-
getExceptionWord
-
getInterletterValues
-
getExternalClasses
- Throws:
SAXException- if not caught
-
startElement
public void startElement(String uri, String local, String raw, Attributes attrs) throws SAXException - Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Throws:
SAXException
-
endElement
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler
-
characters
public void characters(char[] ch, int start, int length) - Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler
-
warning
- Specified by:
warningin interfaceErrorHandler- Overrides:
warningin classDefaultHandler
-
error
- Specified by:
errorin interfaceErrorHandler- Overrides:
errorin classDefaultHandler
-
fatalError
- Specified by:
fatalErrorin interfaceErrorHandler- Overrides:
fatalErrorin classDefaultHandler- Throws:
SAXException
-
getLocationString
Returns a string of the location. -
addClass
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
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
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
Set test out stream.- Parameters:
testOut- the testOut to set
-
closeTestOut
public void closeTestOut()Close test out file. -
main
Main entry point when used as an application.- Parameters:
args- array of command line arguments- Throws:
Exception- in case of uncaught exception
-