Package com.itextpdf.layout.hyphenation
Class HyphenationTreeCache
- java.lang.Object
-
- com.itextpdf.layout.hyphenation.HyphenationTreeCache
-
public class HyphenationTreeCache extends java.lang.Object
This is a cache for HyphenationTree instances.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,HyphenationTree>
hyphenTrees
Contains the cached hyphenation treesprivate java.util.Set<java.lang.String>
missingHyphenationTrees
Used to avoid multiple error messages for the same language if a pattern file is missing.
-
Constructor Summary
Constructors Constructor Description HyphenationTreeCache()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cache(java.lang.String key, HyphenationTree hTree)
Cache a hyphenation tree under its key.static java.lang.String
constructLlccKey(java.lang.String lang, java.lang.String country)
Constructs the key for the hyphenation pattern file.static java.lang.String
constructUserKey(java.lang.String lang, java.lang.String country, java.util.Map<java.lang.String,java.lang.String> hyphPatNames)
If the user configured a hyphenation pattern file name for this (lang,country) value, return it.HyphenationTree
getHyphenationTree(java.lang.String lang, java.lang.String country)
Looks in the cache if a hyphenation tree is available and returns it if it is found.boolean
isMissing(java.lang.String key)
Indicates whether a hyphenation file has been requested before but it wasn't available.void
noteMissing(java.lang.String key)
Notes a key to a hyphenation tree as missing.
-
-
-
Field Detail
-
hyphenTrees
private java.util.Map<java.lang.String,HyphenationTree> hyphenTrees
Contains the cached hyphenation trees
-
missingHyphenationTrees
private java.util.Set<java.lang.String> missingHyphenationTrees
Used to avoid multiple error messages for the same language if a pattern file is missing.
-
-
Method Detail
-
getHyphenationTree
public HyphenationTree getHyphenationTree(java.lang.String lang, java.lang.String country)
Looks in the cache if a hyphenation tree is available and returns it if it is found.- Parameters:
lang
- the languagecountry
- the country (may be null or "none")- Returns:
- the HyhenationTree instance or null if it's not in the cache
-
constructLlccKey
public static java.lang.String constructLlccKey(java.lang.String lang, java.lang.String country)
Constructs the key for the hyphenation pattern file.- Parameters:
lang
- the languagecountry
- the country (may be null or "none")- Returns:
- the resulting key
-
constructUserKey
public static java.lang.String constructUserKey(java.lang.String lang, java.lang.String country, java.util.Map<java.lang.String,java.lang.String> hyphPatNames)
If the user configured a hyphenation pattern file name for this (lang,country) value, return it. If not, return null.- Parameters:
lang
- the languagecountry
- the country (may be null or "none")hyphPatNames
- the map of user-configured hyphenation pattern file names- Returns:
- the hyphenation pattern file name or null
-
cache
public void cache(java.lang.String key, HyphenationTree hTree)
Cache a hyphenation tree under its key.- Parameters:
key
- the key (ex. "de_CH" or "en")hTree
- the hyphenation tree
-
noteMissing
public void noteMissing(java.lang.String key)
Notes a key to a hyphenation tree as missing. This is to avoid searching a second time for a hyphenation pattern file which is not available.- Parameters:
key
- the key (ex. "de_CH" or "en")
-
isMissing
public boolean isMissing(java.lang.String key)
Indicates whether a hyphenation file has been requested before but it wasn't available. This is to avoid searching a second time for a hyphenation pattern file which is not available.- Parameters:
key
- the key (ex. "de_CH" or "en")- Returns:
- true if the hyphenation tree is unavailable
-
-