1 17 18 19 20 package org.apache.fop.hyphenation; 21 22 import java.util.Hashtable ; 23 import java.util.Set ; 24 25 28 public class HyphenationTreeCache { 29 30 31 private Hashtable hyphenTrees = new Hashtable (); 32 33 private Set missingHyphenationTrees; 34 35 41 public HyphenationTree getHyphenationTree(String lang, String country) { 42 String key = constructKey(lang, country); 43 44 if (hyphenTrees.containsKey(key)) { 46 return (HyphenationTree)hyphenTrees.get(key); 47 } else if (hyphenTrees.containsKey(lang)) { 48 return (HyphenationTree)hyphenTrees.get(lang); 49 } else { 50 return null; 51 } 52 } 53 54 60 public static String constructKey(String lang, String country) { 61 String key = lang; 62 if (country != null && !country.equals("none")) { 64 key += "_" + country; 65 } 66 return key; 67 } 68 69 74 public void cache(String key, HyphenationTree hTree) { 75 hyphenTrees.put(key, hTree); 76 } 77 78 84 public void noteMissing(String key) { 85 if (missingHyphenationTrees == null) { 86 missingHyphenationTrees = new java.util.HashSet (); 87 } 88 missingHyphenationTrees.add(key); 89 } 90 91 98 public boolean isMissing(String key) { 99 return (missingHyphenationTrees != null && missingHyphenationTrees.contains(key)); 100 } 101 102 } 103 | Popular Tags |