harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r415066 [1/2] - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/
Date Sat, 17 Jun 2006 21:39:54 GMT
Author: ndbeyer
Date: Sat Jun 17 14:39:53 2006
New Revision: 415066

URL: http://svn.apache.org/viewvc?rev=415066&view=rev
Log:
Code cleanup; generification, spellings, etc

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Formatter.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/GregorianCalendar.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/IdentityHashMap.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ListResourceBundle.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/PropertyPermissionCollection.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Vector.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Formatter.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Formatter.java?rev=415066&r1=415065&r2=415066&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Formatter.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Formatter.java Sat Jun 17 14:39:53 2006
@@ -35,14 +35,14 @@
 /**
  * Formatter provides the method to give out formatted string just like the
  * printf-style. Layout,alignment and other format flags are provided to format
- * numeric,string and datetime as well as locale-specified formats applied.
+ * numeric,string and date/time as well as locale-specified formats applied.
  * Besides primitive types, formatter also support some java object types such
  * as BigInteger,BigDecimal and Calendar. Customized formatting is provided
  * through the Formattable interface.
  * 
  * The class is not multi-threaded safe. The responsibility to maintain thread
  * safety is the user's job.
- * 
+ * @since 1.5
  */
 public final class Formatter implements Closeable, Flushable {
 
@@ -416,7 +416,7 @@
     }
 
     /**
-     * Flushes the formatter. If the output destination is flushable, then the
+     * Flushes the formatter. If the output destination is {@link Flushable}, then the
      * method flush() will be called on that destination.
      * 
      * @throws FormatterClosedException
@@ -434,7 +434,7 @@
     }
 
     /**
-     * Closes the formatter. If the output destination is Closeable, then the
+     * Closes the formatter. If the output destination is {@link Closeable}, then the
      * method close() will be called on that destination.
      * 
      * If the formatter has been closed, then calling the close will have no
@@ -480,7 +480,7 @@
      * @throws IllegalFormatException
      *             If the format string is illegal or incompatible with the
      *             arguments or the arguments are less than those required by
-     *             the format string or any other illegal situcation.
+     *             the format string or any other illegal situation.
      * @throws FormatterClosedException
      *             If the formatter has been closed.
      */
@@ -493,7 +493,7 @@
      * 
      * @param l
      *            The locale used in the method. If locale is null, then no
-     *            localization will be applied. This param does not influence
+     *            localization will be applied. This parameter does not influence
      *            the locale specified during construction.
      * @param format
      *            A format string.
@@ -505,7 +505,7 @@
      * @throws IllegalFormatException
      *             If the format string is illegal or incompatible with the
      *             arguments or the arguments are less than those required by
-     *             the format string or any other illegal situcation.
+     *             the format string or any other illegal situation.
      * @throws FormatterClosedException
      *             If the formatter has been closed.
      */
@@ -589,7 +589,7 @@
      * includes the conversion type, flags, width, precision and the argument
      * index as well as the plainText that contains the whole format string used
      * as the result for output if necessary. Besides, the string for flags is
-     * recorded to construct corresponding FormatExceptions if neccessary.
+     * recorded to construct corresponding FormatExceptions if necessary.
      */
     private static class FormatToken {
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/GregorianCalendar.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/GregorianCalendar.java?rev=415066&r1=415065&r2=415066&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/GregorianCalendar.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/GregorianCalendar.java Sat Jun 17 14:39:53 2006
@@ -21,7 +21,7 @@
 
 /**
  * GregorianCalendar provides the conversion between Dates and integer calendar
- * fields, such as the month, year or minute, for the gregorian calendar. See
+ * fields, such as the month, year or minute, for the Gregorian calendar. See
  * Calendar for the defined fields.
  * 
  * @see Calendar
@@ -32,13 +32,21 @@
 
 	private static final long serialVersionUID = -8125100834729963327L;
 
-	public final static int BC = 0, AD = 1;
+	/**
+	 * Value for the BC era.
+	 */
+	public static final int BC = 0;
+    
+    /**
+     * Value for the AD era.
+     */
+    public static final int AD = 1;
 
 	private long gregorianCutover = -12219292800000l;
 
-	transient private int changeYear = 1582;
+	private transient int changeYear = 1582;
 
-	transient private int julianSkew = ((changeYear - 2000) / 400)
+	private transient int julianSkew = ((changeYear - 2000) / 400)
 			+ julianError() - ((changeYear - 2000) / 100);
 
 	static byte[] DaysInMonth = new byte[] { 31, 28, 31, 30, 31, 30, 31, 31,
@@ -56,7 +64,7 @@
 	private static int[] leastMaximums = new int[] { 1, 292269054, 11, 52, 4,
 			28, 365, 7, 4, 1, 11, 23, 59, 59, 999, 43200000, 3600000 };
 
-	private boolean isCached = false;
+	private boolean isCached;
 
 	private int cachedFields[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 
@@ -64,10 +72,6 @@
 
 	private long lastMidnightMillis = 0L;
 
-	private boolean dstOffsetForwardAdjustment = false;
-
-	private boolean dstOffsetBackwardAdjustment = false;
-
 	/**
 	 * Constructs a new GregorianCalendar initialized to the current date and
 	 * time.
@@ -194,22 +198,26 @@
 	 *                when the specified field is DST_OFFSET or ZONE_OFFSET.
 	 */
 	public void add(int field, int value) {
-		if (value == 0)
-			return;
-		if (field < 0 || field >= ZONE_OFFSET)
-			throw new IllegalArgumentException();
+		if (value == 0) {
+            return;
+        }
+		if (field < 0 || field >= ZONE_OFFSET) {
+            throw new IllegalArgumentException();
+        }
 
 		isCached = false;
 
 		if (field == ERA) {
 			complete();
 			if (fields[ERA] == AD) {
-				if (value >= 0)
-					return;
+				if (value >= 0) {
+                    return;
+                }
 				set(ERA, BC);
 			} else {
-				if (value <= 0)
-					return;
+				if (value <= 0) {
+                    return;
+                }
 				set(ERA, AD);
 			}
 			complete();
@@ -223,14 +231,16 @@
 				if (month < 0) {
 					value = (month - 11) / 12;
 					month = 12 + (month % 12);
-				} else
-					value = month / 12;
+				} else {
+                    value = month / 12;
+                }
 				set(MONTH, month % 12);
 			}
 			set(YEAR, fields[YEAR] + value);
 			int days = daysInMonth(isLeapYear(fields[YEAR]), fields[MONTH]);
-			if (fields[DATE] > days)
-				set(DATE, days);
+			if (fields[DATE] > days) {
+                set(DATE, days);
+            }
 			complete();
 			return;
 		}
@@ -271,8 +281,9 @@
 			time += value * multiplier;
 			int newOffset = getOffset(time + zoneOffset);
 			// Adjust for moving over a DST boundary
-			if (newOffset != offset)
-				time += offset - newOffset;
+			if (newOffset != offset) {
+                time += offset - newOffset;
+            }
 		}
 		areFieldsSet = false;
 		complete();
@@ -285,7 +296,7 @@
      */
     public Object clone(){
         GregorianCalendar thisClone = (GregorianCalendar)super.clone();
-        thisClone.cachedFields = (int[])cachedFields.clone();
+        thisClone.cachedFields = cachedFields.clone();
         return thisClone;
     }
 
@@ -318,8 +329,9 @@
 		fields[DAY_OF_WEEK] = mod7(days - 3) + 1;
 		int dstOffset = fields[YEAR] <= 0 ? 0 : getTimeZone().getOffset(AD,
 				fields[YEAR], month, date, fields[DAY_OF_WEEK], millis);
-		if (fields[YEAR] > 0)
-			dstOffset -= zoneOffset;
+		if (fields[YEAR] > 0) {
+            dstOffset -= zoneOffset;
+        }
 		fields[DST_OFFSET] = dstOffset;
 		if (dstOffset != 0) {
 			long oldDays = days;
@@ -360,8 +372,9 @@
 		if (fields[YEAR] <= 0) {
 			fields[ERA] = BC;
 			fields[YEAR] = -fields[YEAR] + 1;
-		} else
-			fields[ERA] = AD;
+		} else {
+            fields[ERA] = AD;
+        }
 		fields[MONTH] = month;
 		fields[DATE] = date;
 		fields[DAY_OF_WEEK_IN_MONTH] = (date - 1) / 7 + 1;
@@ -424,10 +437,11 @@
 		int offset = zoneOffset + dstOffset;
 		long newTime = time + offset;
 
-		if (time > 0L && newTime < 0L && offset > 0)
-			newTime = 0x7fffffffffffffffL;
-		else if (time < 0L && newTime > 0L && offset < 0)
-			newTime = 0x8000000000000000L;
+		if (time > 0L && newTime < 0L && offset > 0) {
+            newTime = 0x7fffffffffffffffL;
+        } else if (time < 0L && newTime > 0L && offset < 0) {
+            newTime = 0x8000000000000000L;
+        }
 
 		if (isCached) {
 			if (millis < 0) {
@@ -462,18 +476,21 @@
 				newTimeAdjusted += (dstOffset == 0) ? dstSavings : -dstSavings;
 			}
 
-			if (newTime > 0L && newTimeAdjusted < 0L && dstOffset == 0)
-				newTimeAdjusted = 0x7fffffffffffffffL;
-			else if (newTime < 0L && newTimeAdjusted > 0L && dstOffset != 0)
-				newTimeAdjusted = 0x8000000000000000L;
+			if (newTime > 0L && newTimeAdjusted < 0L && dstOffset == 0) {
+                newTimeAdjusted = 0x7fffffffffffffffL;
+            } else if (newTime < 0L && newTimeAdjusted > 0L && dstOffset != 0) {
+                newTimeAdjusted = 0x8000000000000000L;
+            }
 
 			cachedFieldsCheckAndGet(time, newTime, newTimeAdjusted,
 					savedMillis, zoneOffset);
-		} else
-			fullFieldsCalc(time, savedMillis, zoneOffset);
+		} else {
+            fullFieldsCalc(time, savedMillis, zoneOffset);
+        }
 
