org.apache.fop.layout.hyphenation
Class HyphenationTree
org.apache.fop.layout.hyphenation.TernaryTree
|
+--org.apache.fop.layout.hyphenation.HyphenationTree
- public class HyphenationTree
- extends TernaryTree
- implements PatternConsumer, Serializable
This tree structure stores the hyphenation patterns in an efficient
way for fast lookup. It provides the provides the method to
hyphenate a word.
- Author:
- Carlos Villegas
Method Summary |
void | addClass(String chargroup) Add a character class to the tree. |
void | addException(String word, Vector hyphenatedword) Add an exception to the tree. |
void | addPattern(String pattern, String ivalue) Add a pattern to the tree. |
String | findPattern(String pat) |
Hyphenation | hyphenate(String word, int remainCharCount, int pushCharCount) Hyphenate word and return a Hyphenation object. |
Hyphenation | hyphenate(char[] w, int offset, int len, int remainCharCount, int pushCharCount) Hyphenate word and return an array of hyphenation points. |
void | loadPatterns(String filename) Read hyphenation patterns from an XML file. |
static void | main(String[] argv) |
void | printStats() |
Methods inherited from class org.apache.fop.layout.hyphenation.TernaryTree |
balance, clone, find, find, insert, insert, keys, knows, size, strcmp, strcmp, strcpy, strlen, strlen, trimToSize |
HyphenationTree
public HyphenationTree()
addClass
public void addClass(String chargroup)
- Add a character class to the tree. It is used by
PatternParser as callback to
add character classes. Character classes define the
valid word characters for hyphenation. If a word contains
a character not defined in any of the classes, it is not hyphenated.
It also defines a way to normalize the characters in order
to compare them with the stored patterns. Usually pattern
files use only lower case characters, in this case a class
for letter 'a', for example, should be defined as "aA", the first
character being the normalization char.
addException
public void addException(String word, Vector hyphenatedword)
- Add an exception to the tree. It is used by
PatternParser class as callback to
store the hyphenation exceptions.
- Parameters:
- word - normalized word
- hyphenatedword - a vector of alternating strings and
hyphen objects.
addPattern
public void addPattern(String pattern, String ivalue)
- Add a pattern to the tree. Mainly, to be used by
PatternParser class as callback to
add a pattern to the tree.
- Parameters:
- pattern - the hyphenation pattern
- ivalue - interletter weight values indicating the
desirability and priority of hyphenating at a given point
within the pattern. It should contain only digit characters.
(i.e. '0' to '9').
findPattern
public String findPattern(String pat)
hyphenate
public Hyphenation hyphenate(String word, int remainCharCount, int pushCharCount)
- Hyphenate word and return a Hyphenation object.
- Parameters:
- word - the word to be hyphenated
- remainCharCount - Minimum number of characters allowed
before the hyphenation point.
- pushCharCount - Minimum number of characters allowed after
the hyphenation point.
- Returns: a Hyphenation object representing
the hyphenated word or null if word is not hyphenated.
hyphenate
public Hyphenation hyphenate(char[] w, int offset, int len, int remainCharCount, int pushCharCount)
- Hyphenate word and return an array of hyphenation points.
- Parameters:
- w - char array that contains the word
- offset - Offset to first character in word
- len - Length of word
- remainCharCount - Minimum number of characters allowed
before the hyphenation point.
- pushCharCount - Minimum number of characters allowed after
the hyphenation point.
- Returns: a Hyphenation object representing
the hyphenated word or null if word is not hyphenated.
loadPatterns
public void loadPatterns(String filename)
throws HyphenationException
- Read hyphenation patterns from an XML file.
main
public static void main(String[] argv)
throws java.lang.Exception
printStats
public void printStats()
to Class org.apache.fop.layout.hyphenation.ByteVector- value space: stores the inteletter values
to Class java.util.Hashtable
- This map stores hyphenation exceptions
to Class org.apache.fop.layout.hyphenation.TernaryTree
- This map stores the character classes
to Class org.apache.fop.layout.hyphenation.TernaryTree
- Temporary map to store interletter values on pattern loading.