Package com.itextpdf.layout.hyphenation
Class Hyphenator
java.lang.Object
com.itextpdf.layout.hyphenation.Hyphenator
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
-
Constructor Summary
ConstructorDescriptionHyphenator
(String lang, String country, int leftMin, int rightMin) Creates a new hyphenator.Hyphenator
(String lang, String country, int leftMin, int rightMin, Map<String, String> hyphPathNames) Creates a new hyphenator. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Clears the default hyphenation tree cache.static HyphenationTree
getHyphenationTree
(InputStream in, String name) Load tree from the stream.static HyphenationTree
getHyphenationTree
(String searchDirectory, String key) Load tree from xml file using configuration settings.static HyphenationTree
Returns a hyphenation tree for a given language and country, with fallback from (lang,country) to (lang).static HyphenationTree
Returns a hyphenation tree for a given language and country.static HyphenationTreeCache
Returns the default hyphenation tree cache.Hyphenates a word.static Hyphenation
Hyphenates a word.static Hyphenation
hyphenate
(String lang, String country, Map<String, String> hyphPathNames, String word, int leftMin, int rightMin) Hyphenates a word.static void
registerAdditionalHyphenationFileDirectory
(String directory) Registers additional file directories.
-
Field Details
-
lang
-
country
-
-
Constructor Details
-
Hyphenator
Creates a new hyphenator.- Parameters:
-
lang
- the language -
country
- the optional country code (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
-
Hyphenator
public Hyphenator(String lang, String country, int leftMin, int rightMin, Map<String, String> hyphPathNames) Creates a new hyphenator.- Parameters:
-
lang
- the language -
country
- the optional country code (may be null or "none") -
hyphPathNames
- the map with user-configured hyphenation pattern file names -
leftMin
- the minimum number of characters before the hyphenation point -
rightMin
- the minimum number of characters after the hyphenation point
-
-
Method Details
-
registerAdditionalHyphenationFileDirectory
Registers additional file directories.- Parameters:
-
directory
- directory to register
-
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(String lang, String country, Map<String, 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 language -
country
- 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(String lang, String country, Map<String, String> hyphPathNames) 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") -
hyphPathNames
- the map with user-configured hyphenation pattern file names - Returns:
- the hyphenation tree
-
getHyphenationTree
Load tree from xml file using configuration settings.- Parameters:
-
searchDirectory
- the directory to search the file into -
key
- language key for the requested hyphenation file - Returns:
- the requested HyphenationTree or null if it is not available
-
getHyphenationTree
Load tree from the stream.- Parameters:
-
in
- the input stream to load the tree from -
name
- unique key representing country-language combination - Returns:
- the requested HyphenationTree or null if it is not available
-
hyphenate
public static Hyphenation hyphenate(String lang, String country, Map<String, String> hyphPathNames, String word, int leftMin, int rightMin) Hyphenates a word.- Parameters:
-
lang
- the language -
country
- the optional country code (may be null or "none") -
hyphPathNames
- the map with user-configured hyphenation pattern file names -
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, 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
Hyphenates a word.- Parameters:
-
word
- the word to hyphenate - Returns:
- the hyphenation result
-