-		for (int i = 0; i < FIELD_COUNT; i++)
-			isSet[i] = true;
+		for (int i = 0; i < FIELD_COUNT; i++) {
+            isSet[i] = true;
+        }
 
 		// Caching
 		if (!isCached
@@ -517,67 +534,86 @@
 	protected void computeTime() {
 		if (!isLenient()) {
 			if (isSet[HOUR_OF_DAY]) {
-				if (fields[HOUR_OF_DAY] < 0 || fields[HOUR_OF_DAY] > 23)
-					throw new IllegalArgumentException();
-			} else if (isSet[HOUR] && (fields[HOUR] < 0 || fields[HOUR] > 11))
-				throw new IllegalArgumentException();
-			if (isSet[MINUTE] && (fields[MINUTE] < 0 || fields[MINUTE] > 59))
-				throw new IllegalArgumentException();
-			if (isSet[SECOND] && (fields[SECOND] < 0 || fields[SECOND] > 59))
-				throw new IllegalArgumentException();
+				if (fields[HOUR_OF_DAY] < 0 || fields[HOUR_OF_DAY] > 23) {
+                    throw new IllegalArgumentException();
+                }
+			} else if (isSet[HOUR] && (fields[HOUR] < 0 || fields[HOUR] > 11)) {
+                throw new IllegalArgumentException();
+            }
+			if (isSet[MINUTE] && (fields[MINUTE] < 0 || fields[MINUTE] > 59)) {
+                throw new IllegalArgumentException();
+            }
+			if (isSet[SECOND] && (fields[SECOND] < 0 || fields[SECOND] > 59)) {
+                throw new IllegalArgumentException();
+            }
 			if (isSet[MILLISECOND]
-					&& (fields[MILLISECOND] < 0 || fields[MILLISECOND] > 999))
-				throw new IllegalArgumentException();
+					&& (fields[MILLISECOND] < 0 || fields[MILLISECOND] > 999)) {
+                throw new IllegalArgumentException();
+            }
 			if (isSet[WEEK_OF_YEAR]
-					&& (fields[WEEK_OF_YEAR] < 1 || fields[WEEK_OF_YEAR] > 53))
-				throw new IllegalArgumentException();
+					&& (fields[WEEK_OF_YEAR] < 1 || fields[WEEK_OF_YEAR] > 53)) {
+                throw new IllegalArgumentException();
+            }
 			if (isSet[DAY_OF_WEEK]
-					&& (fields[DAY_OF_WEEK] < 1 || fields[DAY_OF_WEEK] > 7))
-				throw new IllegalArgumentException();
+					&& (fields[DAY_OF_WEEK] < 1 || fields[DAY_OF_WEEK] > 7)) {
+                throw new IllegalArgumentException();
+            }
 			if (isSet[DAY_OF_WEEK_IN_MONTH]
-					&& (fields[DAY_OF_WEEK_IN_MONTH] < 1 || fields[DAY_OF_WEEK_IN_MONTH] > 6))
-				throw new IllegalArgumentException();
+					&& (fields[DAY_OF_WEEK_IN_MONTH] < 1 || fields[DAY_OF_WEEK_IN_MONTH] > 6)) {
+                throw new IllegalArgumentException();
+            }
 			if (isSet[WEEK_OF_MONTH]
-					&& (fields[WEEK_OF_MONTH] < 1 || fields[WEEK_OF_MONTH] > 6))
-				throw new IllegalArgumentException();
-			if (isSet[AM_PM] && fields[AM_PM] != AM && fields[AM_PM] != PM)
-				throw new IllegalArgumentException();
-			if (isSet[HOUR] && (fields[HOUR] < 0 || fields[HOUR] > 11))
-				throw new IllegalArgumentException();
+					&& (fields[WEEK_OF_MONTH] < 1 || fields[WEEK_OF_MONTH] > 6)) {
+                throw new IllegalArgumentException();
+            }
+			if (isSet[AM_PM] && fields[AM_PM] != AM && fields[AM_PM] != PM) {
+                throw new IllegalArgumentException();
+            }
+			if (isSet[HOUR] && (fields[HOUR] < 0 || fields[HOUR] > 11)) {
+                throw new IllegalArgumentException();
+            }
 			if (isSet[YEAR]) {
 				if (isSet[ERA] && fields[ERA] == BC
-						&& (fields[YEAR] < 1 || fields[YEAR] > 292269054))
-					throw new IllegalArgumentException();
-				else if (fields[YEAR] < 1 || fields[YEAR] > 292278994)
-					throw new IllegalArgumentException();
+						&& (fields[YEAR] < 1 || fields[YEAR] > 292269054)) {
+                    throw new IllegalArgumentException();
+                } else if (fields[YEAR] < 1 || fields[YEAR] > 292278994) {
+                    throw new IllegalArgumentException();
+                }
 			}
-			if (isSet[MONTH] && (fields[MONTH] < 0 || fields[MONTH] > 11))
-				throw new IllegalArgumentException();
+			if (isSet[MONTH] && (fields[MONTH] < 0 || fields[MONTH] > 11)) {
+                throw new IllegalArgumentException();
+            }
 		}
 
 		long timeVal;
 		int hour = 0;
-		if (isSet[HOUR_OF_DAY] && lastTimeFieldSet != HOUR)
-			hour = fields[HOUR_OF_DAY];
-		else if (isSet[HOUR])
-			hour = (fields[AM_PM] * 12) + fields[HOUR];
+		if (isSet[HOUR_OF_DAY] && lastTimeFieldSet != HOUR) {
+            hour = fields[HOUR_OF_DAY];
+        } else if (isSet[HOUR]) {
+            hour = (fields[AM_PM] * 12) + fields[HOUR];
+        }
 		timeVal = hour * 3600000;
 
-		if (isSet[MINUTE])
-			timeVal += fields[MINUTE] * 60000;
-		if (isSet[SECOND])
-			timeVal += fields[SECOND] * 1000;
-		if (isSet[MILLISECOND])
-			timeVal += fields[MILLISECOND];
+		if (isSet[MINUTE]) {
+            timeVal += fields[MINUTE] * 60000;
+        }
+		if (isSet[SECOND]) {
+            timeVal += fields[SECOND] * 1000;
+        }
+		if (isSet[MILLISECOND]) {
+            timeVal += fields[MILLISECOND];
+        }
 
 		long days;
 		int year = isSet[YEAR] ? fields[YEAR] : 1970;
 		if (isSet[ERA]) {
 			// Always test for valid ERA, even if the Calendar is lenient
-			if (fields[ERA] != BC && fields[ERA] != AD)
-				throw new IllegalArgumentException();
-			if (fields[ERA] == BC)
-				year = 1 - year;
+			if (fields[ERA] != BC && fields[ERA] != AD) {
+                throw new IllegalArgumentException();
+            }
+			if (fields[ERA] == BC) {
+                year = 1 - year;
+            }
 		}
 
 		boolean weekMonthSet = isSet[WEEK_OF_MONTH]
@@ -586,11 +622,12 @@
 				&& lastDateFieldSet != DAY_OF_YEAR;
 		if (useMonth
 				&& (lastDateFieldSet == DAY_OF_WEEK || lastDateFieldSet == WEEK_OF_YEAR)) {
-			if (isSet[WEEK_OF_YEAR] && isSet[DAY_OF_WEEK])
-				useMonth = lastDateFieldSet != WEEK_OF_YEAR && weekMonthSet
+			if (isSet[WEEK_OF_YEAR] && isSet[DAY_OF_WEEK]) {
+                useMonth = lastDateFieldSet != WEEK_OF_YEAR && weekMonthSet
 						&& isSet[DAY_OF_WEEK];
-			else if (isSet[DAY_OF_YEAR])
-				useMonth = isSet[DATE] && isSet[MONTH];
+            } else if (isSet[DAY_OF_YEAR]) {
+                useMonth = isSet[DATE] && isSet[MONTH];
+            }
 		}
 
 		if (useMonth) {
@@ -612,15 +649,17 @@
 			if (useDate) {
 				if (!isLenient()
 						&& (fields[DATE] < 1 || fields[DATE] > daysInMonth(
-								leapYear, month)))
-					throw new IllegalArgumentException();
+								leapYear, month))) {
+                    throw new IllegalArgumentException();
+                }
 				days += fields[DATE] - 1;
 			} else {
 				int dayOfWeek;
 				if (isSet[DAY_OF_WEEK]) {
 					dayOfWeek = fields[DAY_OF_WEEK] - 1;
-				} else
-					dayOfWeek = getFirstDayOfWeek() - 1;
+				} else {
+                    dayOfWeek = getFirstDayOfWeek() - 1;
+                }
 				if (isSet[WEEK_OF_MONTH]
 						&& lastDateFieldSet != DAY_OF_WEEK_IN_MONTH) {
 					int skew = mod7(days - 3 - (getFirstDayOfWeek() - 1));
@@ -641,25 +680,29 @@
 		} else {
 			boolean useWeekYear = isSet[WEEK_OF_YEAR]
 					&& lastDateFieldSet != DAY_OF_YEAR;
-			if (useWeekYear && isSet[DAY_OF_YEAR])
-				useWeekYear = isSet[DAY_OF_WEEK];
+			if (useWeekYear && isSet[DAY_OF_YEAR]) {
+                useWeekYear = isSet[DAY_OF_WEEK];
+            }
 			days = daysFromBaseYear(year);
 			if (useWeekYear) {
 				int dayOfWeek;
 				if (isSet[DAY_OF_WEEK]) {
 					dayOfWeek = fields[DAY_OF_WEEK] - 1;
-				} else
-					dayOfWeek = getFirstDayOfWeek() - 1;
+				} else {
+                    dayOfWeek = getFirstDayOfWeek() - 1;
+                }
 				int skew = mod7(days - 3 - (getFirstDayOfWeek() - 1));
 				days += (fields[WEEK_OF_YEAR] - 1) * 7
 						+ mod7(skew + dayOfWeek - (days - 3)) - skew;
-				if (7 - skew < getMinimalDaysInFirstWeek())
-					days += 7;
+				if (7 - skew < getMinimalDaysInFirstWeek()) {
+                    days += 7;
+                }
 			} else if (isSet[DAY_OF_YEAR]) {
 				if (!isLenient()
 						&& (fields[DAY_OF_YEAR] < 1 || fields[DAY_OF_YEAR] > (365 + (isLeapYear(year) ? 1
-								: 0))))
-					throw new IllegalArgumentException();
+								: 0)))) {
+                    throw new IllegalArgumentException();
+                }
 				days += fields[DAY_OF_YEAR] - 1;
 			} else if (isSet[DAY_OF_WEEK]) {
 				days += mod7(fields[DAY_OF_WEEK] - 1 - (days - 3));
@@ -670,8 +713,9 @@
 		timeVal += days * 86400000;
 		// Use local time to compare with the gregorian change
 		if (year == changeYear
-				&& timeVal >= gregorianCutover + julianError() * 86400000)
-			timeVal -= julianError() * 86400000;
+				&& timeVal >= gregorianCutover + julianError() * 86400000) {
+            timeVal -= julianError() * 86400000;
+        }
 		timeVal -= getOffset(timeVal);
 		this.time = timeVal;
 	}
