harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r491834 [5/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/
Date Tue, 02 Jan 2007 16:22:07 GMT
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Formatter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Formatter.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Formatter.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Formatter.java Tue
Jan  2 08:22:05 2007
@@ -47,13 +47,14 @@
  * 
  * 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 {
 
     public enum BigDecimalLayoutForm {
         SCIENTIFIC, DECIMAL_FLOAT
-    };
+    }
 
     private Appendable out;
 
@@ -70,7 +71,6 @@
      * method and whose contents can be attained by calling the toString method.
      * 
      * The locale for the formatter is the default locale of the JVM.
-     * 
      */
     public Formatter() {
         this(new StringBuilder(), Locale.getDefault());
@@ -426,8 +426,8 @@
     }
 
     /**
-     * Flushes the formatter. If the output destination is {@link Flushable}, then the
-     * method flush() will be called on that destination.
+     * Flushes the formatter. If the output destination is {@link Flushable},
+     * then the method flush() will be called on that destination.
      * 
      * @throws FormatterClosedException
      *             If the formatter has been closed.
@@ -444,8 +444,8 @@
     }
 
     /**
-     * Closes the formatter. If the output destination is {@link Closeable}, then the
-     * method close() will be called on that destination.
+     * 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
      * effect.
@@ -503,8 +503,8 @@
      * 
      * @param l
      *            The locale used in the method. If locale is null, then no
-     *            localization will be applied. This parameter does not influence
-     *            the locale specified during construction.
+     *            localization will be applied. This parameter does not
+     *            influence the locale specified during construction.
      * @param format
      *            A format string.
      * @param args
@@ -606,7 +606,7 @@
         static final int LAST_ARGUMENT_INDEX = -2;
 
         static final int UNSET = -1;
-        
+
         static final int FLAGS_UNSET = 0;
 
         static final int DEFAULT_PRECISION = 6;
@@ -648,10 +648,11 @@
         boolean isPrecisionSet() {
             return precision != UNSET;
         }
-        
+
         boolean isWidthSet() {
             return width != UNSET;
         }
+
         boolean isFlagSet(int flag) {
             return 0 != (flags & flag);
         }
@@ -707,36 +708,36 @@
         boolean setFlag(char c) {
             int newFlag;
             switch (c) {
-            case '-': {
-                newFlag = FLAG_MINUS;
-                break;
-            }
-            case '#': {
-                newFlag = FLAG_SHARP;
-                break;
-            }
-            case '+': {
-                newFlag = FLAG_ADD;
-                break;
-            }
-            case ' ': {
-                newFlag = FLAG_SPACE;
-                break;
-            }
-            case '0': {
-                newFlag = FLAG_ZERO;
-                break;
-            }
-            case ',': {
-                newFlag = FLAG_COMMA;
-                break;
-            }
-            case '(': {
-                newFlag = FLAG_PARENTHESIS;
-                break;
-            }
-            default:
-                return false;
+                case '-': {
+                    newFlag = FLAG_MINUS;
+                    break;
+                }
+                case '#': {
+                    newFlag = FLAG_SHARP;
+                    break;
+                }
+                case '+': {
+                    newFlag = FLAG_ADD;
+                    break;
+                }
+                case ' ': {
+                    newFlag = FLAG_SPACE;
+                    break;
+                }
+                case '0': {
+                    newFlag = FLAG_ZERO;
+                    break;
+                }
+                case ',': {
+                    newFlag = FLAG_COMMA;
+                    break;
+                }
+                case '(': {
+                    newFlag = FLAG_PARENTHESIS;
+                    break;
+                }
+                default:
+                    return false;
             }
             if (0 != (flags & newFlag)) {
                 throw new DuplicateFormatFlagsException(String.valueOf(c));
@@ -821,8 +822,7 @@
          * Gets the formatted string according to the format token and the
          * argument.
          */
-        String transform(FormatToken token,
-                Object argument) {
+        String transform(FormatToken token, Object argument) {
 
             /* init data member to print */
             this.formatToken = token;
@@ -830,64 +830,64 @@
 
             String result;
             switch (token.getConversionType()) {
-            case 'B':
-            case 'b': {
-                result = transformFromBoolean();
-                break;
-            }
-            case 'H':
-            case 'h': {
-                result = transformFromHashCode();
-                break;
-            }
-            case 'S':
-            case 's': {
-                result = transformFromString();
-                break;
-            }
-            case 'C':
-            case 'c': {
-                result = transformFromCharacter();
-                break;
-            }
-            case 'd':
-            case 'o':
-            case 'x':
-            case 'X': {
-                if (null == arg || arg instanceof BigInteger) {
-                    result = transformFromBigInteger();
-                } else {
-                    result = transformFromInteger();
+                case 'B':
+                case 'b': {
+                    result = transformFromBoolean();
+                    break;
+                }
+                case 'H':
+                case 'h': {
+                    result = transformFromHashCode();
+                    break;
+                }
+                case 'S':
+                case 's': {
+                    result = transformFromString();
+                    break;
+                }
+                case 'C':
+                case 'c': {
+                    result = transformFromCharacter();
+                    break;
+                }
+                case 'd':
+                case 'o':
+                case 'x':
+                case 'X': {
+                    if (null == arg || arg instanceof BigInteger) {
+                        result = transformFromBigInteger();
+                    } else {
+                        result = transformFromInteger();
+                    }
+                    break;
+                }
+                case 'e':
+                case 'E':
+                case 'g':
+                case 'G':
+                case 'f':
+                case 'a':
+                case 'A': {
+                    result = transformFromFloat();
+                    break;
+                }
+                case '%': {
+                    result = transformFromPercent();
+                    break;
+                }
+                case 'n': {
+                    result = transfromFromLineSeparator();
+                    break;
+                }
+                case 't':
+                case 'T': {
+                    result = transformFromDateTime();
+                    break;
+                }
+                default: {
+                    throw new UnknownFormatConversionException(String
+                            .valueOf(token.getConversionType()));
                 }
-                break;
-            }
-            case 'e':
-            case 'E':
-            case 'g':
-            case 'G':
-            case 'f':
-            case 'a':
-            case 'A': {
-                result = transformFromFloat();
-                break;
-            }
-            case '%': {
-                result = transformFromPercent();
-                break;
-            }
-            case 'n': {
-                result = transfromFromLineSeparator();
-                break;
-            }
-            case 't':
-            case 'T': {
-                result = transformFromDateTime();
-                break;
-            }
-            default: {
-                throw new UnknownFormatConversionException(String
-                        .valueOf(token.getConversionType()));
-            }
             }
 
             if (Character.isUpperCase(token.getConversionType())) {
@@ -913,7 +913,8 @@
             }
 
             // only '-' is valid for flags
-            if (FormatToken.FLAGS_UNSET != flags && FormatToken.FLAG_MINUS != flags)
{
+            if (FormatToken.FLAGS_UNSET != flags
+                    && FormatToken.FLAG_MINUS != flags) {
                 throw new FormatFlagsConversionMismatchException(formatToken
                         .getStrFlags(), formatToken.getConversionType());
             }
@@ -944,7 +945,8 @@
             }
 
             // only '-' is valid for flags
-            if (FormatToken.FLAGS_UNSET != flags && FormatToken.FLAG_MINUS != flags)
{
+            if (FormatToken.FLAGS_UNSET != flags
+                    && FormatToken.FLAG_MINUS != flags) {
                 throw new FormatFlagsConversionMismatchException(formatToken
                         .getStrFlags(), formatToken.getConversionType());
             }
@@ -994,13 +996,13 @@
                 // returns null, which tells the Parser to add nothing to the
                 // output.
                 return null;
-            } 
+            }
             // only '-' is valid for flags if the argument is not an
             // instance of Formattable
-            if (FormatToken.FLAGS_UNSET != flags && FormatToken.FLAG_MINUS != flags)
{
-                throw new FormatFlagsConversionMismatchException(
-                        formatToken.getStrFlags(), formatToken
-                                .getConversionType());
+            if (FormatToken.FLAGS_UNSET != flags
+                    && FormatToken.FLAG_MINUS != flags) {
+                throw new FormatFlagsConversionMismatchException(formatToken
+                        .getStrFlags(), formatToken.getConversionType());
             }
 
             result.append(arg);
@@ -1023,10 +1025,10 @@
             }
 
             // only '-' is valid for flags
-            if (FormatToken.FLAGS_UNSET != flags && FormatToken.FLAG_MINUS != flags)
{
+            if (FormatToken.FLAGS_UNSET != flags
+                    && FormatToken.FLAG_MINUS != flags) {
                 throw new FormatFlagsConversionMismatchException(formatToken
-                        .getStrFlags(), formatToken
-                        .getConversionType());
+                        .getStrFlags(), formatToken.getConversionType());
             }
 
             if (formatToken.isPrecisionSet()) {
@@ -1041,7 +1043,7 @@
                     result.append(arg);
                 } else if (arg instanceof Byte) {
                     byte b = ((Byte) arg).byteValue();
-                    if(!Character.isValidCodePoint(b)){
+                    if (!Character.isValidCodePoint(b)) {
                         throw new IllegalFormatCodePointException(b);
                     }
                     result.append((char) b);
@@ -1056,8 +1058,7 @@
                     if (!Character.isValidCodePoint(codePoint)) {
                         throw new IllegalFormatCodePointException(codePoint);
                     }
-                        result.append(String.valueOf(Character
-                                .toChars(codePoint)));
+                    result.append(String.valueOf(Character.toChars(codePoint)));
                 } else {
                     // argument of other class is not acceptable.
                     throw new IllegalFormatConversionException(formatToken
@@ -1083,7 +1084,8 @@
                         + formatToken.getConversionType());
             }
 
-            if (FormatToken.FLAGS_UNSET != flags && FormatToken.FLAG_MINUS != flags)
{
+            if (FormatToken.FLAGS_UNSET != flags
+                    && FormatToken.FLAG_MINUS != flags) {
                 throw new FormatFlagsConversionMismatchException(formatToken
                         .getStrFlags(), formatToken.getConversionType());
             }
@@ -1239,7 +1241,6 @@
                 throw new IllegalFormatFlagsException(formatToken.getStrFlags());
             }
 
-
             if (value < 0) {
                 isNegative = true;
             }
@@ -1253,9 +1254,9 @@
                 }
                 result.append(numberFormat.format(arg));
             } else {
-                long BYTE_MASK  = 0x00000000000000FFL;
+                long BYTE_MASK = 0x00000000000000FFL;
                 long SHORT_MASK = 0x000000000000FFFFL;
-                long INT_MASK   = 0x00000000FFFFFFFFL;
+                long INT_MASK = 0x00000000FFFFFFFFL;
                 if (isNegative) {
                     if (arg instanceof Byte) {
                         value &= BYTE_MASK;
@@ -1299,12 +1300,12 @@
 
         /*
          * add () to the output,if the value is negative and
-         * formatToken.FLAG_PARENTHESIS is set. 'result' is used as an
-         * in-out parameter. 
+         * formatToken.FLAG_PARENTHESIS is set. 'result' is used as an in-out
+         * parameter.
          */
         private StringBuilder wrapParentheses(StringBuilder result) {
             // delete the '-'
-            result.deleteCharAt(0); 
+            result.deleteCharAt(0);
             result.insert(0, '(');
             if (formatToken.isFlagSet(FormatToken.FLAG_ZERO)) {
                 formatToken.setWidth(formatToken.getWidth() - 1);
@@ -1384,9 +1385,9 @@
                     && formatToken.isFlagSet(FormatToken.FLAG_SPACE)) {
                 throw new IllegalFormatFlagsException(formatToken.getStrFlags());
             }
-            
+
             // Combination of '-' & '0' is illegal.
-            if(formatToken.isFlagSet(FormatToken.FLAG_ZERO)
+            if (formatToken.isFlagSet(FormatToken.FLAG_ZERO)
                     && formatToken.isFlagSet(FormatToken.FLAG_MINUS)) {
                 throw new IllegalFormatFlagsException(formatToken.getStrFlags());
             }
@@ -1416,7 +1417,8 @@
 
             if ('d' == currentConversionType) {
                 NumberFormat numberFormat = getNumberFormat();
-                boolean readableName = formatToken.isFlagSet(FormatToken.FLAG_COMMA); 
+                boolean readableName = formatToken
+                        .isFlagSet(FormatToken.FLAG_COMMA);
                 numberFormat.setGroupingUsed(readableName);
                 result.append(numberFormat.format(bigInt));
             } else if ('o' == currentConversionType) {
@@ -1431,8 +1433,8 @@
                 if ('o' == currentConversionType) {
                     result.insert(startIndex, "0"); //$NON-NLS-1$
                     startIndex += 1;
-                } else if( 'x' == currentConversionType ||
-                        'X' == currentConversionType){
+                } else if ('x' == currentConversionType
+                        || 'X' == currentConversionType) {
                     result.insert(startIndex, "0x"); //$NON-NLS-1$
                     startIndex += 2;
                 }
@@ -1470,7 +1472,8 @@
             int startIndex = 0;
             char currentConversionType = formatToken.getConversionType();
 
-            if (formatToken.isFlagSet(FormatToken.FLAG_MINUS | FormatToken.FLAG_ZERO)) {
+            if (formatToken.isFlagSet(FormatToken.FLAG_MINUS
+                    | FormatToken.FLAG_ZERO)) {
                 if (!formatToken.isWidthSet()) {
                     throw new MissingFormatWidthException(formatToken
                             .getStrFlags());
@@ -1598,11 +1601,12 @@
             } else {
                 Date date = null;
                 if (arg instanceof Long) {
-                    date = new Date(((Long)arg).longValue());
+                    date = new Date(((Long) arg).longValue());
                 } else if (arg instanceof Date) {
                     date = (Date) arg;
                 } else {
-                    throw new IllegalFormatConversionException(currentConversionType, arg.getClass());
+                    throw new IllegalFormatConversionException(
+                            currentConversionType, arg.getClass());
                 }
                 calendar = Calendar.getInstance(locale);
                 calendar.setTime(date);
@@ -1617,7 +1621,7 @@
             return padding(result, startIndex);
         }
     }
-    
+
     private static class FloatUtil {
         private StringBuilder result;
 
@@ -1638,34 +1642,34 @@
             this.minusSign = decimalFormat.getDecimalFormatSymbols()
                     .getMinusSign();
         }
-        
+
         void transform(FormatToken aFormatToken, StringBuilder aResult) {
             this.result = aResult;
             this.formatToken = aFormatToken;
             switch (formatToken.getConversionType()) {
-            case 'e':
-            case 'E': {
-                transform_e();
-                break;
-            }
-            case 'f': {
-                transform_f();
-                break;
-            }
-            case 'g':
-            case 'G': {
-                transform_g();
-                break;
-            }
-            case 'a':
-            case 'A': {
-                transform_a();
-                break;
-            }
-            default: {
-                throw new UnknownFormatConversionException(String
-                        .valueOf(formatToken.getConversionType()));
-            }
+                case 'e':
+                case 'E': {
+                    transform_e();
+                    break;
+                }
+                case 'f': {
+                    transform_f();
+                    break;
+                }
+                case 'g':
+                case 'G': {
+                    transform_g();
+                    break;
+                }
+                case 'a':
+                case 'A': {
+                    transform_a();
+                    break;
+                }
+                default: {
+                    throw new UnknownFormatConversionException(String
+                            .valueOf(formatToken.getConversionType()));
+                }
             }
         }
 
@@ -1807,7 +1811,8 @@
                 result.append(Double.toHexString(D.doubleValue()));
             } else {
                 // BigInteger is not supported.
-                throw new IllegalFormatConversionException(currentConversionType, argument.getClass());
+                throw new IllegalFormatConversionException(
+                        currentConversionType, argument.getClass());
             }
 
             if (!formatToken.isPrecisionSet()) {
@@ -1830,9 +1835,7 @@
                 result.insert(indexOfP, zeros);
                 return;
             }
-            result
-                    .delete(indexOfFirstFracitoanlDigit + precision,
-                            indexOfP);
+            result.delete(indexOfFirstFracitoanlDigit + precision, indexOfP);
         }
     }
 
@@ -1856,133 +1859,133 @@
             char suffix = formatToken.getDateSuffix();
 
             switch (suffix) {
-            case 'H': {
-                transform_H();
-                break;
-            }
-            case 'I': {
-                transform_I();
-                break;
-            }
-            case 'M': {
-                transform_M();
-                break;
-            }
-            case 'S': {
-                transform_S();
-                break;
-            }
-            case 'L': {
-                transform_L();
-                break;
-            }
-            case 'N': {
-                transform_N();
-                break;
-            }
-            case 'k': {
-                transform_k();
-                break;
-            }
-            case 'l': {
-                transform_l();
-                break;
-            }
-            case 'p': {
-                transform_p(true);
-                break;
-            }
-            case 's': {
-                transform_s();
-                break;
-            }
-            case 'z': {
-                transform_z();
-                break;
-            }
-            case 'Z': {
-                transform_Z();
-                break;
-            }
-            case 'Q': {
-                transform_Q();
-                break;
-            }
-            case 'B': {
-                transform_B();
-                break;
-            }
-            case 'b':
-            case 'h': {
-                transform_b();
-                break;
-            }
-            case 'A': {
-                transform_A();
-                break;
-            }
-            case 'a': {
-                transform_a();
-                break;
-            }
-            case 'C': {
-                transform_C();
-                break;
-            }
-            case 'Y': {
-                transform_Y();
-                break;
-            }
-            case 'y': {
-                transform_y();
-                break;
-            }
-            case 'j': {
-                transform_j();
-                break;
-            }
-            case 'm': {
-                transform_m();
-                break;
-            }
-            case 'd': {
-                transform_d();
-                break;
-            }
-            case 'e': {
-                transform_e();
-                break;
-            }
-            case 'R': {
-                transform_R();
-                break;
-            }
+                case 'H': {
+                    transform_H();
+                    break;
+                }
+                case 'I': {
+                    transform_I();
+                    break;
+                }
+                case 'M': {
+                    transform_M();
+                    break;
+                }
+                case 'S': {
+                    transform_S();
+                    break;
+                }
+                case 'L': {
+                    transform_L();
+                    break;
+                }
+                case 'N': {
+                    transform_N();
+                    break;
+                }
+                case 'k': {
+                    transform_k();
+                    break;
+                }
+                case 'l': {
+                    transform_l();
+                    break;
+                }
+                case 'p': {
+                    transform_p(true);
+                    break;
+                }
+                case 's': {
+                    transform_s();
+                    break;
+                }
+                case 'z': {
+                    transform_z();
+                    break;
+                }
+                case 'Z': {
+                    transform_Z();
+                    break;
+                }
+                case 'Q': {
+                    transform_Q();
+                    break;
+                }
+                case 'B': {
+                    transform_B();
+                    break;
+                }
+                case 'b':
+                case 'h': {
+                    transform_b();
+                    break;
+                }
+                case 'A': {
+                    transform_A();
+                    break;
+                }
+                case 'a': {
+                    transform_a();
+                    break;
+                }
+                case 'C': {
+                    transform_C();
+                    break;
+                }
+                case 'Y': {
+                    transform_Y();
+                    break;
+                }
+                case 'y': {
+                    transform_y();
+                    break;
+                }
+                case 'j': {
+                    transform_j();
+                    break;
+                }
+                case 'm': {
+                    transform_m();
+                    break;
+                }
+                case 'd': {
+                    transform_d();
+                    break;
+                }
+                case 'e': {
+                    transform_e();
+                    break;
+                }
+                case 'R': {
+                    transform_R();
+                    break;
+                }
 
-            case 'T': {
-                transform_T();
-                break;
-            }
-            case 'r': {
-                transform_r();
-                break;
-            }
-            case 'D': {
-                transform_D();
-                break;
-            }
-            case 'F': {
-                transform_F();
-                break;
-            }
-            case 'c': {
-                transform_c();
-                break;
-            }
-            default: {
-                throw new UnknownFormatConversionException(String
-                        .valueOf(formatToken.getConversionType())
-                        + formatToken.getDateSuffix());
-            }
+                case 'T': {
+                    transform_T();
+                    break;
+                }
+                case 'r': {
+                    transform_r();
+                    break;
+                }
+                case 'D': {
+                    transform_D();
+                    break;
+                }
+                case 'F': {
+                    transform_F();
+                    break;
+                }
+                case 'c': {
+                    transform_c();
+                    break;
+                }
+                default: {
+                    throw new UnknownFormatConversionException(String
+                            .valueOf(formatToken.getConversionType())
+                            + formatToken.getDateSuffix());
+                }
             }
         }
 
@@ -2271,41 +2274,41 @@
                 }
 
                 switch (state) {
-                // exit state
-                case ParserStateMachine.EXIT_STATE: {
-                    process_EXIT_STATE();
-                    return token;
-                }
-                    // plain text state, not yet applied converter
-                case ParserStateMachine.ENTRY_STATE: {
-                    process_ENTRY_STATE();
-                    break;
-                }
-                    // begins converted string
-                case ParserStateMachine.START_CONVERSION_STATE: {
-                    process_START_CONVERSION_STATE();
-                    break;
-                }
-                case ParserStateMachine.FLAGS_STATE: {
-                    process_FlAGS_STATE();
-                    break;
-                }
-                case ParserStateMachine.WIDTH_STATE: {
-                    process_WIDTH_STATE();
-                    break;
-                }
-                case ParserStateMachine.PRECISION_STATE: {
-                    process_PRECISION_STATE();
-                    break;
-                }
-                case ParserStateMachine.CONVERSION_TYPE_STATE: {
-                    process_CONVERSION_TYPE_STATE();
-                    break;
-                }
-                case ParserStateMachine.SUFFIX_STATE: {
-                    process_SUFFIX_STATE();
-                    break;
-                }
+                    // exit state
+                    case ParserStateMachine.EXIT_STATE: {
+                        process_EXIT_STATE();
+                        return token;
+                    }
+                        // plain text state, not yet applied converter
+                    case ParserStateMachine.ENTRY_STATE: {
+                        process_ENTRY_STATE();
+                        break;
+                    }
+                        // begins converted string
+                    case ParserStateMachine.START_CONVERSION_STATE: {
+                        process_START_CONVERSION_STATE();
+                        break;
+                    }
+                    case ParserStateMachine.FLAGS_STATE: {
+                        process_FlAGS_STATE();
+                        break;
+                    }
+                    case ParserStateMachine.WIDTH_STATE: {
+                        process_WIDTH_STATE();
+                        break;
+                    }
+                    case ParserStateMachine.PRECISION_STATE: {
+                        process_PRECISION_STATE();
+                        break;
+                    }
+                    case ParserStateMachine.CONVERSION_TYPE_STATE: {
+                        process_CONVERSION_TYPE_STATE();
+                        break;
+                    }
+                    case ParserStateMachine.SUFFIX_STATE: {
+                        process_SUFFIX_STATE();
+                        break;
+                    }
                 }
             }
         }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java Tue
Jan  2 08:22:05 2007
@@ -32,7 +32,7 @@
 
     transient int elementCount;
 
-    transient Entry<K,V>[] elementData;
+    transient Entry<K, V>[] elementData;
 
     final float loadFactor;
 
@@ -44,6 +44,7 @@
 
     static class Entry<K, V> extends MapEntry<K, V> {
         final int origKeyHash;
+
         Entry<K, V> next;
 
         Entry(K theKey, V theValue) {
@@ -54,30 +55,30 @@
         @Override
         @SuppressWarnings("unchecked")
         public Object clone() {
-            Entry<K,V> entry = (Entry<K,V>) super.clone();
+            Entry<K, V> entry = (Entry<K, V>) super.clone();
             if (next != null) {
-                entry.next = (Entry<K,V>) next.clone();
+                entry.next = (Entry<K, V>) next.clone();
             }
             return entry;
         }
     }
 
-    static class HashMapIterator<E,KT,VT> implements Iterator<E> {
+    static class HashMapIterator<E, KT, VT> implements Iterator<E> {
         private int position = 0;
 
         int expectedModCount;
 
-        final MapEntry.Type<E,KT,VT> type;
+        final MapEntry.Type<E, KT, VT> type;
 
         boolean canRemove = false;
 
-        Entry<KT,VT> entry;
+        Entry<KT, VT> entry;
 
-        Entry<KT,VT> lastEntry;
+        Entry<KT, VT> lastEntry;
 
-        final HashMap<KT,VT> associatedMap;
+        final HashMap<KT, VT> associatedMap;
 
-        HashMapIterator(MapEntry.Type<E,KT,VT> value, HashMap<KT,VT> hm) {
+        HashMapIterator(MapEntry.Type<E, KT, VT> value, HashMap<KT, VT> hm) {
             associatedMap = hm;
             type = value;
             expectedModCount = hm.modCount;
@@ -109,7 +110,7 @@
                 throw new NoSuchElementException();
             }
 
-            MapEntry<KT,VT> result;
+            MapEntry<KT, VT> result;
             if (entry == null) {
                 result = lastEntry = associatedMap.elementData[position++];
                 entry = lastEntry.next;
@@ -134,7 +135,7 @@
             associatedMap.modCount++;
             if (lastEntry.next == entry) {
                 while (associatedMap.elementData[--position] == null) {
-                    ;
+                    // Do nothing
                 }
                 associatedMap.elementData[position] = associatedMap.elementData[position].next;
                 entry = null;
@@ -146,14 +147,14 @@
         }
     }
 
-    static class HashMapEntrySet<KT,VT> extends AbstractSet<Map.Entry<KT,VT>>
{
-        private final HashMap<KT,VT> associatedMap;
+    static class HashMapEntrySet<KT, VT> extends AbstractSet<Map.Entry<KT, VT>>
{
+        private final HashMap<KT, VT> associatedMap;
 
-        public HashMapEntrySet(HashMap<KT,VT> hm) {
+        public HashMapEntrySet(HashMap<KT, VT> hm) {
             associatedMap = hm;
         }
 
-        HashMap<KT,VT> hashMap() {
+        HashMap<KT, VT> hashMap() {
             return associatedMap;
         }
 
@@ -170,7 +171,7 @@
         @Override
         public boolean remove(Object object) {
             if (contains(object)) {
-                associatedMap.remove(((Map.Entry) object).getKey());
+                associatedMap.remove(((Map.Entry<?, ?>) object).getKey());
                 return true;
             }
             return false;
@@ -179,20 +180,21 @@
         @Override
         public boolean contains(Object object) {
             if (object instanceof Map.Entry) {
-                Entry<KT, VT> entry = associatedMap.getEntry(((Map.Entry) object)
-                        .getKey());
+                Entry<KT, VT> entry = associatedMap
+                        .getEntry(((Map.Entry<?, ?>) object).getKey());
                 return object.equals(entry);
             }
             return false;
         }
 
         @Override
-        public Iterator<Map.Entry<KT,VT>> iterator() {
-            return new HashMapIterator<Map.Entry<KT,VT>,KT,VT>(new MapEntry.Type<Map.Entry<KT,VT>,
KT, VT>() {
-                public Map.Entry<KT,VT> get(MapEntry<KT,VT> entry) {
-                    return entry;
-                }
-            }, associatedMap);
+        public Iterator<Map.Entry<KT, VT>> iterator() {
+            return new HashMapIterator<Map.Entry<KT, VT>, KT, VT>(
+                    new MapEntry.Type<Map.Entry<KT, VT>, KT, VT>() {
+                        public Map.Entry<KT, VT> get(MapEntry<KT, VT> entry)
{
+                            return entry;
+                        }
+                    }, associatedMap);
         }
     }
 
@@ -203,7 +205,7 @@
      * @return Reference to the element array
      */
     @SuppressWarnings("unchecked")
-    Entry<K,V>[] newElementArray(int s) {
+    Entry<K, V>[] newElementArray(int s) {
         return new Entry[s];
     }
 
@@ -298,12 +300,12 @@
     @SuppressWarnings("unchecked")
     public Object clone() {
         try {
-            HashMap<K,V> map = (HashMap<K,V>) super.clone();
+            HashMap<K, V> map = (HashMap<K, V>) super.clone();
             map.elementData = newElementArray(elementData.length);
-            Entry<K,V> entry;
+            Entry<K, V> entry;
             for (int i = 0; i < elementData.length; i++) {
                 if ((entry = elementData[i]) != null) {
-                    map.elementData[i] = (Entry<K,V>) entry.clone();
+                    map.elementData[i] = (Entry<K, V>) entry.clone();
                 }
             }
             return map;
@@ -363,7 +365,7 @@
     public boolean containsValue(Object value) {
         if (value != null) {
             for (int i = elementData.length; --i >= 0;) {
-                Entry<K,V> entry = elementData[i];
+                Entry<K, V> entry = elementData[i];
                 while (entry != null) {
                     if (value.equals(entry.value)) {
                         return true;
@@ -373,7 +375,7 @@
             }
         } else {
             for (int i = elementData.length; --i >= 0;) {
-                Entry<K,V> entry = elementData[i];
+                Entry<K, V> entry = elementData[i];
                 while (entry != null) {
                     if (entry.value == null) {
                         return true;
@@ -394,7 +396,7 @@
      */
     @Override
     public Set<Map.Entry<K, V>> entrySet() {
-        return new HashMapEntrySet<K,V>(this);
+        return new HashMapEntrySet<K, V>(this);
     }
 
     /**
@@ -413,7 +415,7 @@
         return null;
     }
 
-    Entry<K,V> getEntry(Object key) {
+    Entry<K, V> getEntry(Object key) {
         int index = getModuloHash(key);
         return findEntry(key, index);
     }
@@ -425,8 +427,8 @@
         return (key.hashCode() & 0x7FFFFFFF) % elementData.length;
     }
 
-    Entry<K,V> findEntry(Object key, int index) {
-        Entry<K,V> m;
+    Entry<K, V> findEntry(Object key, int index) {
+        Entry<K, V> m;
         m = elementData[index];
         if (key != null) {
             while (m != null && !keysEqual(key, m)) {
@@ -489,11 +491,12 @@
 
                 @Override
                 public Iterator<K> iterator() {
-                    return new HashMapIterator<K,K,V>(new MapEntry.Type<K,K,V>()
{
-                        public K get(MapEntry<K,V> entry) {
-                            return entry.key;
-                        }
-                    }, HashMap.this);
+                    return new HashMapIterator<K, K, V>(
+                            new MapEntry.Type<K, K, V>() {
+                                public K get(MapEntry<K, V> entry) {
+                                    return entry.key;
+                                }
+                            }, HashMap.this);
                 }
             };
         }
@@ -514,10 +517,10 @@
     public V put(K key, V value) {
         return putImpl(key, value);
     }
-    
+
     private V putImpl(K key, V value) {
         int index = getModuloHash(key);
-        Entry<K,V> entry = findEntry(key, index);
+        Entry<K, V> entry = findEntry(key, index);
 
         if (entry == null) {
             modCount++;
@@ -529,14 +532,14 @@
             createEntry(key, index, value);
             return null;
         }
-        
+
         V result = entry.value;
         entry.value = value;
         return result;
     }
 
-    Entry<K,V> createEntry(K key, int index, V value) {
-        Entry<K,V> entry = new Entry<K,V>(key, value);
+    Entry<K, V> createEntry(K key, int index, V value) {
+        Entry<K, V> entry = new Entry<K, V>(key, value);
         entry.next = elementData[index];
         elementData[index] = entry;
         return entry;
@@ -558,7 +561,7 @@
             putAllImpl(map);
         }
     }
-    
+
     private void putAllImpl(Map<? extends K, ? extends V> map) {
         int capacity = elementCount + map.size();
         if (capacity > threshold) {
@@ -574,12 +577,12 @@
 
         Entry<K, V>[] newData = newElementArray(length);
         for (int i = 0; i < elementData.length; i++) {
-            Entry<K,V> entry = elementData[i];
+            Entry<K, V> entry = elementData[i];
             while (entry != null) {
                 Object key = entry.key;
                 int index = key == null ? 0 : (key.hashCode() & 0x7FFFFFFF)
                         % length;
-                Entry<K,V> next = entry.next;
+                Entry<K, V> next = entry.next;
                 entry.next = newData[index];
                 newData[index] = entry;
                 entry = next;
@@ -610,10 +613,10 @@
         return null;
     }
 
-    Entry<K,V> removeEntry(Object key) {
+    Entry<K, V> removeEntry(Object key) {
         int index = 0;
-        Entry<K,V> entry;
-        Entry<K,V> last = null;
+        Entry<K, V> entry;
+        Entry<K, V> last = null;
         if (key != null) {
             index = (key.hashCode() & 0x7FFFFFFF) % elementData.length;
             entry = elementData[index];
@@ -679,11 +682,12 @@
 
                 @Override
                 public Iterator<V> iterator() {
-                    return new HashMapIterator<V,K,V>(new MapEntry.Type<V,K,V>()
{
-                        public V get(MapEntry<K,V> entry) {
-                            return entry.value;
-                        }
-                    }, HashMap.this);
+                    return new HashMapIterator<V, K, V>(
+                            new MapEntry.Type<V, K, V>() {
+                                public V get(MapEntry<K, V> entry) {
+                                    return entry.value;
+                                }
+                            }, HashMap.this);
                 }
             };
         }
@@ -696,7 +700,7 @@
         stream.writeInt(elementCount);
         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;
@@ -711,10 +715,11 @@
         elementData = newElementArray(length);
         elementCount = stream.readInt();
         for (int i = elementCount; --i >= 0;) {
-            K key = (K)stream.readObject();
-            int index = (null == key) ? 0 : (key.hashCode() & 0x7FFFFFFF) % length;
-            createEntry(key, index, (V)stream.readObject());
+            K key = (K) stream.readObject();
+            int index = (null == key) ? 0 : (key.hashCode() & 0x7FFFFFFF)
+                    % length;
+            createEntry(key, index, (V) stream.readObject());
         }
     }
-    
+
 }



Mime
View raw message