1 7 8 package com.ibm.icu.impl; 9 10 import java.util.MissingResourceException ; 11 12 import com.ibm.icu.util.ULocale; 13 import com.ibm.icu.util.UResourceBundle; 14 15 16 17 21 public class CalendarData { 22 28 public CalendarData(ULocale loc, String type) { 29 this((ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, loc), type); 30 } 31 32 public CalendarData(ICUResourceBundle b, String type) { 33 fBundle = b; 34 if((type == null) || (type.equals("")) || (type.equals("gregorian"))) { 35 fMainType = "gregorian"; 36 fFallbackType = null; 37 } else { 38 fMainType = type; 39 fFallbackType ="gregorian"; 40 } 41 } 42 43 49 public ICUResourceBundle get(String key) { 50 try { 51 return fBundle.getWithFallback("calendar/" + fMainType + "/" + key); 52 } catch(MissingResourceException m) { 53 if(fFallbackType != null) { 54 return fBundle.getWithFallback("calendar/" + fFallbackType + "/" + key); 55 } 56 throw m; 57 58 } 59 } 60 61 71 public ICUResourceBundle get(String key, String subKey) { 72 try { 73 return fBundle.getWithFallback("calendar/" + fMainType + "/" + key + "/format/" + subKey); 74 } catch(MissingResourceException m) { 75 if(fFallbackType != null) { 76 return fBundle.getWithFallback("calendar/" + fFallbackType + "/" + key + "/format/" + subKey); 77 } 78 throw m; 79 80 } 81 } 82 83 93 public ICUResourceBundle get(String key, String contextKey, String subKey) { 94 try { 95 return fBundle.getWithFallback("calendar/" + fMainType + "/" + key + "/" + contextKey + "/" + subKey); 96 } catch(MissingResourceException m) { 97 if(fFallbackType != null) { 98 return fBundle.getWithFallback("calendar/" + fFallbackType + "/" + key + "/" + contextKey + "/" + subKey); 99 } 100 throw m; 101 102 } 103 } 104 105 public String [] getStringArray(String key) { 106 return get(key).getStringArray(); 107 } 108 109 public String [] getStringArray(String key, String subKey) { 110 return get(key, subKey).getStringArray(); 111 } 112 113 public String [] getStringArray(String key, String contextKey, String subKey) { 114 return get(key, contextKey, subKey).getStringArray(); 115 } 116 public String [] getEras(String subkey){ 117 ICUResourceBundle bundle = get("eras/"+subkey); 118 return bundle.getStringArray(); 119 } 120 public ULocale getULocale() { 121 return fBundle.getULocale(); 122 } 123 124 private ICUResourceBundle fBundle; 125 private String fMainType; 126 private String fFallbackType; 127 } 128 | Popular Tags |