@@ -679,8 +723,9 @@
 	private int computeYearAndDay(long dayCount, long localTime) {
 		int year = 1970;
 		long days = dayCount;
-		if (localTime < gregorianCutover)
-			days -= julianSkew;
+		if (localTime < gregorianCutover) {
+            days -= julianSkew;
+        }
 		int approxYears;
 
 		while ((approxYears = (int) (days / 365)) != 0) {
@@ -690,8 +735,9 @@
 		if (days < 0) {
 			year = year - 1;
 			days = days + 365 + (isLeapYear(year) ? 1 : 0);
-			if (year == changeYear && localTime < gregorianCutover)
-				days -= julianError();
+			if (year == changeYear && localTime < gregorianCutover) {
+                days -= julianError();
+            }
 		}
 		fields[YEAR] = year;
 		return (int) days + 1;
@@ -700,10 +746,11 @@
 	private long daysFromBaseYear(int year) {
 		if (year >= 1970) {
 			long days = (year - 1970) * (long) 365 + ((year - 1969) / 4);
-			if (year > changeYear)
-				days -= ((year - 1901) / 100) - ((year - 1601) / 400);
-			else
-				days += julianSkew;
+			if (year > changeYear) {
+                days -= ((year - 1901) / 100) - ((year - 1601) / 400);
+            } else {
+                days += julianSkew;
+            }
 			return days;
 		} else if (year <= changeYear) {
 			return (year - 1970) * (long) 365 + ((year - 1972) / 4)
@@ -719,8 +766,9 @@
 	}
 
 	private int daysInMonth(boolean leapYear, int month) {
-		if (leapYear && month == FEBRUARY)
-			return DaysInMonth[month] + 1;
+		if (leapYear && month == FEBRUARY) {
+            return DaysInMonth[month] + 1;
+        }
 
 		return DaysInMonth[month];
 	}
@@ -730,8 +778,9 @@
 	}
 
 	private int daysInYear(boolean leapYear, int month) {
-		if (leapYear && month > FEBRUARY)
-			return DaysInYear[month] + 1;
+		if (leapYear && month > FEBRUARY) {
+            return DaysInYear[month] + 1;
+        }
 
 		return DaysInYear[month];
 	}
@@ -767,8 +816,9 @@
 	 */
 	public int getActualMaximum(int field) {
 		int value;
-		if ((value = getMaximum(field)) == getLeastMaximum(field))
-			return value;
+		if ((value = getMaximum(field)) == getLeastMaximum(field)) {
+            return value;
+        }
 
 		switch (field) {
 		case WEEK_OF_YEAR:
@@ -806,14 +856,16 @@
 			break;
 		case YEAR:
 			GregorianCalendar clone = (GregorianCalendar) clone();
-			if (get(ERA) == AD)
-				clone.setTimeInMillis(Long.MAX_VALUE);
-			else
-				clone.setTimeInMillis(Long.MIN_VALUE);
+			if (get(ERA) == AD) {
+                clone.setTimeInMillis(Long.MAX_VALUE);
+            } else {
+                clone.setTimeInMillis(Long.MIN_VALUE);
+            }
 			result = clone.get(YEAR);
 			clone.set(YEAR, get(YEAR));
-			if (clone.before(this))
-				result--;
+			if (clone.before(this)) {
+                result--;
+            }
 			break;
 		}
 		time = orgTime;
@@ -892,8 +944,9 @@
 
 	int getOffset(long localTime) {
 		TimeZone timeZone = getTimeZone();
-		if (!timeZone.useDaylightTime())
-			return timeZone.getRawOffset();
+		if (!timeZone.useDaylightTime()) {
+            return timeZone.getRawOffset();
+        }
 
 		long dayCount = localTime / 86400000;
 		int millis = (int) (localTime % 86400000);
@@ -904,8 +957,9 @@
 
 		int year = 1970;
 		long days = dayCount;
-		if (localTime < gregorianCutover)
-			days -= julianSkew;
+		if (localTime < gregorianCutover) {
+            days -= julianSkew;
+        }
 		int approxYears;
 
 		while ((approxYears = (int) (days / 365)) != 0) {
@@ -915,11 +969,13 @@
 		if (days < 0) {
 			year = year - 1;
 			days = days + 365 + (isLeapYear(year) ? 1 : 0);
-			if (year == changeYear && localTime < gregorianCutover)
-				days -= julianError();
-		}
-		if (year <= 0)
-			return timeZone.getRawOffset();
+			if (year == changeYear && localTime < gregorianCutover) {
+                days -= julianError();
+            }
+		}
+		if (year <= 0) {
+            return timeZone.getRawOffset();
+        }
 		int dayOfYear = (int) days + 1;
 
 		int month = dayOfYear / 32;
@@ -956,8 +1012,9 @@
 	 * @return true if the specified year is a leap year, false otherwise
 	 */
 	public boolean isLeapYear(int year) {
-		if (year > changeYear)
-			return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
+		if (year > changeYear) {
+            return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
+        }
 
 		return year % 4 == 0;
 	}
@@ -968,15 +1025,17 @@
 
 	private int mod(int value, int mod) {
 		int rem = value % mod;
-		if (value < 0 && rem < 0)
-			return rem + mod;
+		if (value < 0 && rem < 0) {
+            return rem + mod;
+        }
 		return rem;
 	}
 
 	private int mod7(long num1) {
 		int rem = (int) (num1 % 7);
-		if (num1 < 0 && rem < 0)
-			return rem + 7;
+		if (num1 < 0 && rem < 0) {
+            return rem + 7;
+        }
 		return rem;
 	}
 
@@ -995,10 +1054,12 @@
 	 *                when an invalid field is specified
 	 */
 	public void roll(int field, int value) {
-		if (value == 0)
-			return;
-		if (field < 0 || field >= ZONE_OFFSET)
-			throw new IllegalArgumentException();
+		if (value == 0) {
+            return;
+        }
+		if (field < 0 || field >= ZONE_OFFSET) {
+            throw new IllegalArgumentException();
+        }
 
 		isCached = false;
 
@@ -1024,18 +1085,21 @@
 			int maxWeeks = (days - 1 + mod) / 7 + 1;
 			int newWeek = mod(fields[field] - 1 + value, maxWeeks) + 1;
 			if (newWeek == maxWeeks) {
-				if (fields[day] + (newWeek - fields[field]) * 7 > days)
-					set(day, days);
-				else
-					set(field, newWeek);
+				if (fields[day] + (newWeek - fields[field]) * 7 > days) {
+                    set(day, days);
+                } else {
+                    set(field, newWeek);
+                }
 			} else if (newWeek == 1) {
 				int week = (fields[day] - ((fields[day] - 1) / 7 * 7) - 1 + mod) / 7 + 1;
-				if (week > 1)
-					set(day, 1);
-				else
-					set(field, newWeek);
-			} else
-				set(field, newWeek);
+				if (week > 1) {
+                    set(day, 1);
+                } else {
+                    set(field, newWeek);
+                }
+			} else {
+                set(field, newWeek);
+            }
 			break;
 		case DATE:
 			max = daysInMonth();
@@ -1060,14 +1124,16 @@
 		case SECOND:
 		case MILLISECOND:
 			set(field, mod(fields[field] + value, maximums[field] + 1));
-			if (field == MONTH && fields[DATE] > daysInMonth())
-				set(DATE, daysInMonth());
-			else if (field == AM_PM)
-				lastTimeFieldSet = HOUR;
+			if (field == MONTH && fields[DATE] > daysInMonth()) {
+                set(DATE, daysInMonth());
+            } else if (field == AM_PM) {
+                lastTimeFieldSet = HOUR;
+            }
 			break;
 		}
-		if (max != -1)
-			set(field, mod(fields[field] - 1 + value, max) + 1);
+		if (max != -1) {
+            set(field, mod(fields[field] - 1 + value, max) + 1);
+        }
 		complete();
 	}
 
@@ -1101,8 +1167,9 @@
 		GregorianCalendar cal = new GregorianCalendar(TimeZone.GMT);
 		cal.setTime(date);
 		changeYear = cal.get(YEAR);
-		if (cal.get(ERA) == BC)
-			changeYear = 1 - changeYear;
+		if (cal.get(ERA) == BC) {
+            changeYear = 1 - changeYear;
+        }
 		julianSkew = ((changeYear - 2000) / 400) + julianError()
 				- ((changeYear - 2000) / 100);
 		isCached = false;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java?rev=415066&r1=415065&r2=415066&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java Sat Jun 17 14:39:53 2006
@@ -52,8 +52,9 @@
 
         public Object clone() {
             Entry<K,V> entry = (Entry<K,V>) super.clone();
-            if (next != null)
+            if (next != null) {
                 entry.next = (Entry<K,V>) next.clone();
+            }
             return entry;
         }
 
@@ -88,34 +89,39 @@
         }
 
         public boolean hasNext() {
-            if (entry != null)
+            if (entry != null) {
                 return true;
+            }
             while (position < associatedMap.elementData.length) {
-                if (associatedMap.elementData[position] == null)
+                if (associatedMap.elementData[position] == null) {
                     position++;
-                else
+                } else {
                     return true;
+                }
             }
             return false;
         }
 
         void checkConcurrentMod() throws ConcurrentModificationException {
-            if (expectedModCount != associatedMap.modCount)
+            if (expectedModCount != associatedMap.modCount) {
                 throw new ConcurrentModificationException();
+            }
         }
 
         public E next() {
             checkConcurrentMod();
-            if (!hasNext())
+            if (!hasNext()) {
                 throw new NoSuchElementException();
+            }
 
             MapEntry<KT,VT> result;
             if (entry == null) {
                 result = lastEntry = associatedMap.elementData[position++];
                 entry = lastEntry.next;
             } else {
-                if (lastEntry.next != entry)
+                if (lastEntry.next != entry) {
                     lastEntry = lastEntry.next;
+                }
                 result = entry;
                 entry = entry.next;
             }
@@ -125,18 +131,21 @@
 
         public void remove() {
             checkConcurrentMod();
-            if (!canRemove)
+            if (!canRemove) {
                 throw new IllegalStateException();
+            }
 
             canRemove = false;
             associatedMap.modCount++;
             if (lastEntry.next == entry) {
-                while (associatedMap.elementData[--position] == null)
+                while (associatedMap.elementData[--position] == null) {
                     ;
+                }
                 associatedMap.elementData[position] = associatedMap.elementData[position].next;
                 entry = null;
-            } else
+            } else {
                 lastEntry.next = entry;
+            }
             associatedMap.elementCount--;
             expectedModCount++;
         }
@@ -171,7 +180,7 @@
 
         public boolean contains(Object object) {
             if (object instanceof Map.Entry) {
-                Entry entry = associatedMap.getEntry(((Map.Entry) object)
+                Entry<KT, VT> entry = associatedMap.getEntry(((Map.Entry) object)
                         .getKey());
                 return object.equals(entry);
             }
@@ -194,11 +203,11 @@
      * @return Reference to the element array
      */
     Entry<K,V>[] newElementArray(int s) {
-        return (Entry<K,V>[])new Entry[s];
+        return new Entry[s];
     }
 
     /**
-     * Contructs a new empty instance of HashMap.
+     * Constructs a new empty instance of HashMap.
      * 
      */
     public HashMap() {
@@ -220,8 +229,9 @@
             elementData = newElementArray(capacity == 0 ? 1 : capacity);
             loadFactor = 0.75f; // Default load factor of 0.75
             computeMaxSize();
-        } else
+        } else {
             throw new IllegalArgumentException();
+        }
     }
 
     /**
@@ -244,8 +254,9 @@
             elementData = newElementArray(capacity == 0 ? 1 : capacity);
             this.loadFactor = loadFactor;
             computeMaxSize();
-        } else
+        } else {
             throw new IllegalArgumentException();
+        }
     }
 
     /**
@@ -287,8 +298,9 @@
             map.elementData = newElementArray(elementData.length);
             Entry<K,V> entry;
             for (int i = 0; i < elementData.length; i++) {
-                if ((entry = elementData[i]) != null)
+                if ((entry = elementData[i]) != null) {
                     map.elementData[i] = (Entry<K,V>) entry.clone();
+                }
             }
             return map;
         } catch (CloneNotSupportedException e) {
@@ -320,9 +332,9 @@
      *            first key to compare
      * @param k2
      *            second key to compare
-     * @return true iff the keys are considered equal
+     * @return true if the keys are considered equal
      */
-    boolean keysEqual(Object k1, Entry entry) {
+    boolean keysEqual(Object k1, Entry<K, V> entry) {
         return entry.hashCode() == k1.hashCode() && k1.equals(entry.key);
     }
 
@@ -339,8 +351,9 @@
             for (int i = elementData.length; --i >= 0;) {
                 Entry<K,V> entry = elementData[i];
                 while (entry != null) {
-                    if (value.equals(entry.value))
+                    if (value.equals(entry.value)) {
                         return true;
+                    }
                     entry = entry.next;
                 }
             }
@@ -348,8 +361,9 @@
             for (int i = elementData.length; --i >= 0;) {
                 Entry<K,V> entry = elementData[i];
                 while (entry != null) {
-                    if (entry.value == null)
+                    if (entry.value == null) {
                         return true;
+                    }
                     entry = entry.next;
                 }
             }
@@ -360,7 +374,7 @@
     /**
      * Answers a Set of the mappings contained in this HashMap. Each element in
      * the set is a Map.Entry. The set is backed by this HashMap so changes to
-     * one are relected by the other. The set does not support adding.
+     * one are reflected by the other. The set does not support adding.
      * 
      * @return a Set of the mappings
      */
@@ -389,8 +403,9 @@
     }
 
     int getModuloHash(Object key) {
-        if (key == null)
+        if (key == null) {
             return 0;
+        }
         return (key.hashCode() & 0x7FFFFFFF) % elementData.length;
     }
 
@@ -402,8 +417,9 @@
                 m = m.next;
             }
         } else {
-            while (m != null && m.key != null)
+            while (m != null && m.key != null) {
                 m = m.next;
+            }
         }
         return m;
     }
