Clover Coverage Report
Coverage timestamp: Fri Jun 27 2008 17:20:33 EDT
../../../../img/srcFileCovDistChart9.png 50% of files have more coverage
28   127   19   2.8
8   68   0.68   10
10     1.9  
1    
 
  CalendarData       Line # 21 28 19 87% 0.8695652
 
No Tests
 
1    /*
2    *******************************************************************************
3    * Copyright (C) 2004-2005, International Business Machines Corporation and *
4    * others. All Rights Reserved. *
5    *******************************************************************************
6    */
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    /**
18    * This class abstracts access to calendar (Calendar and DateFormat) data.
19    * @internal ICU 3.0
20    */
 
21    public class CalendarData {
22    /**
23    * Construct a CalendarData from the given locale.
24    * @param loc locale to use. The 'calendar' keyword will be ignored.
25    * @param type calendar type. NULL indicates the gregorian calendar.
26    * No default lookup is done.
27    */
 
28  10913 toggle public CalendarData(ULocale loc, String type) {
29  10913 this((ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, loc), type);
30    }
31   
 
32  10914 toggle public CalendarData(ICUResourceBundle b, String type) {
33  10914 fBundle = b;
34  10914 if((type == null) || (type.equals("")) || (type.equals("gregorian"))) {
35  10613 fMainType = "gregorian";
36  10613 fFallbackType = null;
37    } else {
38  301 fMainType = type;
39  301 fFallbackType ="gregorian";
40    }
41    }
42   
43    /**
44    * Load data for calendar. Note, this object owns the resources, do NOT call ures_close()!
45    *
46    * @param key Resource key to data
47    * @internal
48    */
 
49  12877 toggle public ICUResourceBundle get(String key) {
50  12877 try {
51  12877 return fBundle.getWithFallback("calendar/" + fMainType + "/" + key);
52    } catch(MissingResourceException m) {
53  377 if(fFallbackType != null) {
54  377 return fBundle.getWithFallback("calendar/" + fFallbackType + "/" + key);
55    }
56  0 throw m;
57   
58    }
59    }
60   
61    /**
62    * Load data for calendar. Note, this object owns the resources, do NOT call ures_close()!
63    * There is an implicit key of 'format'
64    * data is located in: "calendar/key/format/subKey"
65    * for example, calendar/dayNames/format/abbreviated
66    *
67    * @param key Resource key to data
68    * @param subKey Resource key to data
69    * @internal
70    */
 
71  4168 toggle public ICUResourceBundle get(String key, String subKey) {
72  4168 try {
73  4168 return fBundle.getWithFallback("calendar/" + fMainType + "/" + key + "/format/" + subKey);
74    } catch(MissingResourceException m) {
75  226 if(fFallbackType != null) {
76  226 return fBundle.getWithFallback("calendar/" + fFallbackType + "/" + key + "/format/" + subKey);
77    }
78  0 throw m;
79   
80    }
81    }
82   
83    /**
84    * Load data for calendar. Note, this object owns the resources, do NOT call ures_close()!
85    * data is located in: "calendar/key/contextKey/subKey"
86    * for example, calendar/dayNames/stand-alone/narrow
87    *
88    * @param key Resource key to data
89    * @param contextKey Resource key to data
90    * @param subKey Resource key to data
91    * @internal
92    */
 
93  4185 toggle public ICUResourceBundle get(String key, String contextKey, String subKey) {
94  4185 try {
95  4185 return fBundle.getWithFallback("calendar/" + fMainType + "/" + key + "/" + contextKey + "/" + subKey);
96    } catch(MissingResourceException m) {
97  722 if(fFallbackType != null) {
98  722 return fBundle.getWithFallback("calendar/" + fFallbackType + "/" + key + "/" + contextKey + "/" + subKey);
99    }
100  0 throw m;
101   
102    }
103    }
104   
 
105  603 toggle public String[] getStringArray(String key) {
106  603 return get(key).getStringArray();
107    }
108   
 
109  4168 toggle public String[] getStringArray(String key, String subKey) {
110  4168 return get(key, subKey).getStringArray();
111    }
112   
 
113  4168 toggle public String[] getStringArray(String key, String contextKey, String subKey) {
114  4168 return get(key, contextKey, subKey).getStringArray();
115    }
 
116  1563 toggle public String[] getEras(String subkey){
117  1563 ICUResourceBundle bundle = get("eras/"+subkey);
118  1563 return bundle.getStringArray();
119    }
 
120  338 toggle public ULocale getULocale() {
121  338 return fBundle.getULocale();
122    }
123   
124    private ICUResourceBundle fBundle;
125    private String fMainType;
126    private String fFallbackType;
127    }