--- old/src/share/classes/sun/util/BuddhistCalendar.java Fri Jul 20 11:45:08 2012
+++ new/src/share/classes/sun/util/BuddhistCalendar.java Fri Jul 20 11:45:06 2012
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,16 +25,13 @@
package sun.util;
+import sun.util.locale.provider.CalendarDataUtility;
import java.io.IOException;
import java.io.ObjectInputStream;
-import java.util.Calendar;
import java.util.GregorianCalendar;
-import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
-import java.util.ResourceBundle;
import java.util.TimeZone;
-import sun.util.resources.LocaleData;
public class BuddhistCalendar extends GregorianCalendar {
@@ -91,6 +88,14 @@
/////////////////
/**
+ * Returns {@code "buddhist"} as the calendar type of this Calendar.
+ */
+ @Override
+ public String getCalendarType() {
+ return "buddhist";
+ }
+
+ /**
* Compares this BuddhistCalendar to an object reference.
* @param obj the object reference with which to compare
* @return true if this object is equal to obj
; false otherwise
@@ -178,17 +183,8 @@
return super.getDisplayName(field, style, locale);
}
- // Handle Thai BuddhistCalendar specific era names
- if (field < 0 || field >= fields.length ||
- style < SHORT || style > LONG) {
- throw new IllegalArgumentException();
- }
- if (locale == null) {
- throw new NullPointerException();
- }
- ResourceBundle rb = LocaleData.getDateFormatData(locale);
- String[] eras = rb.getStringArray(getKey(style));
- return eras[get(field)];
+ String name = CalendarDataUtility.retrieveFieldValueName("buddhist", field, get(field), style, locale);
+ return name;
}
public Map getDisplayNames(int field, int style, Locale locale) {
@@ -195,52 +191,10 @@
if (field != ERA) {
return super.getDisplayNames(field, style, locale);
}
-
- // Handle Thai BuddhistCalendar specific era names
- if (field < 0 || field >= fields.length ||
- style < ALL_STYLES || style > LONG) {
- throw new IllegalArgumentException();
- }
- if (locale == null) {
- throw new NullPointerException();
- }
- // ALL_STYLES
- if (style == ALL_STYLES) {
- Map shortNames = getDisplayNamesImpl(field, SHORT, locale);
- Map longNames = getDisplayNamesImpl(field, LONG, locale);
- if (shortNames == null) {
- return longNames;
- }
- if (longNames != null) {
- shortNames.putAll(longNames);
- }
- return shortNames;
- }
-
- // SHORT or LONG
- return getDisplayNamesImpl(field, style, locale);
+ Map names = CalendarDataUtility.retrieveFieldValueNames("buddhist", field, style, locale);
+ return names;
}
- private Map getDisplayNamesImpl(int field, int style, Locale locale) {
- ResourceBundle rb = LocaleData.getDateFormatData(locale);
- String[] eras = rb.getStringArray(getKey(style));
- Map map = new HashMap(4);
- for (int i = 0; i < eras.length; i++) {
- map.put(eras[i], i);
- }
- return map;
- }
-
- private String getKey(int style) {
- StringBuilder key = new StringBuilder();
- key.append(BuddhistCalendar.class.getName());
- if (style == SHORT) {
- key.append(".short");
- }
- key.append(".Eras");
- return key.toString();
- }
-
/**
* Returns the maximum value that this field could have, given the
* current date. For example, with the date "Feb 3, 2540" and the