@@ -421,7 +437,7 @@
 
     /**
      * Answers a Set of the keys contained in this HashMap. The set is backed by
-     * this HashMap so changes to one are relected by the other. The set does
+     * this HashMap so changes to one are reflected by the other. The set does
      * not support adding.
      * 
      * @return a Set of the keys
@@ -508,8 +524,9 @@
 
     void rehash() {
         int length = elementData.length << 1;
-        if (length == 0)
+        if (length == 0) {
             length = 1;
+        }
         Entry<K,V>[] newData = newElementArray(length);
         for (int i = 0; i < elementData.length; i++) {
             Entry<K,V> entry = elementData[i];
@@ -561,12 +578,14 @@
                 entry = entry.next;
             }
         }
-        if (entry == null)
+        if (entry == null) {
             return null;
-        if (last == null)
+        }
+        if (last == null) {
             elementData[index] = entry.next;
-        else
+        } else {
             last.next = entry.next;
+        }
         modCount++;
         elementCount--;
         return entry;
@@ -583,7 +602,7 @@
 
     /**
      * Answers a Collection of the values contained in this HashMap. The
-     * collection is backed by this HashMap so changes to one are relected by
+     * collection is backed by this HashMap so changes to one are reflected by
      * the other. The collection does not support adding.
      * 
      * @return a Collection of the values
@@ -619,9 +638,9 @@
         stream.defaultWriteObject();
         stream.writeInt(elementData.length);
         stream.writeInt(elementCount);
-        Iterator iterator = entrySet().iterator();
+        Iterator<?> iterator = entrySet().iterator();
         while (iterator.hasNext()) {
-            Entry entry = (Entry) iterator.next();
+            Entry<?, ?> entry = (Entry) iterator.next();
             stream.writeObject(entry.key);
             stream.writeObject(entry.value);
             entry = entry.next;
@@ -632,7 +651,7 @@
             ClassNotFoundException {
         stream.defaultReadObject();
         int length = stream.readInt();
-        elementData = (Entry<K,V>[])new Entry[length];
+        elementData = new Entry[length];
         elementCount = stream.readInt();
         for (int i = elementCount; --i >= 0;) {
             K key = (K)stream.readObject();

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java?rev=415066&r1=415065&r2=415066&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java Sat Jun 17 14:39:53 2006
@@ -73,14 +73,16 @@
 
 		public Object clone() {
 			Entry<K, V> entry = (Entry<K, V>) super.clone();
-			if (next != null)
-				entry.next = (Entry<K, V>) next.clone();
+			if (next != null) {
+                entry.next = (Entry<K, V>) next.clone();
+            }
 			return entry;
 		}
 
 		public V setValue(V object) {
-			if (object == null)
-				throw new NullPointerException();
+			if (object == null) {
+                throw new NullPointerException();
+            }
 			V result = value;
 			value = object;
 			return result;
@@ -121,10 +123,11 @@
 				return true;
 			}
 			while (position >= firstSlot) {
-				if (elementData[position] == null)
-					position--;
-				else
-					return true;
+				if (elementData[position] == null) {
+                    position--;
+                } else {
+                    return true;
+                }
 			}
 			return false;
 		}
@@ -151,8 +154,9 @@
 					return type.get(lastEntry);
 				}
 				throw new NoSuchElementException();
-			} else
-				throw new ConcurrentModificationException();
+			} else {
+                throw new ConcurrentModificationException();
+            }
 		}
 
 		public void remove() {
@@ -187,8 +191,9 @@
 						// throw ConcurrentModificationException() outside of
 						// synchronized block
 					}
-				} else
-					throw new IllegalStateException();
+				} else {
+                    throw new IllegalStateException();
+                }
 			}
 			throw new ConcurrentModificationException();
 		}
@@ -207,13 +212,15 @@
 		}
 
 		public boolean hasMoreElements() {
-			if (entry != null)
-				return true;
-			while (--start >= firstSlot)
-				if (elementData[start] != null) {
+			if (entry != null) {
+                return true;
+            }
+			while (--start >= firstSlot) {
+                if (elementData[start] != null) {
 					entry = elementData[start];
 					return true;
 				}
+            }
 			return false;
 		}
 
@@ -222,8 +229,9 @@
 				Object result = key ? entry.key : entry.value;
 				entry = entry.next;
 				return (E)result;
-			} else
-				throw new NoSuchElementException();
+			} else {
+                throw new NoSuchElementException();
+            }
 		}
 	}
 
@@ -244,12 +252,13 @@
 	public Hashtable(int capacity) {
 		if (capacity >= 0) {
 			elementCount = 0;
-			elementData = (Entry<K, V>[])new Entry[capacity == 0 ? 1 : capacity];
+			elementData = new Entry[capacity == 0 ? 1 : capacity];
 			firstSlot = elementData.length;
 			loadFactor = 0.75f;
 			computeMaxSize();
-		} else
-			throw new IllegalArgumentException();
+		} else {
+            throw new IllegalArgumentException();
+        }
 	}
 
 	/**
@@ -264,11 +273,12 @@
 		if (capacity >= 0 && loadFactor > 0) {
 			elementCount = 0;
 			firstSlot = capacity;
-			elementData = (Entry<K, V>[])new Entry[capacity == 0 ? 1 : capacity];
+			elementData = new Entry[capacity == 0 ? 1 : capacity];
 			this.loadFactor = loadFactor;
 			computeMaxSize();
-		} else
-			throw new IllegalArgumentException();
+		} else {
+            throw new IllegalArgumentException();
+        }
 	}
 
 	/**
@@ -313,9 +323,11 @@
 			Hashtable<K, V> hashtable = (Hashtable<K, V>) super.clone();
 			hashtable.elementData = elementData.clone();
 			Entry<K, V> entry;
-			for (int i = elementData.length; --i >= 0;)
-				if ((entry = elementData[i]) != null)
-					hashtable.elementData[i] = (Entry<K, V>) entry.clone();
+			for (int i = elementData.length; --i >= 0;) {
+                if ((entry = elementData[i]) != null) {
+                    hashtable.elementData[i] = (Entry<K, V>) entry.clone();
+                }
+            }
 			return hashtable;
 		} catch (CloneNotSupportedException e) {
 			return null;
@@ -338,14 +350,16 @@
 	 * @see java.lang.Object#equals
 	 */
 	public synchronized boolean contains(Object value) {
-		if (value == null) 
-			throw new NullPointerException();
+		if (value == null) {
+            throw new NullPointerException();
+        }
 
 			for (int i = elementData.length; --i >= 0;) {
 				Entry<K, V> entry = elementData[i];
 				while (entry != null) {
-					if (value.equals(entry.value))
-						return true;
+					if (value.equals(entry.value)) {
+                        return true;
+                    }
 					entry = entry.next;
 				}
 			}
@@ -391,8 +405,9 @@
 	 * @see Enumeration
 	 */
 	public synchronized Enumeration<V> elements() {
-		if (elementCount == 0)
-			return emptyEnumerator;
+		if (elementCount == 0) {
+            return emptyEnumerator;
+        }
 		return new HashEnumerator<V>(false);
 	}
 
@@ -404,7 +419,7 @@
 	 * @return a Set of the mappings
 	 */
 	public Set<Map.Entry<K,V>> entrySet() {
-		return new Collections.SynchronizedSet(new AbstractSet<Map.Entry<K,V>>() {
+		return new Collections.SynchronizedSet<Map.Entry<K, V>>(new AbstractSet<Map.Entry<K,V>>() {
 			public int size() {
 				return elementCount;
 			}
@@ -428,7 +443,7 @@
 
 			public Iterator<Map.Entry<K,V>> iterator() {
 				return new HashIterator<Map.Entry<K, V>>(new MapEntry.Type<Map.Entry<K, V>, K, V>() {
-					public Map.Entry<K, V> get(MapEntry entry) {
+					public Map.Entry<K, V> get(MapEntry<K, V> entry) {
 						return entry;
 					}
 				});
@@ -449,12 +464,14 @@
 	 * @see #hashCode
 	 */
 	public synchronized boolean equals(Object object) {
-		if (this == object)
-			return true;
+		if (this == object) {
+            return true;
+        }
 		if (object instanceof Map) {
 			Map<?, ?> map = (Map<?, ?>) object;
-			if (size() != map.size())
-				return false;
+			if (size() != map.size()) {
+                return false;
+            }
 			
             Set<Map.Entry<K, V>> entries = entrySet();
             for (Map.Entry<?, ?> e : map.entrySet()) {
@@ -482,8 +499,9 @@
 		int index = (hash & 0x7FFFFFFF) % elementData.length;
 		Entry<K,V> entry = elementData[index];
 		while (entry != null) {
-			if (entry.equalsKey(key, hash))
-				return entry.value;
+			if (entry.equalsKey(key, hash)) {
+                return entry.value;
+            }
 			entry = entry.next;
 		}
 		return null;
@@ -494,8 +512,9 @@
 		int index = (hash & 0x7FFFFFFF) % elementData.length;
 		Entry<K, V> entry = elementData[index];
 		while (entry != null) {
-			if (entry.equalsKey(key, hash))
-				return entry;
+			if (entry.equalsKey(key, hash)) {
+                return entry;
+            }
 			entry = entry.next;
 		}
 		return null;
@@ -547,8 +566,9 @@
 	 * @see Enumeration
 	 */
 	public synchronized Enumeration<K> keys() {
-		if (elementCount == 0)
-			return emptyEnumerator;
+		if (elementCount == 0) {
+            return emptyEnumerator;
+        }
 		return new HashEnumerator<K>(true);
 	}
 
@@ -560,7 +580,7 @@
 	 * @return a Set of the keys
 	 */
 	public Set<K> keySet() {
-		return new Collections.SynchronizedSet(
+		return new Collections.SynchronizedSet<K>(
             new AbstractSet<K>() {
     			public boolean contains(Object object) {
     				return containsKey(object);
@@ -615,18 +635,21 @@
 			int hash = key.hashCode();
 			int index = (hash & 0x7FFFFFFF) % elementData.length;
 			Entry<K,V> entry = elementData[index];
-			while (entry != null && !entry.equalsKey(key, hash))
-				entry = entry.next;
+			while (entry != null && !entry.equalsKey(key, hash)) {
+                entry = entry.next;
+            }
 			if (entry == null) {
 				modCount++;
 				if (++elementCount > threshold) {
 					rehash();
 					index = (hash & 0x7FFFFFFF) % elementData.length;
 				}
-				if (index < firstSlot)
-					firstSlot = index;
-				if (index > lastSlot)
-					lastSlot = index;
+				if (index < firstSlot) {
+                    firstSlot = index;
+                }
+				if (index > lastSlot) {
+                    lastSlot = index;
+                }
 				entry = newEntry(key, value, hash);
 				entry.next = elementData[index];
 				elementData[index] = entry;
@@ -635,8 +658,9 @@
 			V result = entry.value;
 			entry.value = value;
 			return result;
-		} else
-			throw new NullPointerException();
+		} else {
+            throw new NullPointerException();
+        }
 	}
 
 	/**
@@ -657,19 +681,22 @@
 	 */
 	protected void rehash() {
 		int length = (elementData.length << 1) + 1;
-		if (length == 0)
-			length = 1;
+		if (length == 0) {
+            length = 1;
+        }
 		int newFirst = length;
 		int newLast = -1;
-		Entry<K, V>[] newData = (Entry<K, V>[])new Entry[length];
+		Entry<K, V>[] newData = new Entry[length];
 		for (int i = lastSlot + 1; --i >= firstSlot;) {
 			Entry<K, V> entry = elementData[i];
 			while (entry != null) {
 				int index = (entry.getKeyHash() & 0x7FFFFFFF) % length;
-				if (index < newFirst)
-					newFirst = index;
-				if (index > newLast)
-					newLast = index;
+				if (index < newFirst) {
+                    newFirst = index;
+                }
+				if (index > newLast) {
+                    newLast = index;
+                }
 				Entry<K, V> next = entry.next;
 				entry.next = newData[index];
 				newData[index] = entry;
@@ -704,10 +731,11 @@
 		}
 		if (entry != null) {
 			modCount++;
-			if (last == null)
-				elementData[index] = entry.next;
-			else
-				last.next = entry.next;
+			if (last == null) {
+                elementData[index] = entry.next;
+            } else {
+                last.next = entry.next;
+            }
 			elementCount--;
 			V result = entry.value;
 			entry.value = null;
@@ -734,8 +762,9 @@
 	 * @return the string representation of this Hashtable
 	 */
 	public synchronized String toString() {
-		if (isEmpty())
-			return "{}";
+		if (isEmpty()) {
+            return "{}";
+        }
 
 		StringBuilder buffer = new StringBuilder(size() * 28);
 		buffer.append('{');
@@ -758,8 +787,9 @@
 			}
 		}
 		// Remove the last ", "
-		if (elementCount > 0)
-			buffer.setLength(buffer.length() - 2);
+		if (elementCount > 0) {
+            buffer.setLength(buffer.length() - 2);
+        }
 		buffer.append('}');
 		return buffer.toString();
 	}
@@ -772,7 +802,7 @@
 	 * @return a Collection of the values
 	 */
 	public Collection<V> values() {
-		return new Collections.SynchronizedCollection(new AbstractCollection<V>() {
+		return new Collections.SynchronizedCollection<V>(new AbstractCollection<V>() {
 			public boolean contains(Object object) {
 				return Hashtable.this.contains(object);
 			}
@@ -814,16 +844,18 @@
 			ClassNotFoundException {
 		stream.defaultReadObject();
 		int length = stream.readInt();
-		elementData = (Entry<K, V>[])new Entry[length];
+		elementData = new Entry[length];
 		elementCount = stream.readInt();
 		for (int i = elementCount; --i >= 0;) {
 			Object key = stream.readObject();
 			int hash = key.hashCode();
 			int index = (hash & 0x7FFFFFFF) % length;
-			if (index < firstSlot)
-				firstSlot = index;
-			if (index > lastSlot)
-				lastSlot = index;
+			if (index < firstSlot) {
+                firstSlot = index;
+            }
+			if (index > lastSlot) {
+                lastSlot = index;
+            }
 			Entry<K, V> entry = newEntry((K)key, (V)stream.readObject(), hash);
 			entry.next = elementData[index];
 			elementData[index] = entry;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/IdentityHashMap.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/IdentityHashMap.java?rev=415066&r1=415065&r2=415066&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/IdentityHashMap.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/IdentityHashMap.java Sat Jun 17 14:39:53 2006
@@ -84,14 +84,15 @@
 		}
 
 		public Object clone() {
-			return (IdentityHashMapEntry) super.clone();
+			return super.clone();
 		}
 
 		public boolean equals(Object object) {
-			if (this == object)
-				return true;
+			if (this == object) {
+                return true;
+            }
 			if (object instanceof Map.Entry) {
-				Map.Entry entry = (Map.Entry) object;
+				Map.Entry<?, ?> entry = (Map.Entry) object;
 				return (key == entry.getKey()) && (value == entry.getValue());
 			}
 			return false;
@@ -130,22 +131,26 @@
 		public boolean hasNext() {
 			while (position < associatedMap.elementData.length) {
 				// if this is an empty spot, go to the next one
-				if (associatedMap.elementData[position] == null)
-					position += 2;
-				else
-					return true;
+				if (associatedMap.elementData[position] == null) {
+                    position += 2;
+                } else {
+                    return true;
+                }
 			}
 			return false;
 		}
 
 		void checkConcurrentMod() throws ConcurrentModificationException {
-			if (expectedModCount != associatedMap.modCount)
-				throw new ConcurrentModificationException();
+			if (expectedModCount != associatedMap.modCount) {
+                throw new ConcurrentModificationException();
+            }
 		}
 
 		public E next() {
 			checkConcurrentMod();
-			if (!hasNext()) throw new NoSuchElementException();
+			if (!hasNext()) {
+                throw new NoSuchElementException();
+            }
 			
 			IdentityHashMapEntry<KT, VT> result = associatedMap.getEntry(position);
 			lastPosition = position;
@@ -157,7 +162,9 @@
 
 		public void remove() {
 			checkConcurrentMod();
-			if (!canRemove) throw new IllegalStateException();
+			if (!canRemove) {
+                throw new IllegalStateException();
+            }
 			
 			canRemove = false;
 			associatedMap.remove(associatedMap.elementData[lastPosition]);
@@ -195,7 +202,7 @@
 
 		public boolean contains(Object object) {
 			if (object instanceof Map.Entry) {
-				IdentityHashMapEntry entry = associatedMap
+				IdentityHashMapEntry<?, ?> entry = associatedMap
 						.getEntry(((Map.Entry) object).getKey());
 				// we must call equals on the entry obtained from "this"
 				return entry != null && entry.equals(object);
@@ -231,8 +238,9 @@
 			this.size = 0;
 			threshold = getThreshold(maxSize);
 			elementData = newElementArray(computeElementArraySize());
-		} else
-			throw new IllegalArgumentException();
+		} else {
+            throw new IllegalArgumentException();
+        }
 	}
 
 	private int getThreshold(int maxSize) {
@@ -344,7 +352,7 @@
 		return null;
 	}
 
-	private IdentityHashMapEntry getEntry(Object key) {
+	private IdentityHashMapEntry<K, V> getEntry(Object key) {
 		if (key == null) {
 			key = NULL_OBJECT;
 		}
@@ -445,8 +453,9 @@
 
 	private void rehash() {
 		int newlength = elementData.length << 1;
-		if (newlength == 0)
-			newlength = 1;
+		if (newlength == 0) {
+            newlength = 1;
+        }
 		Object[] newData = newElementArray(newlength);
 		for (int i = 0; i < elementData.length; i = i + 2) {
 			Object key = elementData[i];
@@ -483,8 +492,9 @@
 		Object result, object;
 		index = next = findIndex(key, elementData);
 
-		if (elementData[index] != key)
-			return null;
+		if (elementData[index] != key) {
+            return null;
+        }
 
 		// store the value for this key
 		result = elementData[index + 1];
@@ -495,8 +505,9 @@
 		while (true) {
 			next = (next + 2) % length;
 			object = elementData[next];
-			if (object == null)
-				break;
+			if (object == null) {
+                break;
+            }
 
 			hash = getModuloHash(object, length);
 			hashedOk = hash > index;
@@ -607,7 +618,7 @@
 				}
 				
 				public boolean remove(Object object) {
-					Iterator it = iterator();
+					Iterator<?> it = iterator();
 					while (it.hasNext()) {
 						if (object == it.next()) {
 							it.remove();
@@ -640,14 +651,16 @@
 		// place. We must ensure that all comparison is implemented by methods
 		// in this class (or in one of our inner classes) for reference-based
 		// comparison to take place.
-		if (this == object)
-			return true;
+		if (this == object) {
+            return true;
+        }
 		if (object instanceof Map) {
-			Map map = (Map) object;
-			if (size() != map.size())
-				return false;
+			Map<?, ?> map = (Map) object;
+			if (size() != map.size()) {
+                return false;
+            }
 
-			Set set = entrySet();
+			Set<Map.Entry<K, V>> set = entrySet();
 			// ensure we use the equals method of the set created by "this"
 			return set.equals(map.entrySet());
 		}
@@ -664,7 +677,7 @@
 	 */
 	public Object clone() {
 		try {
-			return (IdentityHashMap) super.clone();
+			return super.clone();
 		} catch (CloneNotSupportedException e) {
 			return null;
 		}
@@ -692,9 +705,9 @@
 
 	private void writeObject(ObjectOutputStream stream) throws IOException {
 		stream.writeInt(size);
-		Iterator iterator = entrySet().iterator();
+		Iterator<?> iterator = entrySet().iterator();
 		while (iterator.hasNext()) {
-			MapEntry entry = (MapEntry) iterator.next();
+			MapEntry<?, ?> entry = (MapEntry) iterator.next();
 			stream.writeObject(entry.key);
 			stream.writeObject(entry.value);
 		}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ListResourceBundle.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ListResourceBundle.java?rev=415066&r1=415065&r2=415066&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ListResourceBundle.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ListResourceBundle.java Sat Jun 17 14:39:53 2006
@@ -25,8 +25,7 @@
  * @since 1.1
  */
 public abstract class ListResourceBundle extends ResourceBundle {
-	//TODO Generify when Hashtable is generified
-	Hashtable table;
+	Hashtable<String, Object> table;
 
 	/**
 	 * Constructs a new instance of this class.
@@ -50,22 +49,25 @@
 	 * @return an Enumeration of the resource names
 	 */
 	public Enumeration<String> getKeys() {
-		if (table == null)
-			initializeTable();
-		if (parent == null)
-			return table.keys();
+		if (table == null) {
+            initializeTable();
+        }
+		if (parent == null) {
+            return table.keys();
+        }
 		return new Enumeration<String>() {
 			Enumeration<String> local = table.keys();
 
 			Enumeration<String> pEnum = parent.getKeys();
 
-			String nextElement = null;
+			String nextElement;
 
 			private boolean findNext() {
-				if (nextElement != null)
-					return true;
+				if (nextElement != null) {
+                    return true;
+                }
 				while (pEnum.hasMoreElements()) {
-					String next = (String) pEnum.nextElement();
+					String next = pEnum.nextElement();
 					if (!table.containsKey(next)) {
 						nextElement = next;
 						return true;
@@ -75,14 +77,16 @@
 			}
 
 			public boolean hasMoreElements() {
-				if (local.hasMoreElements())
-					return true;
+				if (local.hasMoreElements()) {
+                    return true;
+                }
 				return findNext();
 			}
 
 			public String nextElement() {
-				if (local.hasMoreElements())
-					return local.nextElement();
+				if (local.hasMoreElements()) {
+                    return local.nextElement();
+                }
 				if (findNext()) {
 					String result = nextElement;
 					nextElement = null;
@@ -103,17 +107,18 @@
 	 * @return the resource object
 	 */
 	public final Object handleGetObject(String key) {
-		if (table == null)
-			initializeTable();
+		if (table == null) {
+            initializeTable();
+        }
 		return table.get(key);
 	}
 
 	private synchronized void initializeTable() {
 		if (table == null) {
 			Object[][] contents = getContents();
-			table = new Hashtable(contents.length / 3 * 4 + 3);
+			table = new Hashtable<String, Object>(contents.length / 3 * 4 + 3);
 			for (int i = 0; i < contents.length; i++) {
-				table.put(contents[i][0], contents[i][1]);
+				table.put((String)contents[i][0], contents[i][1]);
 			}
 		}
 	}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java?rev=415066&r1=415065&r2=415066&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Locale.java Sat Jun 17 14:39:53 2006
@@ -163,12 +163,12 @@
 			"user.language", "write");  //$NON-NLS-1$//$NON-NLS-2$
 
 	static {
-		String language = (String) AccessController
-				.doPrivileged(new PriviAction("user.language", "en")); //$NON-NLS-1$ //$NON-NLS-2$
-		String region = (String) AccessController.doPrivileged(new PriviAction(
+		String language = AccessController
+				.doPrivileged(new PriviAction<String>("user.language", "en")); //$NON-NLS-1$ //$NON-NLS-2$
+		String region = AccessController.doPrivileged(new PriviAction<String>(
 				"user.country", "US")); //$NON-NLS-1$ //$NON-NLS-2$
-		String variant = (String) AccessController
-				.doPrivileged(new PriviAction("user.variant", "")); //$NON-NLS-1$ //$NON-NLS-2$
+		String variant = AccessController
+				.doPrivileged(new PriviAction<String>("user.variant", "")); //$NON-NLS-1$ //$NON-NLS-2$
 		defaultLocale = new Locale(language, region, variant);
 	}
 
@@ -213,12 +213,13 @@
 		languageCode = language.toLowerCase();
 		// Map new language codes to the obsolete language
 		// codes so the correct resource bundles will be used.
-		if (languageCode.equals("he")) //$NON-NLS-1$
-			languageCode = "iw"; //$NON-NLS-1$
-		else if (languageCode.equals("id")) //$NON-NLS-1$
-			languageCode = "in"; //$NON-NLS-1$
-		else if (languageCode.equals("yi")) //$NON-NLS-1$
-			languageCode = "ji"; //$NON-NLS-1$
+		if (languageCode.equals("he")) {
+            languageCode = "iw"; //$NON-NLS-1$
+        } else if (languageCode.equals("id")) {
+            languageCode = "in"; //$NON-NLS-1$
+        } else if (languageCode.equals("yi")) {
+            languageCode = "ji"; //$NON-NLS-1$
+        }
 		countryCode = country.toUpperCase();
 		variantCode = variant;
 	}
@@ -252,8 +253,9 @@
 	 * @see #hashCode
 	 */
 	public boolean equals(Object object) {
-		if (object == this)
-			return true;
+		if (object == this) {
+            return true;
+        }
 		if (object instanceof Locale) {
 			Locale o = (Locale) object;
 			return languageCode.equals(o.languageCode)
@@ -272,7 +274,7 @@
 				return name.startsWith(classPrefix);
 			}
 		};
-		Vector result = new Vector();
+		List<String> result = new ArrayList<String>();
 		StringTokenizer paths = new StringTokenizer(System.getProperty(
 				"com.ibm.oti.system.class.path", ""), System.getProperty( //$NON-NLS-1$ //$NON-NLS-2$
 				"path.separator", ";"));  //$NON-NLS-1$//$NON-NLS-2$
@@ -284,15 +286,17 @@
 					try {
 						File newDir;
 						String path = directory.getCanonicalPath();
-						if (path.charAt(path.length() - 1) == File.separatorChar)
-							newDir = new File(path + thePackage);
-						else
-							newDir = new File(path + File.separatorChar
+						if (path.charAt(path.length() - 1) == File.separatorChar) {
+                            newDir = new File(path + thePackage);
+                        } else {
+                            newDir = new File(path + File.separatorChar
 									+ thePackage);
+                        }
 						if (newDir.isDirectory()) {
 							String[] list = newDir.list(filter);
-							for (int j = 0; j < list.length; j++)
-								result.addElement(list[j]);
+							for (int j = 0; j < list.length; j++) {
+                                result.add(list[j]);
+                            }
 						}
 					} catch (IOException e) {
 					}
@@ -300,13 +304,14 @@
 					// Handle ZIP/JAR files.
 					try {
 						ZipFile zip = new ZipFile(directory);
-						Enumeration entries = zip.entries();
+						Enumeration<? extends ZipEntry> entries = zip.entries();
 						while (entries.hasMoreElements()) {
-							String name = ((ZipEntry) entries.nextElement())
-									.getName();
+                            ZipEntry e = entries.nextElement();
+							String name = e.getName();
 							if (name.startsWith(prefix)
-									&& name.endsWith(".class")) //$NON-NLS-1$
-								result.addElement(name);
+									&& name.endsWith(".class")) {
+                                result.add(name);
+                            }
 						}
 						zip.close();
 					} catch (IOException e) {
@@ -316,7 +321,7 @@
 		}
 		Locale[] locales = new Locale[result.size()];
 		for (int i = 0; i < result.size(); i++) {
-			String name = (String) result.elementAt(i);
+			String name = result.get(i);
 			name = name.substring(0, name.length() - 6); // remove .class
 			int index = name.indexOf('_');
 			int nextIndex = name.indexOf('_', index + 1);
@@ -330,8 +335,9 @@
 			if ((index = name.indexOf('_', nextIndex + 1)) == -1) {
 				variant = ""; //$NON-NLS-1$
 				index = name.length();
-			} else
-				variant = name.substring(index + 1, name.length());
+			} else {
+                variant = name.substring(index + 1, name.length());
+            }
 			String country = name.substring(nextIndex + 1, index);
 			locales[i] = new Locale(language, country, variant);
 		}
@@ -352,7 +358,7 @@
                         }
                     });
         }
-		return (Locale[]) availableLocales.clone();
+		return availableLocales.clone();
 	}
 
 	/**
@@ -394,17 +400,20 @@
 	 * @return a country name
 	 */
 	public String getDisplayCountry(Locale locale) {
-		if (countryCode.length() == 0)
-			return countryCode;
+		if (countryCode.length() == 0) {
+            return countryCode;
+        }
 		try {
 			// First try the specified locale
 			ResourceBundle bundle = getBundle("Country", locale); //$NON-NLS-1$
 			String result = (String) bundle.handleGetObject(countryCode);
-			if (result != null)
-				return result;
+			if (result != null) {
+                return result;
+            }
 			// Now use the default locale
-			if (locale != Locale.getDefault())
-				bundle = getBundle("Country", Locale.getDefault()); //$NON-NLS-1$
+			if (locale != Locale.getDefault()) {
+                bundle = getBundle("Country", Locale.getDefault()); //$NON-NLS-1$
+            }
 			return bundle.getString(countryCode);
 		} catch (MissingResourceException e) {
 			return countryCode;
@@ -432,17 +441,20 @@
 	 * @return a language name
 	 */
 	public String getDisplayLanguage(Locale locale) {
-		if (languageCode.length() == 0)
-			return languageCode;
+		if (languageCode.length() == 0) {
+            return languageCode;
+        }
 		try {
 			// First try the specified locale
 			ResourceBundle bundle = getBundle("Language", locale); //$NON-NLS-1$
 			String result = (String) bundle.handleGetObject(languageCode);
-			if (result != null)
-				return result;
+			if (result != null) {
+                return result;
+            }
 			// Now use the default locale
-			if (locale != Locale.getDefault())
-				bundle = getBundle("Language", Locale.getDefault()); //$NON-NLS-1$
+			if (locale != Locale.getDefault()) {
+                bundle = getBundle("Language", Locale.getDefault()); //$NON-NLS-1$
+            }
 			return bundle.getString(languageCode);
 		} catch (MissingResourceException e) {
 			return languageCode;
@@ -475,21 +487,24 @@
 			count++;
 		}
 		if (countryCode.length() > 0) {
-			if (count == 1)
-				buffer.append(" ("); //$NON-NLS-1$
+			if (count == 1) {
+                buffer.append(" ("); //$NON-NLS-1$
+            }
 			buffer.append(getDisplayCountry(locale));
 			count++;
 		}
 		if (variantCode.length() > 0) {
-			if (count == 1)
-				buffer.append(" ("); //$NON-NLS-1$
-			else if (count == 2)
-				buffer.append(","); //$NON-NLS-1$
+			if (count == 1) {
+                buffer.append(" ("); //$NON-NLS-1$
+            } else if (count == 2) {
+                buffer.append(","); //$NON-NLS-1$
+            }
 			buffer.append(getDisplayVariant(locale));
 			count++;
 		}
-		if (count > 1)
-			buffer.append(")"); //$NON-NLS-1$
+		if (count > 1) {
+            buffer.append(")"); //$NON-NLS-1$
+        }
 		return buffer.toString();
 	}
 
@@ -514,8 +529,9 @@
 	 * @return a variant name
 	 */
 	public String getDisplayVariant(Locale locale) {
-		if (variantCode.length() == 0)
-			return variantCode;
+		if (variantCode.length() == 0) {
+            return variantCode;
+        }
 		ResourceBundle bundle;
 		try {
 			bundle = getBundle("Variant", locale); //$NON-NLS-1$
@@ -533,8 +549,9 @@
 				code = variant;
 			}
 			result.append(code);
-			if (tokens.hasMoreTokens())
-				result.append(',');
+			if (tokens.hasMoreTokens()) {
+                result.append(',');
+            }
 		}
 		return result.toString();
 	}
@@ -549,8 +566,9 @@
 	 *                when there is no matching three letter ISO country code
 	 */
 	public String getISO3Country() throws MissingResourceException {
-		if (countryCode.length() == 0)
-			return ""; //$NON-NLS-1$
+		if (countryCode.length() == 0) {
+            return ""; //$NON-NLS-1$
+        }
 		ResourceBundle bundle = getBundle("ISO3Countries", this); //$NON-NLS-1$
 		return bundle.getString(countryCode);
 	}
@@ -565,8 +583,9 @@
 	 *                when there is no matching three letter ISO language code
 	 */
 	public String getISO3Language() throws MissingResourceException {
-		if (languageCode.length() == 0)
-			return ""; //$NON-NLS-1$
+		if (languageCode.length() == 0) {
+            return ""; //$NON-NLS-1$
+        }
 		ResourceBundle bundle = getBundle("ISO3Languages", this); //$NON-NLS-1$
 		return bundle.getString(languageCode);
 	}
@@ -587,16 +606,18 @@
 		} catch (MissingResourceException e) {
 		}
 
-		Enumeration keys = bundle.getKeys(); // to initialize the table
+		Enumeration<String> keys = bundle.getKeys(); // to initialize the table
 		int size = bundle.table.size();
-		if (hasCS)
-			size--;
+		if (hasCS) {
+            size--;
+        }
 		String[] result = new String[size];
 		int index = 0;
 		while (keys.hasMoreElements()) {
-			String element = (String) keys.nextElement();
-			if (!element.equals("CS")) //$NON-NLS-1$
-				result[index++] = element;
+			String element = keys.nextElement();
+			if (!element.equals("CS")) {
+                result[index++] = element;
+            }
 		}
 		return result;
 	}
@@ -609,11 +630,12 @@
 	 */
 	public static String[] getISOLanguages() {
 		ListResourceBundle bundle = new Language();
-		Enumeration keys = bundle.getKeys(); // to initialize the table
+		Enumeration<String> keys = bundle.getKeys(); // to initialize the table
 		String[] result = new String[bundle.table.size()];
 		int index = 0;
-		while (keys.hasMoreElements())
-			result[index++] = (String) keys.nextElement();
+		while (keys.hasMoreElements()) {
+            result[index++] = keys.nextElement();
+        }
 		return result;
 	}
 
@@ -661,11 +683,13 @@
 	public synchronized static void setDefault(Locale locale) {
 		if (locale != null) {
 			SecurityManager security = System.getSecurityManager();
-			if (security != null)
-				security.checkPermission(setLocalePermission);
+			if (security != null) {
+                security.checkPermission(setLocalePermission);
+            }
 			defaultLocale = locale;
-		} else
-			throw new NullPointerException();
+		} else {
+            throw new NullPointerException();
+        }
 	}
 
 	/**
@@ -681,10 +705,11 @@
 			result.append(countryCode);
 		}
 		if (variantCode.length() > 0) {
-			if (countryCode.length() == 0)
-				result.append("__"); //$NON-NLS-1$
-			else
-				result.append('_');
+			if (countryCode.length() == 0) {
+                result.append("__"); //$NON-NLS-1$
+            } else {
+                result.append('_');
+            }
 			result.append(variantCode);
 		}
 		return result.toString();

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/PropertyPermissionCollection.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/PropertyPermissionCollection.java?rev=415066&r1=415065&r2=415066&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/PropertyPermissionCollection.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/PropertyPermissionCollection.java Sat Jun 17 14:39:53 2006
@@ -30,36 +30,41 @@
 	
 	private static final long serialVersionUID = 7015263904581634791L;
 
-	Hashtable permissions = new Hashtable(30);
+	Hashtable<String, Permission> permissions = new Hashtable<String, Permission>(30);
 
 	public void add(Permission perm) {
-		if (!isReadOnly()) {
-			Permission previous = (Permission) permissions.put(perm.getName(),
-					perm);
-			// if the permission already existed but with only "read" or "write"
-			// set, then replace with both set
-			if (previous != null
-					&& !previous.getActions().equals(perm.getActions()))
-				permissions.put(perm.getName(), new PropertyPermission(perm
-						.getName(), "read,write")); //$NON-NLS-1$
-		} else
-			throw new IllegalStateException();
-	}
+        if (!isReadOnly()) {
+            Permission prev = permissions.put(perm.getName(), perm);
+            /*
+             * If the permission already existed but with only "read" or "write"
+             * set, then replace with both set.
+             */
+            if (prev != null && !prev.getActions().equals(perm.getActions())) {
+                Permission np = new PropertyPermission(perm.getName(),
+                        "read,write");
+                permissions.put(perm.getName(), np); //$NON-NLS-1$
+            }
+        } else {
+            throw new IllegalStateException();
+        }
+    }
 
-	public Enumeration elements() {
+	public Enumeration<Permission> elements() {
 		return permissions.elements();
 	}
 
 	public boolean implies(Permission perm) {
-		Enumeration elemEnum = elements();
-		while (elemEnum.hasMoreElements())
-			if (((Permission) elemEnum.nextElement()).implies(perm))
-				return true;
-		// At this point, the only way it can succeed is if both read and write
-		// are set,
-		// and these are separately granted by two different permissions with
-		// one
-		// representing a parent directory.
+		Enumeration<Permission> elemEnum = elements();
+		while (elemEnum.hasMoreElements()) {
+            if ((elemEnum.nextElement()).implies(perm)) {
+                return true;
+            }
+        }
+		/*
+         * At this point, the only way it can succeed is if both read and write
+         * are set, and these are separately granted by two different
+         * permissions with one representing a parent directory.
+         */
 		return perm.getActions().equals("read,write") //$NON-NLS-1$
 				&& implies(new PropertyPermission(perm.getName(), "read")) //$NON-NLS-1$
 				&& implies(new PropertyPermission(perm.getName(), "write")); //$NON-NLS-1$
@@ -79,6 +84,6 @@
 	private void readObject(ObjectInputStream stream) throws IOException,
 			ClassNotFoundException {
 		ObjectInputStream.GetField fields = stream.readFields();
-		permissions = (Hashtable) fields.get("permissions", null); //$NON-NLS-1$
+		permissions = (Hashtable<String, Permission>) fields.get("permissions", null); //$NON-NLS-1$
 	}
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java?rev=415066&r1=415065&r2=415066&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java Sat Jun 17 14:39:53 2006
@@ -116,20 +116,25 @@
 	 */
 	public static ResourceBundle getBundle(String bundleName, Locale locale,
 			ClassLoader loader) throws MissingResourceException {
-		if (loader == null)
-			throw new NullPointerException();
+		if (loader == null) {
+            throw new NullPointerException();
+        }
 		if (bundleName != null) {
 			ResourceBundle bundle;
-			if (!locale.equals(Locale.getDefault()))
-				if ((bundle = handleGetBundle(bundleName, "_" + locale, false, //$NON-NLS-1$
-						loader)) != null)
-					return bundle;
+			if (!locale.equals(Locale.getDefault())) {
+                if ((bundle = handleGetBundle(bundleName, "_" + locale, false, //$NON-NLS-1$
+						loader)) != null) {
+                    return bundle;
+                }
+            }
 			if ((bundle = handleGetBundle(bundleName,
-					"_" + Locale.getDefault(), true, loader)) != null) //$NON-NLS-1$
-				return bundle;
+					"_" + Locale.getDefault(), true, loader)) != null) {
+                return bundle;
+            }
 			throw new MissingResourceException(null, bundleName, ""); //$NON-NLS-1$
-		} else
-			throw new NullPointerException();
+		} else {
+            throw new NullPointerException();
+        }
 	}
 
 	private static ResourceBundle getBundleImpl(String bundleName,
@@ -138,20 +143,25 @@
 			ResourceBundle bundle;
 			if (!locale.equals(Locale.getDefault())) {
 				String localeName = locale.toString();
-				if (localeName.length() > 0)
-					localeName = "_" + localeName; //$NON-NLS-1$
+				if (localeName.length() > 0) {
+                    localeName = "_" + localeName; //$NON-NLS-1$
+                }
 				if ((bundle = handleGetBundle(bundleName, localeName, false,
-						loader)) != null)
-					return bundle;
+						loader)) != null) {
+                    return bundle;
+                }
 			}
 			String localeName = Locale.getDefault().toString();
-			if (localeName.length() > 0)
-				localeName = "_" + localeName; //$NON-NLS-1$
-			if ((bundle = handleGetBundle(bundleName, localeName, true, loader)) != null)
-				return bundle;
+			if (localeName.length() > 0) {
+                localeName = "_" + localeName; //$NON-NLS-1$
+            }
+			if ((bundle = handleGetBundle(bundleName, localeName, true, loader)) != null) {
+                return bundle;
+            }
 			throw new MissingResourceException(null, bundleName, ""); //$NON-NLS-1$
-		} else
-			throw new NullPointerException();
+		} else {
+            throw new NullPointerException();
+        }
 	}
 
 	/**
@@ -184,8 +194,9 @@
 		ResourceBundle last, theParent = this;
 		do {
 			Object result = theParent.handleGetObject(key);
-			if (result != null)
-				return result;
+			if (result != null) {
+                return result;
+            }
 			last = theParent;
 			theParent = theParent.parent;
 		} while (theParent != null);
@@ -227,7 +238,7 @@
 		Object cacheKey = loader != null ? (Object) loader : (Object) "null"; //$NON-NLS-1$
 		Hashtable<String,ResourceBundle> loaderCache;
 		synchronized (cache) {
-			loaderCache = (Hashtable<String,ResourceBundle>) cache.get(cacheKey);
+			loaderCache = cache.get(cacheKey);
 			if (loaderCache == null) {
 				loaderCache = new Hashtable<String,ResourceBundle>(13);
 				cache.put(cacheKey, loaderCache);
@@ -235,21 +246,24 @@
 		}
 		ResourceBundle result = loaderCache.get(bundleName);
 		if (result != null) {
-			if (result == MISSINGBASE)
-				return null;
+			if (result == MISSINGBASE) {
+                return null;
+            }
 			if (result == MISSING) {
-				if (!loadBase)
-					return null;
+				if (!loadBase) {
+                    return null;
+                }
 				String extension = strip(locale);
-				if (extension == null)
-					return null;
+				if (extension == null) {
+                    return null;
+                }
 				return handleGetBundle(base, extension, loadBase, loader);
 			}
 			return result;
 		}
 
 		try {
-			Class bundleClass = Class.forName(bundleName, true, loader);
+			Class<?> bundleClass = Class.forName(bundleName, true, loader);
 			bundle = (ResourceBundle) bundleClass.newInstance();
 			bundle.setLocale(locale);
 		} catch (Exception e) {
@@ -282,8 +296,9 @@
 			if (extension != null) {
 				ResourceBundle parent = handleGetBundle(base, extension, true,
 						loader);
-				if (parent != null)
-					bundle.setParent(parent);
+				if (parent != null) {
+                    bundle.setParent(parent);
+                }
 			}
 			loaderCache.put(bundleName, bundle);
 			return bundle;
@@ -323,8 +338,9 @@
 
 	private static String strip(String name) {
 		int index = name.lastIndexOf('_');
-		if (index != -1)
-			return name.substring(0, index);
+		if (index != -1) {
+            return name.substring(0, index);
+        }
 		return null;
 	}
 
@@ -332,17 +348,20 @@
 		String language = "", country = "", variant = "";  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
 		if (name.length() > 1) {
 			int nextIndex = name.indexOf('_', 1);
-			if (nextIndex == -1)
-				nextIndex = name.length();
+			if (nextIndex == -1) {
+                nextIndex = name.length();
+            }
 			language = name.substring(1, nextIndex);
 			if (nextIndex + 1 < name.length()) {
 				int index = nextIndex;
 				nextIndex = name.indexOf('_', nextIndex + 1);
-				if (nextIndex == -1)
-					nextIndex = name.length();
+				if (nextIndex == -1) {
+                    nextIndex = name.length();
+                }
 				country = name.substring(index + 1, nextIndex);
-				if (nextIndex + 1 < name.length())
-					variant = name.substring(nextIndex + 1, name.length());
+				if (nextIndex + 1 < name.length()) {
+                    variant = name.substring(nextIndex + 1, name.length());
+                }
 			}
 		}
 		locale = new Locale(language, country, variant);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java?rev=415066&r1=415065&r2=415066&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java Sat Jun 17 14:39:53 2006
@@ -51,7 +51,7 @@
 	 */
 	public static final int LONG = 1;
 
-	private static HashMap AvailableZones;
+	private static HashMap<String, TimeZone> AvailableZones;
 
 	private static TimeZone Default;
 
@@ -61,10 +61,11 @@
 
 	private static void initializeAvailable() {
 		TimeZone[] zones = TimeZones.getTimeZones();
-		AvailableZones = new HashMap((zones.length + 1) * 4 / 3);
+		AvailableZones = new HashMap<String, TimeZone>((zones.length + 1) * 4 / 3);
 		AvailableZones.put(GMT.getID(), GMT);
-		for (int i = 0; i < zones.length; i++)
-			AvailableZones.put(zones[i].getID(), zones[i]);
+		for (int i = 0; i < zones.length; i++) {
+            AvailableZones.put(zones[i].getID(), zones[i]);
+        }
 	}
 
 	/**
@@ -76,9 +77,11 @@
 
 	private void appendNumber(StringBuffer buffer, int count, int value) {
 		String string = Integer.toString(value);
-		if (count > string.length())
-			for (int i = 0; i < count - string.length(); i++)
-				buffer.append('0');
+		if (count > string.length()) {
+            for (int i = 0; i < count - string.length(); i++) {
+                buffer.append('0');
+            }
+        }
 		buffer.append(string);
 	}
 
@@ -105,13 +108,15 @@
 	 * @return an array of time zone ID strings
 	 */
 	public static synchronized String[] getAvailableIDs() {
-		if (AvailableZones == null)
-			initializeAvailable();
+		if (AvailableZones == null) {
+            initializeAvailable();
+        }
 		int length = AvailableZones.size();
 		String[] answer = new String[length];
-		Iterator keys = AvailableZones.keySet().iterator();
-		for (int i = 0; i < length; i++)
-			answer[i] = (String) keys.next();
+		Iterator<String> keys = AvailableZones.keySet().iterator();
+		for (int i = 0; i < length; i++) {
+            answer[i] = keys.next();
+        }
 		return answer;
 	}
 
@@ -124,15 +129,17 @@
 	 * @return an array of time zone ID strings
 	 */
 	public static synchronized String[] getAvailableIDs(int offset) {
-		if (AvailableZones == null)
-			initializeAvailable();
+		if (AvailableZones == null) {
+            initializeAvailable();
+        }
 		int count = 0, length = AvailableZones.size();
 		String[] all = new String[length];
-		Iterator zones = AvailableZones.values().iterator();
+		Iterator<TimeZone> zones = AvailableZones.values().iterator();
 		for (int i = 0; i < length; i++) {
-			TimeZone tz = (TimeZone) zones.next();
-			if (tz.getRawOffset() == offset)
-				all[count++] = tz.getID();
+			TimeZone tz = zones.next();
+			if (tz.getRawOffset() == offset) {
+                all[count++] = tz.getID();
+            }
 		}
 		String[] answer = new String[count];
 		System.arraycopy(all, 0, answer, 0, count);
@@ -145,8 +152,9 @@
 	 * @return the default time zone
 	 */
 	public static synchronized TimeZone getDefault() {
-		if (Default == null)
-			setDefault(null);
+		if (Default == null) {
+            setDefault(null);
+        }
 		return (TimeZone) Default.clone();
 	}
 
@@ -176,7 +184,7 @@
 
 	/**
 	 * Gets the specified style of name (LONG or SHORT) for this TimeZone for
-	 * the default Locale in either standard or daylight time as specifed. If
+	 * the default Locale in either standard or daylight time as specified. If
 	 * the name is not available, the result is in the format GMT[+-]hh:mm.
 	 * 
 	 * @param daylightTime
@@ -191,7 +199,7 @@
 
 	/**
 	 * Gets the specified style of name (LONG or SHORT) for this TimeZone for
-	 * the specified Locale in either standard or daylight time as specifed. If
+	 * the specified Locale in either standard or daylight time as specified. If
 	 * the name is not available, the result is in the format GMT[+-]hh:mm.
 	 * 
 	 * @param daylightTime
@@ -208,13 +216,16 @@
 			DateFormatSymbols data = new DateFormatSymbols(locale);
 			String id = getID();
 			String[][] zones = data.getZoneStrings();
-			for (int i = 0; i < zones.length; i++)
-				if (id.equals(zones[i][0]))
-					return style == SHORT ? zones[i][useDaylight ? 4 : 2]
+			for (int i = 0; i < zones.length; i++) {
+                if (id.equals(zones[i][0])) {
+                    return style == SHORT ? zones[i][useDaylight ? 4 : 2]
 							: zones[i][useDaylight ? 3 : 1];
+                }
+            }
 			int offset = getRawOffset();
-			if (useDaylight && this instanceof SimpleTimeZone)
-				offset += ((SimpleTimeZone) this).getDSTSavings();
+			if (useDaylight && this instanceof SimpleTimeZone) {
+                offset += ((SimpleTimeZone) this).getDSTSavings();
+            }
 			offset /= 60000;
 			char sign = '+';
 			if (offset < 0) {
@@ -251,7 +262,7 @@
 	 * hour.
 	 * <p>
 	 * 
-	 * @return the daylight savings offset in milliseconds if this Timezone
+	 * @return the daylight savings offset in milliseconds if this TimeZone
 	 *         observes daylight savings, zero otherwise.
 	 * 
 	 */
@@ -317,9 +328,10 @@
 	 *         the specified ID does not exist
 	 */
 	public static synchronized TimeZone getTimeZone(String name) {
-		if (AvailableZones == null)
-			initializeAvailable();
-		TimeZone zone = (TimeZone) AvailableZones.get(name);
+		if (AvailableZones == null) {
+            initializeAvailable();
+        }
+		TimeZone zone = AvailableZones.get(name);
 		if (zone == null) {
 			if (name.startsWith("GMT") && name.length() > 3) {
 				char sign = name.charAt(3);
@@ -337,14 +349,16 @@
 								&& formattedName.charAt(index) == ':') {
 							int minute = parseNumber(formattedName, index + 1,
 									position);
-							if (position[0] == -1 || minute < 0 || minute > 59)
-								return (TimeZone) GMT.clone();
+							if (position[0] == -1 || minute < 0 || minute > 59) {
+                                return (TimeZone) GMT.clone();
+                            }
 							raw += minute * 60000;
 						} else if (hour >= 30 || index > 6) {
 							raw = (hour / 100 * 3600000) + (hour % 100 * 60000);
 						}
-						if (sign == '-')
-							raw = -raw;
+						if (sign == '-') {
+                            raw = -raw;
+                        }
 						return new SimpleTimeZone(raw, formattedName);
 					}
 				}
@@ -392,8 +406,9 @@
 	 * @return true when the TimeZones have the same raw offset, false otherwise
 	 */
 	public boolean hasSameRules(TimeZone zone) {
-		if (zone == null)
-			return false;
+		if (zone == null) {
+            return false;
+        }
 		return getRawOffset() == zone.getRawOffset();
 	}
 
@@ -431,7 +446,7 @@
 			return;
 		}
 
-		String zone = (String) AccessController.doPrivileged(new PriviAction(
+		String zone = AccessController.doPrivileged(new PriviAction<String>(
 				"user.timezone"));
 
 		// if property user.timezone is not set, we call the native method
@@ -473,8 +488,9 @@
 	 *            a string which is the time zone ID
 	 */
 	public void setID(String name) {
-		if (name == null)
-			throw new NullPointerException();
+		if (name == null) {
+            throw new NullPointerException();
+        }
 		ID = name;
 	}
 



Mime
View raw message