Package com.itextpdf.layout.hyphenation
Class Hyphenator
- java.lang.Object
-
- com.itextpdf.layout.hyphenation.Hyphenator
-
public final 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.This work was authored by Carlos Villegas (cav@uniscope.co.jp).
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.List<java.lang.String>
additionalHyphenationFileDirectories
protected java.lang.String
country
private static HyphenationTreeCache
hTreeCache
(package private) java.util.Map<java.lang.String,java.lang.String>
hyphPathNames
protected java.lang.String
lang
(package private) int
leftMin
private static org.slf4j.Logger
log
Logging instance.(package private) int
rightMin
private static char
SOFT_HYPHEN
private static java.lang.Object
staticLock
-
Constructor Summary
Constructors Constructor Description Hyphenator(java.lang.String lang, java.lang.String country, int leftMin, int rightMin)
Creates a new hyphenator.Hyphenator(java.lang.String lang, java.lang.String country, int leftMin, int rightMin, java.util.Map<java.lang.String,java.lang.String> hyphPathNames)
Creates a new hyphenator.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
clearHyphenationTreeCache()
Clears the default hyphenation tree cache.static HyphenationTree
getHyphenationTree(java.io.InputStream in, java.lang.String name)
Load tree from the stream.static HyphenationTree
getHyphenationTree(java.lang.String searchDirectory, java.lang.String key)
Load tree from xml file using configuration settings.static HyphenationTree
getHyphenationTree(java.lang.String lang, java.lang.String country, java.util.Map<java.lang.String,java.lang.String> hyphPathNames)
Returns a hyphenation tree for a given language and country, with fallback from (lang,country) to (lang).static HyphenationTree
getHyphenationTree2(java.lang.String lang, java.lang.String country, java.util.Map<java.lang.String,java.lang.String> hyphPathNames)
Returns a hyphenation tree for a given language and country.static HyphenationTreeCache
getHyphenationTreeCache()
Returns the default hyphenation tree cache.Hyphenation
hyphenate(java.lang.String word)
Hyphenates a word.static Hyphenation
hyphenate(java.lang.String lang, java.lang.String country, java.lang.String word, int leftMin, int rightMin)
Hyphenates a word.static Hyphenation
hyphenate(java.lang.String lang, java.lang.String country, java.util.Map<java.lang.String,java.lang.String> hyphPathNames, java.lang.String word, int leftMin, int rightMin)
Hyphenates a word.private static Hyphenation
hyphenateBasedOnSoftHyphens(java.lang.String word, int leftMin, int rightMin)
static void
registerAdditionalHyphenationFileDirectory(java.lang.String directory)
Registers additional file directories.private static boolean
wordContainsSoftHyphens(java.lang.String word)
-
-
-
Field Detail
-
SOFT_HYPHEN
private static final char SOFT_HYPHEN
- See Also:
- Constant Field Values
-
staticLock
private static final java.lang.Object staticLock
-
log
private static org.slf4j.Logger log
Logging instance.
-
hTreeCache
private static HyphenationTreeCache hTreeCache
-
additionalHyphenationFileDirectories
private static java.util.List<java.lang.String> additionalHyphenationFileDirectories
-
lang
protected java.lang.String lang
-
country
protected java.lang.String country
-
leftMin
int leftMin
-
rightMin
int rightMin
-
hyphPathNames
java.util.Map<java.lang.String,java.lang.String> hyphPathNames
-
-
Constructor Detail
-
Hyphenator
public Hyphenator(java.lang.String lang, java.lang.String country, int leftMin, int rightMin)
Creates a new hyphenator.- Parameters:
lang
- the languagecountry
- the optional country code (may be null or "none")leftMin
- the minimum number of characters before the hyphenation pointrightMin
- the minimum number of characters after the hyphenation point
-
Hyphenator
public Hyphenator(java.lang.String lang, java.lang.String country, int leftMin, int rightMin, java.util.Map<java.lang.String,java.lang.String> hyphPathNames)
Creates a new hyphenator.- Parameters:
lang
- the languagecountry
- the optional country code (may be null or "none")hyphPathNames
- the map with user-configured hyphenation pattern file namesleftMin
- the minimum number of characters before the hyphenation pointrightMin
- the minimum number of characters after the hyphenation point
-
-
Method Detail
-
registerAdditionalHyphenationFileDirectory
public static void registerAdditionalHyphenationFileDirectory(java.lang.String directory)
Registers additional file directories.- Parameters:
directory
- directory to register
-
getHyphenationTreeCache
public static HyphenationTreeCache getHyphenationTreeCache()
Returns the default hyphenation tree cache.- Returns:
- the default (static) hyphenation tree cache
-
clearHyphenationTreeCache
public static void clearHyphenationTreeCache()
Clears the default hyphenation tree cache. This method can be used if the underlying data files are changed at runtime.
-
getHyphenationTree
public static HyphenationTree getHyphenationTree(java.lang.String lang, java.lang.String country, java.util.Map<java.lang.String,java.lang.String> hyphPathNames)
Returns a hyphenation tree for a given language and country, with fallback from (lang,country) to (lang). The hyphenation trees are cached.- Parameters:
lang
- the languagecountry
- the country (may be null or "none")hyphPathNames
- the map with user-configured hyphenation pattern file names- Returns:
- the hyphenation tree
-
getHyphenationTree2
public static HyphenationTree getHyphenationTree2(java.lang.String lang, java.lang.String country, java.util.Map<java.lang.String,java.lang.String> hyphPathNames)
Returns a hyphenation tree for a given language and country. The hyphenation trees are cached.- Parameters:
lang
- the languagecountry
- the country (may be null or "none")hyphPathNames
- the map with user-configured hyphenation pattern file names- Returns:
- the hyphenation tree
-
getHyphenationTree
public static HyphenationTree getHyphenationTree(java.lang.String searchDirectory, java.lang.String key)
Load tree from xml file using configuration settings.- Parameters:
searchDirectory
- the directory to search the file intokey
- language key for the requested hyphenation file- Returns:
- the requested HyphenationTree or null if it is not available
-
getHyphenationTree
public static HyphenationTree getHyphenationTree(java.io.InputStream in, java.lang.String name)
Load tree from the stream.- Parameters:
in
- the input stream to load the tree fromname
- unique key representing country-language combination- Returns:
- the requested HyphenationTree or null if it is not available
-
hyphenate
public static Hyphenation hyphenate(java.lang.String lang, java.lang.String country, java.util.Map<java.lang.String,java.lang.String> hyphPathNames, java.lang.String word, int leftMin, int rightMin)
Hyphenates a word.- Parameters:
lang
- the languagecountry
- the optional country code (may be null or "none")hyphPathNames
- the map with user-configured hyphenation pattern file namesword
- the word to hyphenateleftMin
- the minimum number of characters before the hyphenation pointrightMin
- the minimum number of characters after the hyphenation point- Returns:
- the hyphenation result
-
hyphenate
public static Hyphenation hyphenate(java.lang.String lang, java.lang.String country, java.lang.String word, int leftMin, int rightMin)
Hyphenates a word.- Parameters:
lang
- the languagecountry
- the optional country code (may be null or "none")word
- the word to hyphenateleftMin
- the minimum number of characters before the hyphenation pointrightMin
- the minimum number of characters after the hyphenation point- Returns:
- the hyphenation result
-
hyphenate
public Hyphenation hyphenate(java.lang.String word)
Hyphenates a word.- Parameters:
word
- the word to hyphenate- Returns:
- the hyphenation result
-
wordContainsSoftHyphens
private static boolean wordContainsSoftHyphens(java.lang.String word)
-
hyphenateBasedOnSoftHyphens
private static Hyphenation hyphenateBasedOnSoftHyphens(java.lang.String word, int leftMin, int rightMin)
-
-