au.id.pbw.hyfo.hyph
Class HyphenationTree

java.lang.Object
  extended by au.id.pbw.hyfo.hyph.HyphenationTree
All Implemented Interfaces:
Serializable

public class HyphenationTree
extends Object
implements Serializable

Represents a tree of hyphenation data and associated structures.

The tree itself is an instance of a ShortTernaryTree. Associated with it is an Alphabet, defining the canonical character set and equivalents, and another ShortTernaryTree of hyphenation exceptions.

These structures are derived from an input file of hyphenation data. This is an XML file conforming to hyph/hyphenation.dtd in the HYFo tree. The data in the hyphenation files is taken from various TeX hyphenation files. The character set of all hyphenation files is UTF-8.

Author:
pbw
See Also:
Serialized Form

Constructor Summary
HyphenationTree(Alphabet alphabet, TernaryTree exceptions, HyphenDataCache exception_data, TernaryTree patterns, HyphenDataCache pattern_data)
          Creates a new instance of HyphenationTree, from a set of components which have been constructed by processing a hyphenation pattern file.
 
Method Summary
static HyphenationTree deserialize_tree(String id)
          Deserializes a HyphenationTree, given an id, normally a language or language_country specifier, by which a serialized tree can be identified.
 void dump_exceptions(PrintStream stream)
          Formats and dumps the contents of the exceptions tree to the nominated PrintStream.
 void dump_patterns(PrintStream stream)
          Formats and dumps the contents of the patterns tree to the nominated PrintStream.
 void dump_ternary_tree(TernaryTree tree, HyphenDataCache data_cache, PrintStream stream)
          Formats and dumps the contents of the nominated tree to the nominated PrintStream.
 String format_data(HyphenBreak[] breaks)
          Formats an array of HyphenBreaks into a display string.
 String format_key(int[] key)
          Format the given key, represented as an array of codepoints, into a string.
 HyphenatedWord hyphenate(String word)
          Gets the hyphenation data for the given word as a HyphenatedWord.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HyphenationTree

public HyphenationTree(Alphabet alphabet,
                       TernaryTree exceptions,
                       HyphenDataCache exception_data,
                       TernaryTree patterns,
                       HyphenDataCache pattern_data)
Creates a new instance of HyphenationTree, from a set of components which have been constructed by processing a hyphenation pattern file.

Parameters:
exception_data - a implementation of TernaryTreeDataStore containing the exception tree data.
pattern_data - a implementation of TernaryTreeDataStore containing the pattern tree data.
alphabet - an instance of the Alphabet used by this tree.
exceptions - the ternary tree of exceptions defined in this tree.
patterns - the ternary tree of patterns defined in this tree.
Method Detail

hyphenate

public HyphenatedWord hyphenate(String word)
Gets the hyphenation data for the given word as a HyphenatedWord.

Parameters:
word - the word to hyphenate.
Returns:
the WHyphenatedWord/CODE> containing the hyphenation data for the word.

format_data

public String format_data(HyphenBreak[] breaks)
Formats an array of HyphenBreaks into a display string.

Parameters:
breaks - the array of HyphenBreaks.
Returns:
the string representation of the HyphenBreaks.

dump_exceptions

public void dump_exceptions(PrintStream stream)
Formats and dumps the contents of the exceptions tree to the nominated PrintStream.

Parameters:
stream - the stream to which to dump the tree.

dump_patterns

public void dump_patterns(PrintStream stream)
Formats and dumps the contents of the patterns tree to the nominated PrintStream.

Parameters:
stream - the stream to which to dump the tree.

dump_ternary_tree

public void dump_ternary_tree(TernaryTree tree,
                              HyphenDataCache data_cache,
                              PrintStream stream)
Formats and dumps the contents of the nominated tree to the nominated PrintStream.

Parameters:
tree - the tree to dump.
data_cache - the implementation of TernaryTreeDataStore from which tree data may be retrieved and formatted.
stream - the stream to which to dump the tree.

format_key

public String format_key(int[] key)
Format the given key, represented as an array of codepoints, into a string.

Parameters:
key - the key as an array of codepoints.
Returns:
the string representation of the array of codepoints.

deserialize_tree

public static HyphenationTree deserialize_tree(String id)
                                        throws HyphenationException,
                                               IOException
Deserializes a HyphenationTree, given an id, normally a language or language_country specifier, by which a serialized tree can be identified.

Parameters:
id - the id of the serialized tree.
Returns:
the deserialized instance of HyphenationTree.
Throws:
HyphenationException - if the resource cannot be located, or is not a valid class.
IOException - if an IO error occurs during deserialization.


Copyright © 2005-2006 Peter B. West.