140 141 if (!initialized) { 142 initNames(); 143 } 144 145 CalendarSystem cal = calendars.get(calendarName); 146 if (cal != null) { 147 return cal; 148 } 149 150 String className = names.get(calendarName); 151 if (className == null) { 152 return null; // Unknown calendar name 153 } 154 155 if (className.endsWith("LocalGregorianCalendar")) { 156 // Create the specific kind of local Gregorian calendar system 157 cal = LocalGregorianCalendar.getLocalGregorianCalendar(calendarName); 158 } else { 159 try { 160 Class<?> cl = Class.forName(className); 161 cal = (CalendarSystem) cl.newInstance(); 162 } catch (Exception e) { 163 throw new InternalError(e); 164 } 165 } 166 if (cal == null) { 167 return null; 168 } 169 CalendarSystem cs = calendars.putIfAbsent(calendarName, cal); 170 return (cs == null) ? cal : cs; 171 } 172 173 //////////////////////////////// Calendar API ////////////////////////////////// 174 175 /** 176 * Returns the name of this calendar system. 177 */ 178 public abstract String getName(); 179 180 public abstract CalendarDate getCalendarDate(); 181 | 140 141 if (!initialized) { 142 initNames(); 143 } 144 145 CalendarSystem cal = calendars.get(calendarName); 146 if (cal != null) { 147 return cal; 148 } 149 150 String className = names.get(calendarName); 151 if (className == null) { 152 return null; // Unknown calendar name 153 } 154 155 if (className.endsWith("LocalGregorianCalendar")) { 156 // Create the specific kind of local Gregorian calendar system 157 cal = LocalGregorianCalendar.getLocalGregorianCalendar(calendarName); 158 } else { 159 try { 160 @SuppressWarnings("deprecation") 161 Object tmp = Class.forName(className).newInstance(); 162 cal = (CalendarSystem) tmp; 163 } catch (Exception e) { 164 throw new InternalError(e); 165 } 166 } 167 if (cal == null) { 168 return null; 169 } 170 CalendarSystem cs = calendars.putIfAbsent(calendarName, cal); 171 return (cs == null) ? cal : cs; 172 } 173 174 //////////////////////////////// Calendar API ////////////////////////////////// 175 176 /** 177 * Returns the name of this calendar system. 178 */ 179 public abstract String getName(); 180 181 public abstract CalendarDate getCalendarDate(); 182 |