org.apache.fop.hyphenation

Class Hyphenator


public class Hyphenator
extends java.lang.Object

This class is the main entry point to the hyphenation package. You can use only the static methods or create an instance.
Author:
Carlos Villegas

Field Summary

protected static Log
log
logging instance

Constructor Summary

Hyphenator(String lang, String country, int leftMin, int rightMin)
Creates a new hyphenator.

Method Summary

static HyphenationTree
getFopHyphenationTree(String key)
Returns a hyphenation tree.
static HyphenationTree
getHyphenationTree(String lang, String country)
Returns a hyphenation tree for a given language and country.
static HyphenationTree
getHyphenationTree(String lang, String country, HyphenationTreeResolver resolver)
Returns a hyphenation tree for a given language and country.
static HyphenationTreeCache
getHyphenationTreeCache()
static HyphenationTree
getUserHyphenationTree(String key, String hyphenDir)
Load tree from serialized file or xml file using configuration settings
static HyphenationTree
getUserHyphenationTree(String key, HyphenationTreeResolver resolver)
Load tree from serialized file or xml file using configuration settings
Hyphenation
hyphenate(String word)
Hyphenates a word.
static Hyphenation
hyphenate(String lang, String country, String word, int leftMin, int rightMin)
Hyphenates a word.
static Hyphenation
hyphenate(String lang, String country, char[] word, int offset, int len, int leftMin, int rightMin)
Hyphenates a word.
static Hyphenation
hyphenate(String lang, String country, HyphenationTreeResolver resolver, String word, int leftMin, int rightMin)
Hyphenates a word.
static Hyphenation
hyphenate(String lang, String country, HyphenationTreeResolver resolver, char[] word, int offset, int len, int leftMin, int rightMin)
Hyphenates a word.
Hyphenation
hyphenate(char[] word, int offset, int len)
Hyphenates a word.
void
setLanguage(String lang, String country)
Sets the language and country for the hyphenation process.
void
setMinPushCharCount(int min)
Sets the minimum number of characters after the hyphenation point
void
setMinRemainCharCount(int min)
Sets the minimum number of characters before the hyphenation point

Field Details

log

protected static Log log
logging instance

Constructor Details

Hyphenator

public Hyphenator(String lang,
                  String country,
                  int leftMin,
                  int rightMin)
Creates a new hyphenator.
Parameters:
lang - the language
country - the country (may be null or "none")
leftMin - the minimum number of characters before the hyphenation point
rightMin - the minimum number of characters after the hyphenation point

Method Details

getFopHyphenationTree

public static HyphenationTree getFopHyphenationTree(String key)
Returns a hyphenation tree. This method looks in the resources (getResourceStream) for the hyphenation patterns.
Parameters:
key - the language/country key
Returns:
the hyphenation tree or null if it wasn't found in the resources

getHyphenationTree

public static HyphenationTree getHyphenationTree(String lang,
                                                 String country)
Returns a hyphenation tree for a given language and country. The hyphenation trees are cached.
Parameters:
lang - the language
country - the country (may be null or "none")
Returns:
the hyphenation tree

getHyphenationTree

public static HyphenationTree getHyphenationTree(String lang,
                                                 String country,
                                                 HyphenationTreeResolver resolver)
Returns a hyphenation tree for a given language and country. The hyphenation trees are cached.
Parameters:
lang - the language
country - the country (may be null or "none")
resolver - resolver to find the hyphenation files
Returns:
the hyphenation tree

getHyphenationTreeCache

public static HyphenationTreeCache getHyphenationTreeCache()
Returns:
the default (static) hyphenation tree cache

getUserHyphenationTree

public static HyphenationTree getUserHyphenationTree(String key,
                                                     String hyphenDir)
Load tree from serialized file or xml file using configuration settings
Parameters:
key - language key for the requested hyphenation file
hyphenDir - base directory to find hyphenation files in
Returns:
the requested HypenationTree or null if it is not available

getUserHyphenationTree

public static HyphenationTree getUserHyphenationTree(String key,
                                                     HyphenationTreeResolver resolver)
Load tree from serialized file or xml file using configuration settings
Parameters:
key - language key for the requested hyphenation file
resolver - resolver to find the hyphenation files
Returns:
the requested HypenationTree or null if it is not available

hyphenate

public Hyphenation hyphenate(String word)
Hyphenates a word.
Parameters:
word - the word to hyphenate
Returns:
the hyphenation result

hyphenate

public static Hyphenation hyphenate(String lang,
                                    String country,
                                    String word,
                                    int leftMin,
                                    int rightMin)
Hyphenates a word.
Parameters:
lang - the language
country - the optional country code (may be null or "none")
word - the word to hyphenate
leftMin - the minimum number of characters before the hyphenation point
rightMin - the minimum number of characters after the hyphenation point
Returns:
the hyphenation result

hyphenate

public static Hyphenation hyphenate(String lang,
                                    String country,
                                    char[] word,
                                    int offset,
                                    int len,
                                    int leftMin,
                                    int rightMin)
Hyphenates a word.
Parameters:
lang - the language
country - the optional country code (may be null or "none")
word - the word to hyphenate
offset - the offset of the first character in the "word" character array
len - the length of the word
leftMin - the minimum number of characters before the hyphenation point
rightMin - the minimum number of characters after the hyphenation point
Returns:
the hyphenation result

hyphenate

public static Hyphenation hyphenate(String lang,
                                    String country,
                                    HyphenationTreeResolver resolver,
                                    String word,
                                    int leftMin,
                                    int rightMin)
Hyphenates a word.
Parameters:
lang - the language
country - the optional country code (may be null or "none")
resolver - resolver to find the hyphenation files
word - the word to hyphenate
leftMin - the minimum number of characters before the hyphenation point
rightMin - the minimum number of characters after the hyphenation point
Returns:
the hyphenation result

hyphenate

public static Hyphenation hyphenate(String lang,
                                    String country,
                                    HyphenationTreeResolver resolver,
                                    char[] word,
                                    int offset,
                                    int len,
                                    int leftMin,
                                    int rightMin)
Hyphenates a word.
Parameters:
lang - the language
country - the optional country code (may be null or "none")
resolver - resolver to find the hyphenation files
word - the word to hyphenate
offset - the offset of the first character in the "word" character array
len - the length of the word
leftMin - the minimum number of characters before the hyphenation point
rightMin - the minimum number of characters after the hyphenation point
Returns:
the hyphenation result

hyphenate

public Hyphenation hyphenate(char[] word,
                             int offset,
                             int len)
Hyphenates a word.
Parameters:
word - the word to hyphenate
offset - the offset of the first character in the "word" character array
len - the length of the word
Returns:
the hyphenation result

setLanguage

public void setLanguage(String lang,
                        String country)
Sets the language and country for the hyphenation process.
Parameters:
lang - the language
country - the country (may be null or "none")

setMinPushCharCount

public void setMinPushCharCount(int min)
Sets the minimum number of characters after the hyphenation point
Parameters:
min - the number of characters

setMinRemainCharCount

public void setMinRemainCharCount(int min)
Sets the minimum number of characters before the hyphenation point
Parameters:
min - the number of characters

Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.