You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2007/01/02 17:22:07 UTC
svn commit: r491834 [4/7] - in
/harmony/enhanced/classlib/trunk/modules/luni/src/main/java: java/net/
java/util/ org/apache/harmony/luni/internal/nls/
org/apache/harmony/luni/internal/reflect/ org/apache/harmony/luni/net/
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Currency.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Currency.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Currency.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Currency.java Tue Jan 2 08:22:05 2007
@@ -17,110 +17,112 @@
package java.util;
-
import java.io.Serializable;
+import org.apache.harmony.luni.util.Msg;
+
/**
* This class represents a currency as identified in the ISO 4217 currency
* codes.
*/
public final class Currency implements Serializable {
- private static final long serialVersionUID = -158308464356906721L;
+ private static final long serialVersionUID = -158308464356906721L;
+
+ private static Hashtable<String, Currency> codesToCurrencies = new Hashtable<String, Currency>();
+
+ private String currencyCode;
- private static Hashtable<String,Currency> codesToCurrencies = new Hashtable<String,Currency>();
+ private static String currencyVars = "EURO, HK, PREEURO"; //$NON-NLS-1$
- private String currencyCode;
+ private transient int defaultFractionDigits;
- private static String currencyVars = "EURO, HK, PREEURO"; //$NON-NLS-1$
+ /**
+ * @param currencyCode
+ */
+ private Currency(String currencyCode) {
+ this.currencyCode = currencyCode;
+ }
- private transient int defaultFractionDigits;
-
- /**
- * @param currencyCode
- */
- private Currency(String currencyCode) {
- this.currencyCode = currencyCode;
- }
-
- /**
- * Answers the currency instance for this currency code.
- * <p>
- *
- * @param currencyCode
- * java.lang.String
- * @return currency java.util.Currency
- *
- * @throws java.lang.IllegalArgumentException
- * if the currency code is not a supported ISO 4217 currency
- * code
- */
- public static Currency getInstance(String currencyCode) {
- Currency currency = codesToCurrencies.get(currencyCode);
-
- if (currency == null) {
- ResourceBundle bundle = Locale.getBundle(
- "ISO4CurrenciesToDigits", Locale.getDefault()); //$NON-NLS-1$
- currency = new Currency(currencyCode);
-
- String defaultFractionDigits = null;
- try {
- defaultFractionDigits = bundle.getString(currencyCode);
- } catch (MissingResourceException e) {
- throw new IllegalArgumentException(org.apache.harmony.luni.util.Msg
- .getString("K0322", currencyCode)); //$NON-NLS-1$
- }
- currency.defaultFractionDigits = Integer
- .parseInt(defaultFractionDigits);
- codesToCurrencies.put(currencyCode, currency);
- }
-
- return currency;
- }
-
- /***************************************************************************
- * Answers the currency instance for this locale.
- *
- * @param locale
- * java.util.Locale
- * @return currency java.util.Currency
- *
- * @throws java.lang.IllegalArgumentException
- * if the locale's country is not a supported ISO 3166 Country
- */
- public static Currency getInstance(Locale locale) {
- String country = locale.getCountry();
- String variant = locale.getVariant();
- if (!variant.equals("") && currencyVars.indexOf(variant) > -1) {
+ /**
+ * Answers the currency instance for this currency code.
+ * <p>
+ *
+ * @param currencyCode
+ * java.lang.String
+ * @return currency java.util.Currency
+ *
+ * @throws java.lang.IllegalArgumentException
+ * if the currency code is not a supported ISO 4217 currency
+ * code
+ */
+ public static Currency getInstance(String currencyCode) {
+ Currency currency = codesToCurrencies.get(currencyCode);
+
+ if (currency == null) {
+ ResourceBundle bundle = Locale.getBundle(
+ "ISO4CurrenciesToDigits", Locale.getDefault()); //$NON-NLS-1$
+ currency = new Currency(currencyCode);
+
+ String defaultFractionDigits = null;
+ try {
+ defaultFractionDigits = bundle.getString(currencyCode);
+ } catch (MissingResourceException e) {
+ throw new IllegalArgumentException(
+ org.apache.harmony.luni.util.Msg.getString(
+ "K0322", currencyCode)); //$NON-NLS-1$
+ }
+ currency.defaultFractionDigits = Integer
+ .parseInt(defaultFractionDigits);
+ codesToCurrencies.put(currencyCode, currency);
+ }
+
+ return currency;
+ }
+
+ /***************************************************************************
+ * Answers the currency instance for this locale.
+ *
+ * @param locale
+ * java.util.Locale
+ * @return currency java.util.Currency
+ *
+ * @throws java.lang.IllegalArgumentException
+ * if the locale's country is not a supported ISO 3166 Country
+ */
+ public static Currency getInstance(Locale locale) {
+ String country = locale.getCountry();
+ String variant = locale.getVariant();
+ if (!variant.equals("") && currencyVars.indexOf(variant) > -1) { //$NON-NLS-1$
country = country + "_" + variant; //$NON-NLS-1$
}
- ResourceBundle bundle = Locale.getBundle(
- "ISO4Currencies", Locale.getDefault()); //$NON-NLS-1$
- String currencyCode = null;
- try {
- currencyCode = bundle.getString(country);
- } catch (MissingResourceException e) {
- throw new IllegalArgumentException(org.apache.harmony.luni.util.Msg.getString(
- "K0323", locale.toString())); //$NON-NLS-1$
- }
+ ResourceBundle bundle = Locale.getBundle(
+ "ISO4Currencies", Locale.getDefault()); //$NON-NLS-1$
+ String currencyCode = null;
+ try {
+ currencyCode = bundle.getString(country);
+ } catch (MissingResourceException e) {
+ throw new IllegalArgumentException(Msg.getString(
+ "K0323", locale.toString())); //$NON-NLS-1$
+ }
- if (currencyCode.equals("None")) {
+ if (currencyCode.equals("None")) { //$NON-NLS-1$
return null;
}
- return getInstance(currencyCode);
- }
+ return getInstance(currencyCode);
+ }
/**
* Answers this currency's ISO 4217 currency code.
*
* @return this currency's ISO 4217 currency code
*/
- public String getCurrencyCode() {
- return currencyCode;
- }
-
+ public String getCurrencyCode() {
+ return currencyCode;
+ }
+
/**
* Answers the symbol for this currency in the default locale. For instance,
* if the default locale is the US, the symbol of the US dollar is "$". For
@@ -129,66 +131,67 @@
*
* @return the symbol for this currency in the default locale
*/
- public String getSymbol() {
- return getSymbol(Locale.getDefault());
- }
-
- /***************************************************************************
- * Return the symbol for this currency in the given locale.
- * <p>
- *
- * If the locale doesn't have any countries (e.g.
- * <code>Locale.JAPANESE, new Locale("en","")</code>), currencyCode is
- * returned.
- * <p>
- * First the locale bundle is checked, if the locale has the same currency,
- * the CurrencySymbol in this locale bundle is returned.
- * <p>
- * Then a currency bundle for this locale is searched.
- * <p>
- * If a currency bundle for this locale does not exist, or there is no
- * symbol for this currency in this bundle, than <code>currencyCode</code>
- * is returned.
- * <p>
- *
- * @param locale
- * java.lang.String locale
- * @return symbol java.lang.String the representation of this Currency's
- * symbol in this locale
- */
- public String getSymbol(Locale locale) {
- if (locale.getCountry().equals("")) {
+ public String getSymbol() {
+ return getSymbol(Locale.getDefault());
+ }
+
+ /**
+ * Return the symbol for this currency in the given locale.
+ * <p>
+ *
+ * If the locale doesn't have any countries (e.g.
+ * <code>Locale.JAPANESE, new Locale("en","")</code>), currencyCode is
+ * returned.
+ * <p>
+ * First the locale bundle is checked, if the locale has the same currency,
+ * the CurrencySymbol in this locale bundle is returned.
+ * <p>
+ * Then a currency bundle for this locale is searched.
+ * <p>
+ * If a currency bundle for this locale does not exist, or there is no
+ * symbol for this currency in this bundle, than <code>currencyCode</code>
+ * is returned.
+ * <p>
+ *
+ * @param locale
+ * java.lang.String locale
+ * @return symbol java.lang.String the representation of this Currency's
+ * symbol in this locale
+ */
+ public String getSymbol(Locale locale) {
+ if (locale.getCountry().equals("")) { //$NON-NLS-1$
return currencyCode;
}
- // check in the Locale bundle first, if the local has the same currency
- ResourceBundle bundle = Locale.getBundle("Locale", locale); //$NON-NLS-1$
- if (((String) bundle.getObject("IntCurrencySymbol")).equals(currencyCode)) {
+ // check in the Locale bundle first, if the local has the same currency
+ ResourceBundle bundle = Locale.getBundle("Locale", locale); //$NON-NLS-1$
+ if (((String) bundle.getObject("IntCurrencySymbol")) //$NON-NLS-1$
+ .equals(currencyCode)) {
return (String) bundle.getObject("CurrencySymbol"); //$NON-NLS-1$
}
- // search for a Currency bundle
- bundle = null;
- try {
- bundle = Locale.getBundle("Currency", locale); //$NON-NLS-1$
- } catch (MissingResourceException e) {
- return currencyCode;
- }
-
- // is the bundle found for a different country? (for instance the
- // default locale's currency bundle)
- if (!bundle.getLocale().getCountry().equals(locale.getCountry())) {
+ // search for a Currency bundle
+ bundle = null;
+ try {
+ bundle = Locale.getBundle("Currency", locale); //$NON-NLS-1$
+ } catch (MissingResourceException e) {
return currencyCode;
}
- // check if the currency bundle for this locale
- // has an entry for this currency
- String result = (String) bundle.handleGetObject(currencyCode);
- if (result != null) {
+ // is the bundle found for a different country? (for instance the
+ // default locale's currency bundle)
+ if (!bundle.getLocale().getCountry().equals(locale.getCountry())) {
+ return currencyCode;
+ }
+
+ // check if the currency bundle for this locale
+ // has an entry for this currency
+ String result = (String) bundle.handleGetObject(currencyCode);
+ if (result != null) {
return result;
}
return currencyCode;
- }
+ }
/**
* Answers the default number of fraction digits for this currency. For
@@ -198,21 +201,21 @@
*
* @return the default number of fraction digits for this currency
*/
- public int getDefaultFractionDigits() {
- return defaultFractionDigits;
- }
+ public int getDefaultFractionDigits() {
+ return defaultFractionDigits;
+ }
/**
* Answers this currency's ISO 4217 currency code.
*
* @return this currency's ISO 4217 currency code
*/
- @Override
+ @Override
public String toString() {
- return currencyCode;
- }
+ return currencyCode;
+ }
- private Object readResolve() {
- return getInstance(currencyCode);
- }
+ private Object readResolve() {
+ return getInstance(currencyCode);
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Date.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Date.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Date.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Date.java Tue Jan 2 08:22:05 2007
@@ -17,7 +17,6 @@
package java.util;
-
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -26,6 +25,8 @@
import java.text.DateFormatSymbols;
import java.text.SimpleDateFormat;
+import org.apache.harmony.luni.internal.nls.Messages;
+
/**
* Date represents a specific moment in time, to the millisecond.
*
@@ -36,416 +37,417 @@
* @see TimeZone
*/
public class Date implements Serializable, Cloneable, Comparable<Date> {
-
- private static final long serialVersionUID = 7523967970034938905L;
+
+ private static final long serialVersionUID = 7523967970034938905L;
// Used by parse()
private static int creationYear = new Date().getYear();
-
+
private transient long milliseconds;
- /**
- * Initializes this Date instance to the current date and time.
- *
- */
- public Date() {
- this(System.currentTimeMillis());
- }
-
- /**
- * Constructs a new Date initialized to midnight in the default TimeZone on
- * the specified date.
- *
- * @param year
- * the year, 0 is 1900
- * @param month
- * the month, 0 - 11
- * @param day
- * the day of the month, 1 - 31
- *
- * @deprecated use GregorianCalendar(int, int, int)
- */
- @Deprecated
+ /**
+ * Initializes this Date instance to the current date and time.
+ *
+ */
+ public Date() {
+ this(System.currentTimeMillis());
+ }
+
+ /**
+ * Constructs a new Date initialized to midnight in the default TimeZone on
+ * the specified date.
+ *
+ * @param year
+ * the year, 0 is 1900
+ * @param month
+ * the month, 0 - 11
+ * @param day
+ * the day of the month, 1 - 31
+ *
+ * @deprecated use GregorianCalendar(int, int, int)
+ */
+ @Deprecated
public Date(int year, int month, int day) {
- GregorianCalendar cal = new GregorianCalendar(false);
- cal.set(1900 + year, month, day);
- milliseconds = cal.getTimeInMillis();
- }
-
- /**
- * Constructs a new Date initialized to the specified date and time in the
- * default TimeZone.
- *
- * @param year
- * the year, 0 is 1900
- * @param month
- * the month, 0 - 11
- * @param day
- * the day of the month, 1 - 31
- * @param hour
- * the hour of day, 0 - 23
- * @param minute
- * the minute of the hour, 0 - 59
- *
- * @deprecated use GregorianCalendar(int, int, int, int, int)
- */
- @Deprecated
+ GregorianCalendar cal = new GregorianCalendar(false);
+ cal.set(1900 + year, month, day);
+ milliseconds = cal.getTimeInMillis();
+ }
+
+ /**
+ * Constructs a new Date initialized to the specified date and time in the
+ * default TimeZone.
+ *
+ * @param year
+ * the year, 0 is 1900
+ * @param month
+ * the month, 0 - 11
+ * @param day
+ * the day of the month, 1 - 31
+ * @param hour
+ * the hour of day, 0 - 23
+ * @param minute
+ * the minute of the hour, 0 - 59
+ *
+ * @deprecated use GregorianCalendar(int, int, int, int, int)
+ */
+ @Deprecated
public Date(int year, int month, int day, int hour, int minute) {
- GregorianCalendar cal = new GregorianCalendar(false);
- cal.set(1900 + year, month, day, hour, minute);
- milliseconds = cal.getTimeInMillis();
- }
-
- /**
- * Constructs a new Date initialized to the specified date and time in the
- * default TimeZone.
- *
- * @param year
- * the year, 0 is 1900
- * @param month
- * the month, 0 - 11
- * @param day
- * the day of the month, 1 - 31
- * @param hour
- * the hour of day, 0 - 23
- * @param minute
- * the minute of the hour, 0 - 59
- * @param second
- * the second of the minute, 0 - 59
- *
- * @deprecated use GregorianCalendar(int, int, int, int, int, int)
- */
- @Deprecated
+ GregorianCalendar cal = new GregorianCalendar(false);
+ cal.set(1900 + year, month, day, hour, minute);
+ milliseconds = cal.getTimeInMillis();
+ }
+
+ /**
+ * Constructs a new Date initialized to the specified date and time in the
+ * default TimeZone.
+ *
+ * @param year
+ * the year, 0 is 1900
+ * @param month
+ * the month, 0 - 11
+ * @param day
+ * the day of the month, 1 - 31
+ * @param hour
+ * the hour of day, 0 - 23
+ * @param minute
+ * the minute of the hour, 0 - 59
+ * @param second
+ * the second of the minute, 0 - 59
+ *
+ * @deprecated use GregorianCalendar(int, int, int, int, int, int)
+ */
+ @Deprecated
public Date(int year, int month, int day, int hour, int minute, int second) {
- GregorianCalendar cal = new GregorianCalendar(false);
- cal.set(1900 + year, month, day, hour, minute, second);
- milliseconds = cal.getTimeInMillis();
- }
-
- /**
- * Initializes this Date instance using the specified millisecond value. The
- * value is the number of milliseconds since Jan. 1, 1970 GMT.
- *
- * @param milliseconds
- * the number of milliseconds since Jan. 1, 1970 GMT
- */
- public Date(long milliseconds) {
- this.setTime(milliseconds);
- }
-
- /**
- * Constructs a new Date initialized to the date and time parsed from the
- * specified String.
- *
- * @param string
- * the String to parse
- *
- * @deprecated use DateFormat
- */
- @Deprecated
+ GregorianCalendar cal = new GregorianCalendar(false);
+ cal.set(1900 + year, month, day, hour, minute, second);
+ milliseconds = cal.getTimeInMillis();
+ }
+
+ /**
+ * Initializes this Date instance using the specified millisecond value. The
+ * value is the number of milliseconds since Jan. 1, 1970 GMT.
+ *
+ * @param milliseconds
+ * the number of milliseconds since Jan. 1, 1970 GMT
+ */
+ public Date(long milliseconds) {
+ this.setTime(milliseconds);
+ }
+
+ /**
+ * Constructs a new Date initialized to the date and time parsed from the
+ * specified String.
+ *
+ * @param string
+ * the String to parse
+ *
+ * @deprecated use DateFormat
+ */
+ @Deprecated
public Date(String string) {
- milliseconds = parse(string);
- }
+ milliseconds = parse(string);
+ }
- /**
- * Answers if this Date is after the specified Date.
- *
- * @param date
- * a Date instance to compare
- * @return true if this Date is after the specified Date, false otherwise
- */
- public boolean after(Date date) {
- return milliseconds > date.milliseconds;
- }
-
- /**
- * Boolean indication of whether or not this <code>Date</code> occurs
- * earlier than the <code>Date</code> argument.
- *
- * @param date
- * a Date instance to compare
- * @return <code>true</code> if this <code>Date</code> occurs earlier
- * than <code>date</code>, otherwise <code>false</code>
- */
- public boolean before(Date date) {
- return milliseconds < date.milliseconds;
- }
-
- /**
- * Answers a new Date with the same millisecond value as this Date.
- *
- * @return a shallow copy of this Date
- *
- * @see java.lang.Cloneable
- */
- @Override
+ /**
+ * Answers if this Date is after the specified Date.
+ *
+ * @param date
+ * a Date instance to compare
+ * @return true if this Date is after the specified Date, false otherwise
+ */
+ public boolean after(Date date) {
+ return milliseconds > date.milliseconds;
+ }
+
+ /**
+ * Boolean indication of whether or not this <code>Date</code> occurs
+ * earlier than the <code>Date</code> argument.
+ *
+ * @param date
+ * a Date instance to compare
+ * @return <code>true</code> if this <code>Date</code> occurs earlier
+ * than <code>date</code>, otherwise <code>false</code>
+ */
+ public boolean before(Date date) {
+ return milliseconds < date.milliseconds;
+ }
+
+ /**
+ * Answers a new Date with the same millisecond value as this Date.
+ *
+ * @return a shallow copy of this Date
+ *
+ * @see java.lang.Cloneable
+ */
+ @Override
public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- return null;
- }
- }
-
- /**
- * Compare the receiver to the specified Date to determine the relative
- * ordering.
- *
- * @param date
- * a Date
- * @return an int < 0 if this Date is less than the specified Date, 0 if
- * they are equal, and > 0 if this Date is greater
- */
- public int compareTo(Date date) {
- if (milliseconds < date.milliseconds) {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ return null;
+ }
+ }
+
+ /**
+ * Compare the receiver to the specified Date to determine the relative
+ * ordering.
+ *
+ * @param date
+ * a Date
+ * @return an int < 0 if this Date is less than the specified Date, 0 if
+ * they are equal, and > 0 if this Date is greater
+ */
+ public int compareTo(Date date) {
+ if (milliseconds < date.milliseconds) {
return -1;
}
- if (milliseconds == date.milliseconds) {
+ if (milliseconds == date.milliseconds) {
return 0;
}
- return 1;
- }
+ return 1;
+ }
- /**
- * Compares the specified object to this Date and answer if they are equal.
- * The object must be an instance of Date and have the same millisecond
- * value.
- *
- * @param object
- * the object to compare with this object
- * @return true if the specified object is equal to this Date, false
- * otherwise
- *
- * @see #hashCode
- */
- @Override
+ /**
+ * Compares the specified object to this Date and answer if they are equal.
+ * The object must be an instance of Date and have the same millisecond
+ * value.
+ *
+ * @param object
+ * the object to compare with this object
+ * @return true if the specified object is equal to this Date, false
+ * otherwise
+ *
+ * @see #hashCode
+ */
+ @Override
public boolean equals(Object object) {
- return (object == this) || (object instanceof Date)
- && (milliseconds == ((Date) object).milliseconds);
- }
-
- /**
- * Answers the gregorian calendar day of the month for this Date object.
- *
- * @return the day of the month
- *
- * @deprecated use Calendar.get(Calendar.DATE)
- */
- @Deprecated
+ return (object == this) || (object instanceof Date)
+ && (milliseconds == ((Date) object).milliseconds);
+ }
+
+ /**
+ * Answers the gregorian calendar day of the month for this Date object.
+ *
+ * @return the day of the month
+ *
+ * @deprecated use Calendar.get(Calendar.DATE)
+ */
+ @Deprecated
public int getDate() {
- return new GregorianCalendar(milliseconds).get(Calendar.DATE);
- }
+ return new GregorianCalendar(milliseconds).get(Calendar.DATE);
+ }
- /**
- * Answers the gregorian calendar day of the week for this Date object.
- *
- * @return the day of the week
- *
- * @deprecated use Calendar.get(Calendar.DAY_OF_WEEK)
- */
- @Deprecated
+ /**
+ * Answers the gregorian calendar day of the week for this Date object.
+ *
+ * @return the day of the week
+ *
+ * @deprecated use Calendar.get(Calendar.DAY_OF_WEEK)
+ */
+ @Deprecated
public int getDay() {
- return new GregorianCalendar(milliseconds).get(Calendar.DAY_OF_WEEK) - 1;
- }
+ return new GregorianCalendar(milliseconds).get(Calendar.DAY_OF_WEEK) - 1;
+ }
- /**
- * Answers the gregorian calendar hour of the day for this Date object.
- *
- * @return the hour of the day
- *
- * @deprecated use Calendar.get(Calendar.HOUR_OF_DAY)
- */
- @Deprecated
+ /**
+ * Answers the gregorian calendar hour of the day for this Date object.
+ *
+ * @return the hour of the day
+ *
+ * @deprecated use Calendar.get(Calendar.HOUR_OF_DAY)
+ */
+ @Deprecated
public int getHours() {
- return new GregorianCalendar(milliseconds).get(Calendar.HOUR_OF_DAY);
- }
+ return new GregorianCalendar(milliseconds).get(Calendar.HOUR_OF_DAY);
+ }
- /**
- * Answers the gregorian calendar minute of the hour for this Date object.
- *
- * @return the minutes
- *
- * @deprecated use Calendar.get(Calendar.MINUTE)
- */
- @Deprecated
+ /**
+ * Answers the gregorian calendar minute of the hour for this Date object.
+ *
+ * @return the minutes
+ *
+ * @deprecated use Calendar.get(Calendar.MINUTE)
+ */
+ @Deprecated
public int getMinutes() {
- return new GregorianCalendar(milliseconds).get(Calendar.MINUTE);
- }
+ return new GregorianCalendar(milliseconds).get(Calendar.MINUTE);
+ }
- /**
- * Answers the gregorian calendar month for this Date object.
- *
- * @return the month
- *
- * @deprecated use Calendar.get(Calendar.MONTH)
- */
- @Deprecated
+ /**
+ * Answers the gregorian calendar month for this Date object.
+ *
+ * @return the month
+ *
+ * @deprecated use Calendar.get(Calendar.MONTH)
+ */
+ @Deprecated
public int getMonth() {
- return new GregorianCalendar(milliseconds).get(Calendar.MONTH);
- }
+ return new GregorianCalendar(milliseconds).get(Calendar.MONTH);
+ }
- /**
- * Answers the gregorian calendar second of the minute for this Date object.
- *
- * @return the seconds
- *
- * @deprecated use Calendar.get(Calendar.SECOND)
- */
- @Deprecated
+ /**
+ * Answers the gregorian calendar second of the minute for this Date object.
+ *
+ * @return the seconds
+ *
+ * @deprecated use Calendar.get(Calendar.SECOND)
+ */
+ @Deprecated
public int getSeconds() {
- return new GregorianCalendar(milliseconds).get(Calendar.SECOND);
- }
+ return new GregorianCalendar(milliseconds).get(Calendar.SECOND);
+ }
- /**
- * Answers this Date as a millisecond value. The value is the number of
- * milliseconds since Jan. 1, 1970 GMT.
- *
- * @return the number of milliseconds since Jan. 1, 1970 GMT.
- */
- public long getTime() {
- return milliseconds;
- }
-
- /**
- * Answers the timezone offset in minutes of the default TimeZone.
- *
- * @return the timezone offset in minutes of the default TimeZone
- *
- * @deprecated use
- * <code>(Calendar.get(Calendar.ZONE_OFFSET) + Calendar.get(Calendar.DST_OFFSET)) / 60000</code>
- */
- @Deprecated
+ /**
+ * Answers this Date as a millisecond value. The value is the number of
+ * milliseconds since Jan. 1, 1970 GMT.
+ *
+ * @return the number of milliseconds since Jan. 1, 1970 GMT.
+ */
+ public long getTime() {
+ return milliseconds;
+ }
+
+ /**
+ * Answers the timezone offset in minutes of the default TimeZone.
+ *
+ * @return the timezone offset in minutes of the default TimeZone
+ *
+ * @deprecated use
+ * <code>(Calendar.get(Calendar.ZONE_OFFSET) + Calendar.get(Calendar.DST_OFFSET)) / 60000</code>
+ */
+ @Deprecated
public int getTimezoneOffset() {
- GregorianCalendar cal = new GregorianCalendar(milliseconds);
- return -(cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / 60000;
- }
-
- /**
- * Answers the gregorian calendar year since 1900 for this Date object.
- *
- * @return the year - 1900
- *
- * @deprecated use Calendar.get(Calendar.YEAR) - 1900
- */
- @Deprecated
+ GregorianCalendar cal = new GregorianCalendar(milliseconds);
+ return -(cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / 60000;
+ }
+
+ /**
+ * Answers the gregorian calendar year since 1900 for this Date object.
+ *
+ * @return the year - 1900
+ *
+ * @deprecated use Calendar.get(Calendar.YEAR) - 1900
+ */
+ @Deprecated
public int getYear() {
- return new GregorianCalendar(milliseconds).get(Calendar.YEAR) - 1900;
- }
+ return new GregorianCalendar(milliseconds).get(Calendar.YEAR) - 1900;
+ }
- /**
- * Answers an integer hash code for the receiver. Objects which are equal
- * answer the same value for this method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
- @Override
+ /**
+ * Answers an integer hash code for the receiver. Objects which are equal
+ * answer the same value for this method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+ @Override
public int hashCode() {
- return (int) (milliseconds >>> 32) ^ (int) milliseconds;
- }
+ return (int) (milliseconds >>> 32) ^ (int) milliseconds;
+ }
- private static int parse(String string, String[] array) {
- for (int i = 0, alength = array.length, slength = string.length(); i < alength; i++) {
+ private static int parse(String string, String[] array) {
+ for (int i = 0, alength = array.length, slength = string.length(); i < alength; i++) {
if (string.regionMatches(true, 0, array[i], 0, slength)) {
return i;
}
}
- return -1;
- }
+ return -1;
+ }
- /**
- * Answers the millisecond value of the date and time parsed from the
- * specified String. Many date/time formats are recognized, including IETF
- * standard syntax, i.e. Tue, 22 Jun 1999 12:16:00 GMT-0500
- *
- * @param string
- * the String to parse
- * @return the millisecond value parsed from the String
- *
- * @deprecated use DateFormat
- */
- @Deprecated
+ /**
+ * Answers the millisecond value of the date and time parsed from the
+ * specified String. Many date/time formats are recognized, including IETF
+ * standard syntax, i.e. Tue, 22 Jun 1999 12:16:00 GMT-0500
+ *
+ * @param string
+ * the String to parse
+ * @return the millisecond value parsed from the String
+ *
+ * @deprecated use DateFormat
+ */
+ @Deprecated
public static long parse(String string) {
- if (string == null) {
- throw new IllegalArgumentException("string is null.");
- }
-
- char sign = 0;
- int commentLevel = 0;
- int offset = 0, length = string.length(), state = 0;
- int year = -1, month = -1, date = -1;
- int hour = -1, minute = -1, second = -1, zoneOffset = 0;
- boolean zone = false;
- final int PAD = 0, LETTERS = 1, NUMBERS = 2;
- StringBuffer buffer = new StringBuffer();
-
- while (offset <= length) {
- char next = offset < length ? string.charAt(offset) : '\r';
- offset++;
+ if (string == null) {
+ // luni.06=The string argument is null
+ throw new IllegalArgumentException(Messages.getString("luni.06")); //$NON-NLS-1$
+ }
+
+ char sign = 0;
+ int commentLevel = 0;
+ int offset = 0, length = string.length(), state = 0;
+ int year = -1, month = -1, date = -1;
+ int hour = -1, minute = -1, second = -1, zoneOffset = 0;
+ boolean zone = false;
+ final int PAD = 0, LETTERS = 1, NUMBERS = 2;
+ StringBuffer buffer = new StringBuffer();
+
+ while (offset <= length) {
+ char next = offset < length ? string.charAt(offset) : '\r';
+ offset++;
- if (next == '(') {
+ if (next == '(') {
commentLevel++;
}
- if (commentLevel > 0) {
- if (next == ')') {
+ if (commentLevel > 0) {
+ if (next == ')') {
commentLevel--;
}
- if (commentLevel == 0) {
+ if (commentLevel == 0) {
next = ' ';
} else {
continue;
}
- }
+ }
- int nextState = PAD;
- if ('a' <= next && next <= 'z' || 'A' <= next && next <= 'Z') {
+ int nextState = PAD;
+ if ('a' <= next && next <= 'z' || 'A' <= next && next <= 'Z') {
nextState = LETTERS;
} else if ('0' <= next && next <= '9') {
nextState = NUMBERS;
- } else if (!Character.isSpace(next) && ",+-:/".indexOf(next) == -1) {
+ } else if (!Character.isSpace(next) && ",+-:/".indexOf(next) == -1) { //$NON-NLS-1$
throw new IllegalArgumentException();
}
- if (state == NUMBERS && nextState != NUMBERS) {
- int digit = Integer.parseInt(buffer.toString());
- buffer.setLength(0);
- if (sign == '+' || sign == '-') {
- if (zoneOffset == 0) {
- zone = true;
- zoneOffset = sign == '-' ? -digit : digit;
- sign = 0;
- } else {
+ if (state == NUMBERS && nextState != NUMBERS) {
+ int digit = Integer.parseInt(buffer.toString());
+ buffer.setLength(0);
+ if (sign == '+' || sign == '-') {
+ if (zoneOffset == 0) {
+ zone = true;
+ zoneOffset = sign == '-' ? -digit : digit;
+ sign = 0;
+ } else {
throw new IllegalArgumentException();
}
- } else if (digit >= 70) {
- if (year == -1
- && (Character.isSpace(next) || next == ','
- || next == '/' || next == '\r')) {
+ } else if (digit >= 70) {
+ if (year == -1
+ && (Character.isSpace(next) || next == ','
+ || next == '/' || next == '\r')) {
year = digit;
} else {
throw new IllegalArgumentException();
}
- } else if (next == ':') {
- if (hour == -1) {
+ } else if (next == ':') {
+ if (hour == -1) {
hour = digit;
} else if (minute == -1) {
minute = digit;
} else {
throw new IllegalArgumentException();
}
- } else if (next == '/') {
- if (month == -1) {
+ } else if (next == '/') {
+ if (month == -1) {
month = digit - 1;
} else if (date == -1) {
date = digit;
} else {
throw new IllegalArgumentException();
}
- } else if (Character.isSpace(next) || next == ','
- || next == '-' || next == '\r') {
- if (hour != -1 && minute == -1) {
+ } else if (Character.isSpace(next) || next == ','
+ || next == '-' || next == '\r') {
+ if (hour != -1 && minute == -1) {
minute = digit;
} else if (minute != -1 && second == -1) {
second = digit;
@@ -456,311 +458,309 @@
} else {
throw new IllegalArgumentException();
}
- } else if (year == -1 && month != -1 && date != -1) {
+ } else if (year == -1 && month != -1 && date != -1) {
year = digit;
} else {
throw new IllegalArgumentException();
}
- } else if (state == LETTERS && nextState != LETTERS) {
- String text = buffer.toString().toUpperCase();
- buffer.setLength(0);
- if (text.length() == 1) {
+ } else if (state == LETTERS && nextState != LETTERS) {
+ String text = buffer.toString().toUpperCase();
+ buffer.setLength(0);
+ if (text.length() == 1) {
throw new IllegalArgumentException();
}
- if (text.equals("AM")) { //$NON-NLS-1$
- if (hour == 12) {
+ if (text.equals("AM")) { //$NON-NLS-1$
+ if (hour == 12) {
hour = 0;
} else if (hour < 1 || hour > 12) {
throw new IllegalArgumentException();
}
- } else if (text.equals("PM")) { //$NON-NLS-1$
- if (hour == 12) {
+ } else if (text.equals("PM")) { //$NON-NLS-1$
+ if (hour == 12) {
hour = 0;
} else if (hour < 1 || hour > 12) {
throw new IllegalArgumentException();
}
- hour += 12;
- } else {
- DateFormatSymbols symbols = new DateFormatSymbols(Locale.US);
- String[] weekdays = symbols.getWeekdays(), months = symbols
- .getMonths();
- int value;
- if (parse(text, weekdays) != -1) {/*empty*/
- } else if (month == -1
- && (month = parse(text, months)) != -1) {/*empty*/
- } else if (text.equals("GMT") || text.equals("UT") //$NON-NLS-1$ //$NON-NLS-2$
- || text.equals("UTC")) { //$NON-NLS-1$
- zone = true;
- zoneOffset = 0;
- } else if ((value = zone(text)) != 0) {
- zone = true;
- zoneOffset = value;
- } else {
+ hour += 12;
+ } else {
+ DateFormatSymbols symbols = new DateFormatSymbols(Locale.US);
+ String[] weekdays = symbols.getWeekdays(), months = symbols
+ .getMonths();
+ int value;
+ if (parse(text, weekdays) != -1) {/* empty */
+ } else if (month == -1
+ && (month = parse(text, months)) != -1) {/* empty */
+ } else if (text.equals("GMT") || text.equals("UT") //$NON-NLS-1$ //$NON-NLS-2$
+ || text.equals("UTC")) { //$NON-NLS-1$
+ zone = true;
+ zoneOffset = 0;
+ } else if ((value = zone(text)) != 0) {
+ zone = true;
+ zoneOffset = value;
+ } else {
throw new IllegalArgumentException();
}
- }
- }
+ }
+ }
- if (next == '+' || (year != -1 && next == '-')) {
+ if (next == '+' || (year != -1 && next == '-')) {
sign = next;
} else if (!Character.isSpace(next) && next != ','
- && nextState != NUMBERS) {
+ && nextState != NUMBERS) {
sign = 0;
}
- if (nextState == LETTERS || nextState == NUMBERS) {
+ if (nextState == LETTERS || nextState == NUMBERS) {
buffer.append(next);
}
- state = nextState;
- }
+ state = nextState;
+ }
- if (year != -1 && month != -1 && date != -1) {
- if (hour == -1) {
+ if (year != -1 && month != -1 && date != -1) {
+ if (hour == -1) {
hour = 0;
}
- if (minute == -1) {
+ if (minute == -1) {
minute = 0;
}
- if (second == -1) {
+ if (second == -1) {
second = 0;
}
- if (year < (creationYear - 80)) {
+ if (year < (creationYear - 80)) {
year += 2000;
} else if (year < 100) {
year += 1900;
}
- if (zone) {
- if (zoneOffset >= 24 || zoneOffset <= -24) {
- hour -= zoneOffset / 100;
- minute -= zoneOffset % 100;
- } else {
+ if (zone) {
+ if (zoneOffset >= 24 || zoneOffset <= -24) {
+ hour -= zoneOffset / 100;
+ minute -= zoneOffset % 100;
+ } else {
hour -= zoneOffset;
}
- return UTC(year - 1900, month, date, hour, minute, second);
- }
+ return UTC(year - 1900, month, date, hour, minute, second);
+ }
return new Date(year - 1900, month, date, hour, minute, second)
- .getTime();
- }
- throw new IllegalArgumentException();
- }
-
- /**
- * Sets the gregorian calendar day of the month for this Date object.
- *
- * @param day
- * the day of the month
- *
- * @deprecated use Calendar.set(Calendar.DATE, day)
- */
- @Deprecated
+ .getTime();
+ }
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * Sets the gregorian calendar day of the month for this Date object.
+ *
+ * @param day
+ * the day of the month
+ *
+ * @deprecated use Calendar.set(Calendar.DATE, day)
+ */
+ @Deprecated
public void setDate(int day) {
- GregorianCalendar cal = new GregorianCalendar(milliseconds);
- cal.set(Calendar.DATE, day);
- milliseconds = cal.getTimeInMillis();
- }
-
- /**
- * Sets the gregorian calendar hour of the day for this Date object.
- *
- * @param hour
- * the hour of the day
- *
- * @deprecated use Calendar.set(Calendar.HOUR_OF_DAY, hour)
- */
- @Deprecated
+ GregorianCalendar cal = new GregorianCalendar(milliseconds);
+ cal.set(Calendar.DATE, day);
+ milliseconds = cal.getTimeInMillis();
+ }
+
+ /**
+ * Sets the gregorian calendar hour of the day for this Date object.
+ *
+ * @param hour
+ * the hour of the day
+ *
+ * @deprecated use Calendar.set(Calendar.HOUR_OF_DAY, hour)
+ */
+ @Deprecated
public void setHours(int hour) {
- GregorianCalendar cal = new GregorianCalendar(milliseconds);
- cal.set(Calendar.HOUR_OF_DAY, hour);
- milliseconds = cal.getTimeInMillis();
- }
-
- /**
- * Sets the gregorian calendar minute of the hour for this Date object.
- *
- * @param minute
- * the minutes
- *
- * @deprecated use Calendar.set(Calendar.MINUTE, minute)
- */
- @Deprecated
+ GregorianCalendar cal = new GregorianCalendar(milliseconds);
+ cal.set(Calendar.HOUR_OF_DAY, hour);
+ milliseconds = cal.getTimeInMillis();
+ }
+
+ /**
+ * Sets the gregorian calendar minute of the hour for this Date object.
+ *
+ * @param minute
+ * the minutes
+ *
+ * @deprecated use Calendar.set(Calendar.MINUTE, minute)
+ */
+ @Deprecated
public void setMinutes(int minute) {
- GregorianCalendar cal = new GregorianCalendar(milliseconds);
- cal.set(Calendar.MINUTE, minute);
- milliseconds = cal.getTimeInMillis();
- }
-
- /**
- * Sets the gregorian calendar month for this Date object.
- *
- * @param month
- * the month
- *
- * @deprecated use Calendar.set(Calendar.MONTH, month)
- */
- @Deprecated
+ GregorianCalendar cal = new GregorianCalendar(milliseconds);
+ cal.set(Calendar.MINUTE, minute);
+ milliseconds = cal.getTimeInMillis();
+ }
+
+ /**
+ * Sets the gregorian calendar month for this Date object.
+ *
+ * @param month
+ * the month
+ *
+ * @deprecated use Calendar.set(Calendar.MONTH, month)
+ */
+ @Deprecated
public void setMonth(int month) {
- GregorianCalendar cal = new GregorianCalendar(milliseconds);
- cal.set(Calendar.MONTH, month);
- milliseconds = cal.getTimeInMillis();
- }
-
- /**
- * Sets the gregorian calendar second of the minute for this Date object.
- *
- * @param second
- * the seconds
- *
- * @deprecated use Calendar.set(Calendar.SECOND, second)
- */
- @Deprecated
+ GregorianCalendar cal = new GregorianCalendar(milliseconds);
+ cal.set(Calendar.MONTH, month);
+ milliseconds = cal.getTimeInMillis();
+ }
+
+ /**
+ * Sets the gregorian calendar second of the minute for this Date object.
+ *
+ * @param second
+ * the seconds
+ *
+ * @deprecated use Calendar.set(Calendar.SECOND, second)
+ */
+ @Deprecated
public void setSeconds(int second) {
- GregorianCalendar cal = new GregorianCalendar(milliseconds);
- cal.set(Calendar.SECOND, second);
- milliseconds = cal.getTimeInMillis();
- }
-
- /**
- * Sets this Date to the specified millisecond value. The value is the
- * number of milliseconds since Jan. 1, 1970 GMT.
- *
- * @param milliseconds
- * the number of milliseconds since Jan. 1, 1970 GMT.
- */
- public void setTime(long milliseconds) {
- this.milliseconds = milliseconds;
- }
-
- /**
- * Sets the gregorian calendar year since 1900 for this Date object.
- *
- * @param year
- * the year since 1900
- *
- * @deprecated use Calendar.set(Calendar.YEAR, year + 1900)
- */
- @Deprecated
+ GregorianCalendar cal = new GregorianCalendar(milliseconds);
+ cal.set(Calendar.SECOND, second);
+ milliseconds = cal.getTimeInMillis();
+ }
+
+ /**
+ * Sets this Date to the specified millisecond value. The value is the
+ * number of milliseconds since Jan. 1, 1970 GMT.
+ *
+ * @param milliseconds
+ * the number of milliseconds since Jan. 1, 1970 GMT.
+ */
+ public void setTime(long milliseconds) {
+ this.milliseconds = milliseconds;
+ }
+
+ /**
+ * Sets the gregorian calendar year since 1900 for this Date object.
+ *
+ * @param year
+ * the year since 1900
+ *
+ * @deprecated use Calendar.set(Calendar.YEAR, year + 1900)
+ */
+ @Deprecated
public void setYear(int year) {
- GregorianCalendar cal = new GregorianCalendar(milliseconds);
- cal.set(Calendar.YEAR, year + 1900);
- milliseconds = cal.getTimeInMillis();
- }
-
- /**
- * Answers the string representation of this Date in GMT in the format: 22
- * Jun 1999 13:02:00 GMT
- *
- * @return the string representation of this Date in GMT
- *
- * @deprecated use DateFormat
- */
- @Deprecated
+ GregorianCalendar cal = new GregorianCalendar(milliseconds);
+ cal.set(Calendar.YEAR, year + 1900);
+ milliseconds = cal.getTimeInMillis();
+ }
+
+ /**
+ * Answers the string representation of this Date in GMT in the format: 22
+ * Jun 1999 13:02:00 GMT
+ *
+ * @return the string representation of this Date in GMT
+ *
+ * @deprecated use DateFormat
+ */
+ @Deprecated
public String toGMTString() {
- SimpleDateFormat format1 = new SimpleDateFormat(
- "d MMM ", Locale.US); //$NON-NLS-1$
- SimpleDateFormat format2 = new SimpleDateFormat(
- " HH:mm:ss 'GMT'", Locale.US); //$NON-NLS-1$
- TimeZone gmtZone = TimeZone.getTimeZone("GMT"); //$NON-NLS-1$
- format1.setTimeZone(gmtZone);
- format2.setTimeZone(gmtZone);
- GregorianCalendar gc = new GregorianCalendar(gmtZone);
- gc.setTimeInMillis(milliseconds);
- return format1.format(this) +
- gc.get(Calendar.YEAR) +
- format2.format(this);
- }
-
- /**
- * Answers the string representation of this Date for the current Locale.
- *
- * @return the string representation of this Date for the current Locale
- *
- * @deprecated use DateFormat
- */
- @Deprecated
+ SimpleDateFormat format1 = new SimpleDateFormat("d MMM ", Locale.US); //$NON-NLS-1$
+ SimpleDateFormat format2 = new SimpleDateFormat(
+ " HH:mm:ss 'GMT'", Locale.US); //$NON-NLS-1$
+ TimeZone gmtZone = TimeZone.getTimeZone("GMT"); //$NON-NLS-1$
+ format1.setTimeZone(gmtZone);
+ format2.setTimeZone(gmtZone);
+ GregorianCalendar gc = new GregorianCalendar(gmtZone);
+ gc.setTimeInMillis(milliseconds);
+ return format1.format(this) + gc.get(Calendar.YEAR)
+ + format2.format(this);
+ }
+
+ /**
+ * Answers the string representation of this Date for the current Locale.
+ *
+ * @return the string representation of this Date for the current Locale
+ *
+ * @deprecated use DateFormat
+ */
+ @Deprecated
public String toLocaleString() {
- return DateFormat.getDateTimeInstance().format(this);
- }
+ return DateFormat.getDateTimeInstance().format(this);
+ }
- /**
- * Answers the string representation of this Date in the format: Tue Jun 22
- * 13:07:00 GMT 1999
- *
- * @return the string representation of this Date
- */
- @Override
+ /**
+ * Answers the string representation of this Date in the format: Tue Jun 22
+ * 13:07:00 GMT 1999
+ *
+ * @return the string representation of this Date
+ */
+ @Override
public String toString() {
- return new SimpleDateFormat("E MMM dd HH:mm:ss z ", Locale.US) //$NON-NLS-1$
- .format(this) +
- new GregorianCalendar(milliseconds).get(Calendar.YEAR);
- }
-
- /**
- * Answers the millisecond value of the specified date and time in GMT.
- *
- * @param year
- * the year, 0 is 1900
- * @param month
- * the month, 0 - 11
- * @param day
- * the day of the month, 1 - 31
- * @param hour
- * the hour of day, 0 - 23
- * @param minute
- * the minute of the hour, 0 - 59
- * @param second
- * the second of the minute, 0 - 59
- * @return long
- *
- * @deprecated use: <code>
- * Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
- * cal.set(year + 1900, month, day, hour, minute, second);
- * cal.getTime().getTime();</code>
- */
- @Deprecated
+ return new SimpleDateFormat("E MMM dd HH:mm:ss z ", Locale.US) //$NON-NLS-1$
+ .format(this)
+ + new GregorianCalendar(milliseconds).get(Calendar.YEAR);
+ }
+
+ /**
+ * Answers the millisecond value of the specified date and time in GMT.
+ *
+ * @param year
+ * the year, 0 is 1900
+ * @param month
+ * the month, 0 - 11
+ * @param day
+ * the day of the month, 1 - 31
+ * @param hour
+ * the hour of day, 0 - 23
+ * @param minute
+ * the minute of the hour, 0 - 59
+ * @param second
+ * the second of the minute, 0 - 59
+ * @return long
+ *
+ * @deprecated use: <code>
+ * Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
+ * cal.set(year + 1900, month, day, hour, minute, second);
+ * cal.getTime().getTime();</code>
+ */
+ @Deprecated
public static long UTC(int year, int month, int day, int hour, int minute,
- int second) {
- GregorianCalendar cal = new GregorianCalendar(false);
- cal.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$
- cal.set(1900 + year, month, day, hour, minute, second);
- return cal.getTimeInMillis();
- }
+ int second) {
+ GregorianCalendar cal = new GregorianCalendar(false);
+ cal.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$
+ cal.set(1900 + year, month, day, hour, minute, second);
+ return cal.getTimeInMillis();
+ }
- private static int zone(String text) {
- if (text.equals("EST")) {
+ private static int zone(String text) {
+ if (text.equals("EST")) { //$NON-NLS-1$
return -5;
}
- if (text.equals("EDT")) {
+ if (text.equals("EDT")) { //$NON-NLS-1$
return -4;
}
- if (text.equals("CST")) {
+ if (text.equals("CST")) { //$NON-NLS-1$
return -6;
}
- if (text.equals("CDT")) {
+ if (text.equals("CDT")) { //$NON-NLS-1$
return -5;
}
- if (text.equals("MST")) {
+ if (text.equals("MST")) { //$NON-NLS-1$
return -7;
}
- if (text.equals("MDT")) {
+ if (text.equals("MDT")) { //$NON-NLS-1$
return -6;
}
- if (text.equals("PST")) {
+ if (text.equals("PST")) { //$NON-NLS-1$
return -8;
}
- if (text.equals("PDT")) {
+ if (text.equals("PDT")) { //$NON-NLS-1$
return -7;
}
- return 0;
- }
+ return 0;
+ }
- private void writeObject(ObjectOutputStream stream) throws IOException {
- stream.defaultWriteObject();
- stream.writeLong(getTime());
- }
-
- private void readObject(ObjectInputStream stream) throws IOException,
- ClassNotFoundException {
- stream.defaultReadObject();
- setTime(stream.readLong());
- }
+ private void writeObject(ObjectOutputStream stream) throws IOException {
+ stream.defaultWriteObject();
+ stream.writeLong(getTime());
+ }
+
+ private void readObject(ObjectInputStream stream) throws IOException,
+ ClassNotFoundException {
+ stream.defaultReadObject();
+ setTime(stream.readLong());
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/DuplicateFormatFlagsException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/DuplicateFormatFlagsException.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/DuplicateFormatFlagsException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/DuplicateFormatFlagsException.java Tue Jan 2 08:22:05 2007
@@ -21,6 +21,7 @@
* out in the format specifier.
*/
public class DuplicateFormatFlagsException extends IllegalFormatException {
+
private static final long serialVersionUID = 18890531L;
private String flags;
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/EnumMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/EnumMap.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/EnumMap.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/EnumMap.java Tue Jan 2 08:22:05 2007
@@ -72,8 +72,8 @@
@Override
public int hashCode() {
- return (enumMap.keys[ordinal] == null ? 0
- : enumMap.keys[ordinal].hashCode())
+ return (enumMap.keys[ordinal] == null ? 0 : enumMap.keys[ordinal]
+ .hashCode())
^ (enumMap.values[ordinal] == null ? 0
: enumMap.values[ordinal].hashCode());
}
@@ -218,8 +218,8 @@
}
}
- private static class EnumMapValueCollection<KT extends Enum<KT>, VT> extends
- AbstractCollection<VT> {
+ private static class EnumMapValueCollection<KT extends Enum<KT>, VT>
+ extends AbstractCollection<VT> {
private final EnumMap<KT, VT> enumMap;
EnumMapValueCollection(EnumMap<KT, VT> em) {
@@ -355,14 +355,14 @@
int index = 0;
Object[] entryArray = array;
if (size > array.length) {
- Class clazz = array.getClass().getComponentType();
+ Class<?> clazz = array.getClass().getComponentType();
entryArray = (Object[]) Array.newInstance(clazz, size);
}
- Iterator iter = iterator();
+ Iterator<Map.Entry<KT, VT>> iter = iterator();
for (; index < size; index++) {
- Map.Entry<KT, VT> entry = (Map.Entry<KT, VT>) iter.next();
- entryArray[index] = new MapEntry<KT, VT>((KT) entry.getKey(),
- (VT) entry.getValue());
+ Map.Entry<KT, VT> entry = iter.next();
+ entryArray[index] = new MapEntry<KT, VT>(entry.getKey(), entry
+ .getValue());
}
if (index < array.length) {
entryArray[index] = null;
@@ -419,10 +419,10 @@
}
Iterator<K> iter = map.keySet().iterator();
K enumKey = iter.next();
- Class clazz=enumKey.getClass();
- if(clazz.isEnum()){
+ Class clazz = enumKey.getClass();
+ if (clazz.isEnum()) {
initialization(clazz);
- }else{
+ } else {
initialization(clazz.getSuperclass());
}
putAllImpl(map);
@@ -533,8 +533,8 @@
if (keyType != enumMap.keyType || size() != enumMap.size()) {
return false;
}
- return Arrays.equals(hasMapping, enumMap.hasMapping) &&
- Arrays.equals(values, enumMap.values);
+ return Arrays.equals(hasMapping, enumMap.hasMapping)
+ && Arrays.equals(values, enumMap.values);
}
/**
@@ -588,7 +588,7 @@
@Override
@SuppressWarnings("unchecked")
public V put(K key, V value) {
- return putImpl(key,value);
+ return putImpl(key, value);
}
/**
@@ -676,9 +676,9 @@
private void writeObject(ObjectOutputStream stream) throws IOException {
stream.defaultWriteObject();
stream.writeInt(mappingsCount);
- Iterator iterator = entrySet().iterator();
+ Iterator<Map.Entry<K, V>> iterator = entrySet().iterator();
while (iterator.hasNext()) {
- Map.Entry<K, V> entry = (Map.Entry<K, V>) iterator.next();
+ Map.Entry<K, V> entry = iterator.next();
stream.writeObject(entry.getKey());
stream.writeObject(entry.getValue());
}
@@ -692,7 +692,7 @@
}
@SuppressWarnings("unchecked")
- private void initialization(EnumMap enumMap){
+ private void initialization(EnumMap enumMap) {
keyType = enumMap.keyType;
keys = enumMap.keys;
enumSize = enumMap.enumSize;
@@ -700,7 +700,7 @@
hasMapping = enumMap.hasMapping.clone();
mappingsCount = enumMap.mappingsCount;
}
-
+
private void initialization(Class<K> type) {
keyType = type;
keys = keyType.getEnumConstants();
@@ -708,16 +708,16 @@
values = new Object[enumSize];
hasMapping = new boolean[enumSize];
}
-
+
@SuppressWarnings("unchecked")
- private void putAllImpl(Map map){
+ private void putAllImpl(Map map) {
Iterator iter = map.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
putImpl((K) entry.getKey(), (V) entry.getValue());
}
}
-
+
@SuppressWarnings("unchecked")
private V putImpl(K key, V value) {
if (null == key) {
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/EnumSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/EnumSet.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/EnumSet.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/EnumSet.java Tue Jan 2 08:22:05 2007
@@ -21,7 +21,7 @@
implements Cloneable, Serializable {
private static final long serialVersionUID = 4782406773684236311L;
-
+
final Class<E> elementClass;
EnumSet(Class<E> cls) {
@@ -127,7 +127,7 @@
set.complement();
return set;
}
-
+
abstract void complement();
/**
@@ -283,7 +283,7 @@
set.setRange(start, end);
return set;
}
-
+
abstract void setRange(E start, E end);
/**
@@ -293,6 +293,7 @@
* @return a new enum set with the same elements as those contained in this
* enum set
*/
+ @SuppressWarnings("unchecked")
@Override
public EnumSet<E> clone() {
try {
@@ -302,14 +303,14 @@
return null;
}
}
-
+
@SuppressWarnings("unchecked")
boolean isValidType(Class cls) {
return cls == elementClass || cls.getSuperclass() == elementClass;
}
-
+
private static class SerializationProxy<E extends Enum<E>> implements
- Serializable {
+ Serializable {
private static final long serialVersionUID = 362491234563181265L;
@@ -325,7 +326,7 @@
return set;
}
}
-
+
@SuppressWarnings("unchecked")
Object writeReplace() {
SerializationProxy proxy = new SerializationProxy();