classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] small patch to clean up 'inner' classes


From: Dalibor Topic
Subject: [cp-patches] small patch to clean up 'inner' classes
Date: Thu, 03 Feb 2005 01:15:10 +0100
User-agent: Mozilla/5.0 (X11; U; Linux ppc; en-US; rv:1.7.5) Gecko/20050105 Debian/1.7.5-1

Hi all,

the attached patch cleans up the inner classes a bit, turning them into real, private, static final inner classes where possible. That causes less weird classes to hang around in our 'exported' APIs, and makes creating profiles for Classpath's libraries simpler. See http://article.gmane.org/gmane.comp.java.vm.kaffe.general/8028 for details.

2005-02-02  Dalibor Topic  <address@hidden>

        * libraries/javalib/gnu/regexp/RE.java,
        libraries/javalib/java/io/ObjectInputStream.java,
        libraries/javalib/java/io/ObjectStreamClass.java,
        libraries/javalib/java/lang/SecurityManager.java,
        libraries/javalib/java/security/AllPermission.java,
        libraries/javalib/java/security/BasicPermission.java,
        libraries/javalib/java/security/Permissions.java,
        libraries/javalib/java/text/MessageFormat.java,
        libraries/javalib/java/util/AbstractList.java:
        Made 'inner' classes real public static inner classes,
        and made them final where possible, or removed them where
        unused.

cheers,
dalibor topic
Index: gnu/regexp/RE.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/regexp/RE.java,v
retrieving revision 1.2
diff -u -r1.2 RE.java
--- gnu/regexp/RE.java  25 Sep 2004 17:29:13 -0000      1.2
+++ gnu/regexp/RE.java  2 Feb 2005 23:43:50 -0000
@@ -43,15 +43,6 @@
 import java.util.ResourceBundle;
 import java.util.Vector;
 
-class IntPair implements Serializable {
-  public int first, second;
-}
-
-class CharUnit implements Serializable {
-  public char ch;
-  public boolean bk;
-}
-
 /**
  * RE provides the user interface for compiling and matching regular
  * expressions.
@@ -119,6 +110,16 @@
  */
 
 public class RE extends REToken {
+
+  private static final class IntPair implements Serializable {
+    public int first, second;
+  }
+
+  private static final class CharUnit implements Serializable {
+    public char ch;
+    public boolean bk;
+  }
+
   // This String will be returned by getVersion()
   private static final String VERSION = "1.1.5-dev";
 
Index: java/io/ObjectInputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/ObjectInputStream.java,v
retrieving revision 1.51
diff -u -r1.51 ObjectInputStream.java
--- java/io/ObjectInputStream.java      18 Jan 2005 22:57:45 -0000      1.51
+++ java/io/ObjectInputStream.java      2 Feb 2005 23:43:51 -0000
@@ -1946,24 +1946,24 @@
        System.loadLibrary ("javaio");
       }
   }
-}
-
 
-// used to keep a prioritized list of object validators
-class ValidatorAndPriority implements Comparable
-{
-  int priority;
-  ObjectInputValidation validator;
-
-  ValidatorAndPriority (ObjectInputValidation validator, int priority)
+  // used to keep a prioritized list of object validators
+  private static final class ValidatorAndPriority implements Comparable
   {
-    this.priority = priority;
-    this.validator = validator;
-  }
+    int priority;
+    ObjectInputValidation validator;
 
-  public int compareTo (Object o)
-  {
-    ValidatorAndPriority vap = (ValidatorAndPriority)o;
-    return this.priority - vap.priority;
+    ValidatorAndPriority (ObjectInputValidation validator, int priority)
+    {
+      this.priority = priority;
+      this.validator = validator;
+    }
+
+    public int compareTo (Object o)
+    {
+      ValidatorAndPriority vap = (ValidatorAndPriority)o;
+      return this.priority - vap.priority;
+    }
   }
 }
+
Index: java/io/ObjectStreamClass.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/ObjectStreamClass.java,v
retrieving revision 1.38
diff -u -r1.38 ObjectStreamClass.java
--- java/io/ObjectStreamClass.java      6 Dec 2004 13:14:08 -0000       1.38
+++ java/io/ObjectStreamClass.java      2 Feb 2005 23:43:52 -0000
@@ -897,34 +897,33 @@
   // but it will avoid showing up as a discrepancy when comparing SUIDs.
   private static final long serialVersionUID = -6120832682080437368L;
 
-}
-
 
-// interfaces are compared only by name
-class InterfaceComparator implements Comparator
-{
-  public int compare(Object o1, Object o2)
+  // interfaces are compared only by name
+  private static final class InterfaceComparator implements Comparator
   {
-    return ((Class) o1).getName().compareTo(((Class) o2).getName());
+    public int compare(Object o1, Object o2)
+    {
+      return ((Class) o1).getName().compareTo(((Class) o2).getName());
+    }
   }
-}
 
 
-// Members (Methods and Constructors) are compared first by name,
-// conflicts are resolved by comparing type signatures
-class MemberComparator implements Comparator
-{
-  public int compare(Object o1, Object o2)
+  // Members (Methods and Constructors) are compared first by name,
+  // conflicts are resolved by comparing type signatures
+  private static final class MemberComparator implements Comparator
   {
-    Member m1 = (Member) o1;
-    Member m2 = (Member) o2;
-
-    int comp = m1.getName().compareTo(m2.getName());
-
-    if (comp == 0)
-      return TypeSignature.getEncodingOfMember(m1).
-       compareTo(TypeSignature.getEncodingOfMember(m2));
-    else
-      return comp;
+    public int compare(Object o1, Object o2)
+    {
+      Member m1 = (Member) o1;
+      Member m2 = (Member) o2;
+
+      int comp = m1.getName().compareTo(m2.getName());
+
+      if (comp == 0)
+        return TypeSignature.getEncodingOfMember(m1).
+         compareTo(TypeSignature.getEncodingOfMember(m2));
+      else
+        return comp;
+    }
   }
 }
Index: java/lang/SecurityManager.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/SecurityManager.java,v
retrieving revision 1.26
diff -u -r1.26 SecurityManager.java
--- java/lang/SecurityManager.java      7 Jan 2005 15:08:23 -0000       1.26
+++ java/lang/SecurityManager.java      2 Feb 2005 23:43:52 -0000
@@ -1058,11 +1058,3 @@
       }
   }
 } // class SecurityManager
-
-// XXX This class is unnecessary.
-class SecurityContext {
-       Class[] classes;
-       SecurityContext(Class[] classes) {
-               this.classes = classes;
-       }
-}
Index: java/security/AllPermission.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/security/AllPermission.java,v
retrieving revision 1.7
diff -u -r1.7 AllPermission.java
--- java/security/AllPermission.java    21 Oct 2004 20:22:12 -0000      1.7
+++ java/security/AllPermission.java    2 Feb 2005 23:43:53 -0000
@@ -135,64 +135,64 @@
   {
     return new AllPermissionCollection();
   }
-} // class AllPermission
-
-/**
- * Implements AllPermission.newPermissionCollection, and obeys serialization
- * of JDK.
- *
- * @author Eric Blake <address@hidden>
- */
-final class AllPermissionCollection extends PermissionCollection
-{
-  /**
-   * Compatible with JDK 1.1+.
-   */
-  private static final long serialVersionUID = -4023755556366636806L;
-
-  /**
-   * Whether an AllPermission has been added to the collection.
-   *
-   * @serial if all permission is in the collection yet
-   */
-  private boolean all_allowed;
 
   /**
-   * Add an AllPermission.
+   * Implements AllPermission.newPermissionCollection, and obeys serialization
+   * of JDK.
    *
-   * @param perm the permission to add
-   * @throws IllegalArgumentException if perm is not an AllPermission
-   * @throws SecurityException if the collection is read-only
+   * @author Eric Blake <address@hidden>
    */
-  public void add(Permission perm)
+  private static final class AllPermissionCollection extends 
PermissionCollection
   {
-    if (isReadOnly())
-      throw new SecurityException();
-    if (! (perm instanceof AllPermission))
-      throw new IllegalArgumentException();
-    all_allowed = true;
-  }
+    /**
+     * Compatible with JDK 1.1+.
+     */
+    private static final long serialVersionUID = -4023755556366636806L;
 
-  /**
-   * Returns true if this collection implies a permission.
-   *
-   * @param perm the permission to check
-   * @return true if this collection contains an AllPermission
-   */
-  public boolean implies(Permission perm)
-  {
-    return all_allowed;
-  }
+    /**
+     * Whether an AllPermission has been added to the collection.
+     *
+     * @serial if all permission is in the collection yet
+     */
+    private boolean all_allowed;
 
-  /**
-   * Returns an enumeration of the elements in the collection.
-   *
-   * @return the elements in the collection
-   */
-  public Enumeration elements()
-  {
-    return all_allowed
-      ? Collections.enumeration(Collections.singleton(new AllPermission()))
-      : EmptyEnumeration.getInstance();
-  }
-} // class AllPermissionCollection
+    /**
+     * Add an AllPermission.
+     *
+     * @param perm the permission to add
+     * @throws IllegalArgumentException if perm is not an AllPermission
+     * @throws SecurityException if the collection is read-only
+     */
+    public void add(Permission perm)
+    {
+      if (isReadOnly())
+        throw new SecurityException();
+      if (! (perm instanceof AllPermission))
+        throw new IllegalArgumentException();
+      all_allowed = true;
+    }
+
+    /**
+     * Returns true if this collection implies a permission.
+     *
+     * @param perm the permission to check
+     * @return true if this collection contains an AllPermission
+     */
+    public boolean implies(Permission perm)
+    {
+      return all_allowed;
+    }
+
+    /**
+     * Returns an enumeration of the elements in the collection.
+     *
+     * @return the elements in the collection
+     */
+    public Enumeration elements()
+    {
+      return all_allowed
+        ? Collections.enumeration(Collections.singleton(new AllPermission()))
+        : EmptyEnumeration.getInstance();
+    }
+  } // class AllPermissionCollection
+} // class AllPermission
Index: java/security/BasicPermission.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/security/BasicPermission.java,v
retrieving revision 1.12
diff -u -r1.12 BasicPermission.java
--- java/security/BasicPermission.java  21 Oct 2004 20:22:12 -0000      1.12
+++ java/security/BasicPermission.java  2 Feb 2005 23:43:53 -0000
@@ -198,111 +198,111 @@
   {
     return new BasicPermissionCollection(getClass());
   }
-} // class BasicPermission
-
-/**
- * Implements AllPermission.newPermissionCollection, and obeys serialization
- * of JDK.
- *
- * @author Eric Blake <address@hidden>
- */
-final class BasicPermissionCollection extends PermissionCollection
-{
-  /**
-   * Compatible with JDK 1.1+.
-   */
-  private static final long serialVersionUID = 739301742472979399L;
-
-  /**
-   * The permissions in the collection.
-   *
-   * @serial a hash mapping name to permissions, all of type permClass
-   */
-  private final Hashtable permissions = new Hashtable();
-
-  /**
-   * If "*" is in the collection.
-   *
-   * @serial true if a permission named "*" is in the collection
-   */
-  private boolean all_allowed;
-
-  /**
-   * The runtime class which all entries in the table must belong to.
-   *
-   * @serial the limiting subclass of this collection
-   */
-  private final Class permClass;
 
   /**
-   * Construct a collection over the given runtime class.
+   * Implements AllPermission.newPermissionCollection, and obeys serialization
+   * of JDK.
    *
-   * @param c the class
+   * @author Eric Blake <address@hidden>
    */
-  BasicPermissionCollection(Class c)
+  private static final class BasicPermissionCollection extends 
PermissionCollection
   {
-    permClass = c;
-  }
-
-  /**
-   * Add a Permission. It must be of the same type as the permission which
-   * created this collection.
-   *
-   * @param perm the permission to add
-   * @throws IllegalArgumentException if perm is not the correct type
-   * @throws SecurityException if the collection is read-only
-   */
-  public void add(Permission perm)
-  {
-    if (isReadOnly())
-      throw new SecurityException("readonly");
-    if (! permClass.isInstance(perm))
-      throw new IllegalArgumentException("Expecting instance of " + permClass);
-    BasicPermission bp = (BasicPermission) perm;
-    String name = bp.getName();
-    if (name.equals("*"))
-      all_allowed = true;
-    permissions.put(name, bp);
-  }
-
-  /**
-   * Returns true if this collection implies the given permission.
-   *
-   * @param permission the permission to check
-   * @return true if it is implied by this
-   */
-  public boolean implies(Permission permission)
-  {
-    if (! permClass.isInstance(permission))
-      return false;
-    if (all_allowed)
-      return true;
-    BasicPermission toImply = (BasicPermission) permission;
-    String name = toImply.getName();
-    if (name.equals("*"))
-      return false;
-    int prefixLength = name.length();
-    if (name.endsWith("*"))
-      prefixLength -= 2;
-
-    while (true)
-      {
-        if (permissions.get(name) != null)
-          return true;
-        prefixLength = name.lastIndexOf('.', prefixLength);
-        if (prefixLength < 0)
-          return false;
-        name = name.substring(0, prefixLength + 1) + '*';
-      }
-  }
-
-  /**
-   * Enumerate over the collection.
-   *
-   * @return an enumeration of the collection contents
-   */
-  public Enumeration elements()
-  {
-    return permissions.elements();
-  }
-} // class BasicPermissionCollection
+    /**
+     * Compatible with JDK 1.1+.
+     */
+    private static final long serialVersionUID = 739301742472979399L;
+
+    /**
+     * The permissions in the collection.
+     *
+     * @serial a hash mapping name to permissions, all of type permClass
+     */
+    private final Hashtable permissions = new Hashtable();
+
+    /**
+     * If "*" is in the collection.
+     *
+     * @serial true if a permission named "*" is in the collection
+     */
+    private boolean all_allowed;
+
+    /**
+     * The runtime class which all entries in the table must belong to.
+     *
+     * @serial the limiting subclass of this collection
+     */
+    private final Class permClass;
+
+    /**
+     * Construct a collection over the given runtime class.
+     *
+     * @param c the class
+     */
+    BasicPermissionCollection(Class c)
+    {
+      permClass = c;
+    }
+
+    /**
+     * Add a Permission. It must be of the same type as the permission which
+     * created this collection.
+     *
+     * @param perm the permission to add
+     * @throws IllegalArgumentException if perm is not the correct type
+     * @throws SecurityException if the collection is read-only
+     */
+    public void add(Permission perm)
+    {
+      if (isReadOnly())
+        throw new SecurityException("readonly");
+      if (! permClass.isInstance(perm))
+        throw new IllegalArgumentException("Expecting instance of " + 
permClass);
+      BasicPermission bp = (BasicPermission) perm;
+      String name = bp.getName();
+      if (name.equals("*"))
+        all_allowed = true;
+      permissions.put(name, bp);
+    }
+
+    /**
+     * Returns true if this collection implies the given permission.
+     *
+     * @param permission the permission to check
+     * @return true if it is implied by this
+     */
+    public boolean implies(Permission permission)
+    {
+      if (! permClass.isInstance(permission))
+        return false;
+      if (all_allowed)
+        return true;
+      BasicPermission toImply = (BasicPermission) permission;
+      String name = toImply.getName();
+      if (name.equals("*"))
+        return false;
+      int prefixLength = name.length();
+      if (name.endsWith("*"))
+        prefixLength -= 2;
+
+      while (true)
+        {
+          if (permissions.get(name) != null)
+            return true;
+          prefixLength = name.lastIndexOf('.', prefixLength);
+          if (prefixLength < 0)
+            return false;
+          name = name.substring(0, prefixLength + 1) + '*';
+        }
+    }
+
+    /**
+     * Enumerate over the collection.
+     *
+     * @return an enumeration of the collection contents
+     */
+    public Enumeration elements()
+    {
+      return permissions.elements();
+    }
+  } // class BasicPermissionCollection
+} // class BasicPermission
Index: java/security/Permissions.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/security/Permissions.java,v
retrieving revision 1.9
diff -u -r1.9 Permissions.java
--- java/security/Permissions.java      6 Nov 2004 23:13:39 -0000       1.9
+++ java/security/Permissions.java      2 Feb 2005 23:43:53 -0000
@@ -188,58 +188,58 @@
       }
     };
   }
-} // class Permissions
 
-/**
- * Implements the permission collection for all permissions without one of
- * their own, and obeys serialization of JDK.
- *
- * @author Eric Blake <address@hidden>
- */
-class PermissionsHash extends PermissionCollection
-{
   /**
-   * Compatible with JDK 1.1+.
-   */
-  private static final long serialVersionUID = -8491988220802933440L;
-
-  /**
-   * Hashtable where we store permissions.
+   * Implements the permission collection for all permissions without one of
+   * their own, and obeys serialization of JDK.
    *
-   * @serial the stored permissions, both as key and value
+   * @author Eric Blake <address@hidden>
    */
-  private final Hashtable perms = new Hashtable();
-
-  /**
-   * Add a permission. We don't need to check for read-only, as this
-   * collection is never exposed outside of Permissions, which has already
-   * done that check.
-   *
-   * @param perm the permission to add
-   */
-  public void add(Permission perm)
+  private static final class PermissionsHash extends PermissionCollection
   {
-    perms.put(perm, perm);
-  }
+    /**
+     * Compatible with JDK 1.1+.
+     */
+    private static final long serialVersionUID = -8491988220802933440L;
 
-  /**
-   * Returns true if perm is in the collection.
-   *
-   * @param perm the permission to check
-   * @return true if it is implied
-   */
-  public boolean implies(Permission perm)
-  {
-    return perms.get(perm) != null;
-  }
+    /**
+     * Hashtable where we store permissions.
+     *
+     * @serial the stored permissions, both as key and value
+     */
+    private final Hashtable perms = new Hashtable();
 
-  /**
-   * Return the elements.
-   *
-   * @return the elements
-   */
-  public Enumeration elements()
-  {
-    return perms.elements();
-  }
+    /**
+     * Add a permission. We don't need to check for read-only, as this
+     * collection is never exposed outside of Permissions, which has already
+     * done that check.
+     *
+     * @param perm the permission to add
+     */
+    public void add(Permission perm)
+    {
+      perms.put(perm, perm);
+    }
+
+    /**
+     * Returns true if perm is in the collection.
+     *
+     * @param perm the permission to check
+     * @return true if it is implied
+     */
+    public boolean implies(Permission perm)
+    {
+      return perms.get(perm) != null;
+    }
+
+    /**
+     * Return the elements.
+     *
+     * @return the elements
+     */
+    public Enumeration elements()
+    {
+      return perms.elements();
+    }
+  } // class PermissionsHash
 } // class Permissions
Index: java/text/MessageFormat.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/text/MessageFormat.java,v
retrieving revision 1.16
diff -u -r1.16 MessageFormat.java
--- java/text/MessageFormat.java        18 Jan 2005 00:59:01 -0000      1.16
+++ java/text/MessageFormat.java        2 Feb 2005 23:43:53 -0000
@@ -46,107 +46,107 @@
 import java.util.Locale;
 import java.util.Vector;
 
-/**
- * @author Tom Tromey <address@hidden>
- * @author Jorge Aliss <address@hidden>
- * @date March 3, 1999
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 from http://www.javasoft.com.
- * Status:  Believed complete and correct to 1.2, except serialization.
- *          and parsing.
- */
-final class MessageFormatElement
+public class MessageFormat extends Format
 {
-  // Argument number.
-  int argNumber;
-  // Formatter to be used.  This is the format set by setFormat.
-  Format setFormat;
-  // Formatter to be used based on the type.
-  Format format;
-
-  // Argument will be checked to make sure it is an instance of this
-  // class.
-  Class formatClass;
-
-  // Formatter type.
-  String type;
-  // Formatter style.
-  String style;
-
-  // Text to follow this element.
-  String trailer;
-
-  // Recompute the locale-based formatter.
-  void setLocale (Locale loc)
-  {
-    if (type == null)
-      ;
-    else if (type.equals("number"))
-      {
-       formatClass = java.lang.Number.class;
-
-       if (style == null)
-         format = NumberFormat.getInstance(loc);
-       else if (style.equals("currency"))
-         format = NumberFormat.getCurrencyInstance(loc);
-       else if (style.equals("percent"))
-         format = NumberFormat.getPercentInstance(loc);
-       else if (style.equals("integer"))
-         {
-           NumberFormat nf = NumberFormat.getNumberInstance(loc);
-           nf.setMaximumFractionDigits(0);
-           nf.setGroupingUsed(false);
-           format = nf;
-         }
-       else
-         {
-           format = NumberFormat.getNumberInstance(loc);
-           DecimalFormat df = (DecimalFormat) format;
-           df.applyPattern(style);
-         }
-      }
-    else if (type.equals("time") || type.equals("date"))
-      {
-       formatClass = java.util.Date.class;
-
-       int val = DateFormat.DEFAULT;
-       if (style == null)
-         ;
-       else if (style.equals("short"))
-         val = DateFormat.SHORT;
-       else if (style.equals("medium"))
-         val = DateFormat.MEDIUM;
-       else if (style.equals("long"))
-         val = DateFormat.LONG;
-       else if (style.equals("full"))
-         val = DateFormat.FULL;
+  /**
+   * @author Tom Tromey <address@hidden>
+   * @author Jorge Aliss <address@hidden>
+   * @date March 3, 1999
+   */
+  /* Written using "Java Class Libraries", 2nd edition, plus online
+   * API docs for JDK 1.2 from http://www.javasoft.com.
+   * Status:  Believed complete and correct to 1.2, except serialization.
+   *          and parsing.
+   */
+  private static final class MessageFormatElement
+  {
+    // Argument number.
+    int argNumber;
+    // Formatter to be used.  This is the format set by setFormat.
+    Format setFormat;
+    // Formatter to be used based on the type.
+    Format format;
+
+    // Argument will be checked to make sure it is an instance of this
+    // class.
+    Class formatClass;
+
+    // Formatter type.
+    String type;
+    // Formatter style.
+    String style;
 
-       if (type.equals("time"))
-         format = DateFormat.getTimeInstance(val, loc);
-       else
-         format = DateFormat.getDateInstance(val, loc);
+    // Text to follow this element.
+    String trailer;
 
-       if (style != null && val == DateFormat.DEFAULT)
-         {
-           SimpleDateFormat sdf = (SimpleDateFormat) format;
-           sdf.applyPattern(style);
-         }
-      }
-    else if (type.equals("choice"))
-      {
-       formatClass = java.lang.Number.class;
-
-       if (style == null)
-         throw new
-           IllegalArgumentException ("style required for choice format");
-       format = new ChoiceFormat (style);
-      }
+    // Recompute the locale-based formatter.
+    void setLocale (Locale loc)
+    {
+      if (type == null)
+        ;
+      else if (type.equals("number"))
+        {
+         formatClass = java.lang.Number.class;
+
+         if (style == null)
+           format = NumberFormat.getInstance(loc);
+         else if (style.equals("currency"))
+           format = NumberFormat.getCurrencyInstance(loc);
+         else if (style.equals("percent"))
+           format = NumberFormat.getPercentInstance(loc);
+         else if (style.equals("integer"))
+           {
+             NumberFormat nf = NumberFormat.getNumberInstance(loc);
+             nf.setMaximumFractionDigits(0);
+             nf.setGroupingUsed(false);
+             format = nf;
+           }
+         else
+           {
+             format = NumberFormat.getNumberInstance(loc);
+             DecimalFormat df = (DecimalFormat) format;
+             df.applyPattern(style);
+           }
+        }
+      else if (type.equals("time") || type.equals("date"))
+        {
+         formatClass = java.util.Date.class;
+
+         int val = DateFormat.DEFAULT;
+         if (style == null)
+           ;
+         else if (style.equals("short"))
+           val = DateFormat.SHORT;
+         else if (style.equals("medium"))
+           val = DateFormat.MEDIUM;
+         else if (style.equals("long"))
+           val = DateFormat.LONG;
+         else if (style.equals("full"))
+           val = DateFormat.FULL;
+
+         if (type.equals("time"))
+           format = DateFormat.getTimeInstance(val, loc);
+         else
+           format = DateFormat.getDateInstance(val, loc);
+
+         if (style != null && val == DateFormat.DEFAULT)
+           {
+             SimpleDateFormat sdf = (SimpleDateFormat) format;
+             sdf.applyPattern(style);
+           }
+        }
+      else if (type.equals("choice"))
+        {
+         formatClass = java.lang.Number.class;
+
+         if (style == null)
+           throw new
+             IllegalArgumentException ("style required for choice format");
+         format = new ChoiceFormat (style);
+        }
+    }
   }
-}
 
-public class MessageFormat extends Format
-{
   private static final long serialVersionUID = 6479157306784022952L;
 
   public static class Field extends Format.Field
Index: java/util/AbstractList.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/AbstractList.java,v
retrieving revision 1.22
diff -u -r1.22 AbstractList.java
--- java/util/AbstractList.java 17 Aug 2004 22:19:56 -0000      1.22
+++ java/util/AbstractList.java 2 Feb 2005 23:43:54 -0000
@@ -751,476 +751,475 @@
     return new SubList(this, fromIndex, toIndex);
   }
 
-} // class AbstractList
-
-
-/**
- * This class follows the implementation requirements set forth in
- * address@hidden AbstractList#subList(int, int)}. It matches Sun's 
implementation
- * by using a non-public top-level class in the same package.
- *
- * @author Original author unknown
- * @author Eric Blake <address@hidden>
- */
-class SubList extends AbstractList
-{
-  // Package visible, for use by iterator.
-  /** The original list. */
-  final AbstractList backingList;
-  /** The index of the first element of the sublist. */
-  final int offset;
-  /** The size of the sublist. */
-  int size;
-
-  /**
-   * Construct the sublist.
-   *
-   * @param backing the list this comes from
-   * @param fromIndex the lower bound, inclusive
-   * @param toIndex the upper bound, exclusive
-   */
-  SubList(AbstractList backing, int fromIndex, int toIndex)
-  {
-    backingList = backing;
-    modCount = backing.modCount;
-    offset = fromIndex;
-    size = toIndex - fromIndex;
-  }
-
-  /**
-   * This method checks the two modCount fields to ensure that there has
-   * not been a concurrent modification, returning if all is okay.
-   *
-   * @throws ConcurrentModificationException if the backing list has been
-   *         modified externally to this sublist
-   */
-  // This can be inlined. Package visible, for use by iterator.
-  void checkMod()
-  {
-    if (modCount != backingList.modCount)
-      throw new ConcurrentModificationException();
-  }
-
-  /**
-   * This method checks that a value is between 0 and size (inclusive). If
-   * it is not, an exception is thrown.
-   *
-   * @param index the value to check
-   * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
-   */
-  // This will get inlined, since it is private.
-  private void checkBoundsInclusive(int index)
-  {
-    if (index < 0 || index > size)
-      throw new IndexOutOfBoundsException("Index: " + index + ", Size:"
-                                          + size);
-  }
-
-  /**
-   * This method checks that a value is between 0 (inclusive) and size
-   * (exclusive). If it is not, an exception is thrown.
-   *
-   * @param index the value to check
-   * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
-   */
-  // This will get inlined, since it is private.
-  private void checkBoundsExclusive(int index)
-  {
-    if (index < 0 || index >= size)
-      throw new IndexOutOfBoundsException("Index: " + index + ", Size:"
-                                          + size);
-  }
-
-  /**
-   * Specified by AbstractList.subList to return the private field size.
-   *
-   * @return the sublist size
-   * @throws ConcurrentModificationException if the backing list has been
-   *         modified externally to this sublist
-   */
-  public int size()
-  {
-    checkMod();
-    return size;
-  }
-
   /**
-   * Specified by AbstractList.subList to delegate to the backing list.
-   *
-   * @param index the location to modify
-   * @param o the new value
-   * @return the old value
-   * @throws ConcurrentModificationException if the backing list has been
-   *         modified externally to this sublist
-   * @throws UnsupportedOperationException if the backing list does not
-   *         support the set operation
-   * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
-   * @throws ClassCastException if o cannot be added to the backing list due
-   *         to its type
-   * @throws IllegalArgumentException if o cannot be added to the backing list
-   *         for some other reason
-   */
-  public Object set(int index, Object o)
-  {
-    checkMod();
-    checkBoundsExclusive(index);
-    return backingList.set(index + offset, o);
-  }
-
-  /**
-   * Specified by AbstractList.subList to delegate to the backing list.
-   *
-   * @param index the location to get from
-   * @return the object at that location
-   * @throws ConcurrentModificationException if the backing list has been
-   *         modified externally to this sublist
-   * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
-   */
-  public Object get(int index)
-  {
-    checkMod();
-    checkBoundsExclusive(index);
-    return backingList.get(index + offset);
-  }
-
-  /**
-   * Specified by AbstractList.subList to delegate to the backing list.
-   *
-   * @param index the index to insert at
-   * @param o the object to add
-   * @throws ConcurrentModificationException if the backing list has been
-   *         modified externally to this sublist
-   * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
-   * @throws UnsupportedOperationException if the backing list does not
-   *         support the add operation.
-   * @throws ClassCastException if o cannot be added to the backing list due
-   *         to its type.
-   * @throws IllegalArgumentException if o cannot be added to the backing
-   *         list for some other reason.
-   */
-  public void add(int index, Object o)
-  {
-    checkMod();
-    checkBoundsInclusive(index);
-    backingList.add(index + offset, o);
-    size++;
-    modCount = backingList.modCount;
-  }
-
-  /**
-   * Specified by AbstractList.subList to delegate to the backing list.
-   *
-   * @param index the index to remove
-   * @return the removed object
-   * @throws ConcurrentModificationException if the backing list has been
-   *         modified externally to this sublist
-   * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
-   * @throws UnsupportedOperationException if the backing list does not
-   *         support the remove operation
-   */
-  public Object remove(int index)
-  {
-    checkMod();
-    checkBoundsExclusive(index);
-    Object o = backingList.remove(index + offset);
-    size--;
-    modCount = backingList.modCount;
-    return o;
-  }
-
-  /**
-   * Specified by AbstractList.subList to delegate to the backing list.
-   * This does no bounds checking, as it assumes it will only be called
-   * by trusted code like clear() which has already checked the bounds.
-   *
-   * @param fromIndex the lower bound, inclusive
-   * @param toIndex the upper bound, exclusive
-   * @throws ConcurrentModificationException if the backing list has been
-   *         modified externally to this sublist
-   * @throws UnsupportedOperationException if the backing list does
-   *         not support removing elements.
-   */
-  protected void removeRange(int fromIndex, int toIndex)
-  {
-    checkMod();
-
-    backingList.removeRange(offset + fromIndex, offset + toIndex);
-    size -= toIndex - fromIndex;
-    modCount = backingList.modCount;
-  }
-
-  /**
-   * Specified by AbstractList.subList to delegate to the backing list.
-   *
-   * @param index the location to insert at
-   * @param c the collection to insert
-   * @return true if this list was modified, in other words, c is non-empty
-   * @throws ConcurrentModificationException if the backing list has been
-   *         modified externally to this sublist
-   * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
-   * @throws UnsupportedOperationException if this list does not support the
-   *         addAll operation
-   * @throws ClassCastException if some element of c cannot be added to this
-   *         list due to its type
-   * @throws IllegalArgumentException if some element of c cannot be added
-   *         to this list for some other reason
-   * @throws NullPointerException if the specified collection is null
-   */
-  public boolean addAll(int index, Collection c)
-  {
-    checkMod();
-    checkBoundsInclusive(index);
-    int csize = c.size();
-    boolean result = backingList.addAll(offset + index, c);
-    size += csize;
-    modCount = backingList.modCount;
-    return result;
-  }
-
-  /**
-   * Specified by AbstractList.subList to return addAll(size, c).
-   *
-   * @param c the collection to insert
-   * @return true if this list was modified, in other words, c is non-empty
-   * @throws ConcurrentModificationException if the backing list has been
-   *         modified externally to this sublist
-   * @throws UnsupportedOperationException if this list does not support the
-   *         addAll operation
-   * @throws ClassCastException if some element of c cannot be added to this
-   *         list due to its type
-   * @throws IllegalArgumentException if some element of c cannot be added
-   *         to this list for some other reason
-   * @throws NullPointerException if the specified collection is null
-   */
-  public boolean addAll(Collection c)
-  {
-    return addAll(size, c);
-  }
-
-  /**
-   * Specified by AbstractList.subList to return listIterator().
-   *
-   * @return an iterator over the sublist
-   */
-  public Iterator iterator()
-  {
-    return listIterator();
-  }
+   * This class follows the implementation requirements set forth in
+   * address@hidden AbstractList#subList(int, int)}. It matches Sun's 
implementation
+   * by using a non-public top-level class in the same package.
+   *
+   * @author Original author unknown
+   * @author Eric Blake <address@hidden>
+   */
+  private static class SubList extends AbstractList
+  {
+    // Package visible, for use by iterator.
+    /** The original list. */
+    final AbstractList backingList;
+    /** The index of the first element of the sublist. */
+    final int offset;
+    /** The size of the sublist. */
+    int size;
+
+    /**
+     * Construct the sublist.
+     *
+     * @param backing the list this comes from
+     * @param fromIndex the lower bound, inclusive
+     * @param toIndex the upper bound, exclusive
+     */
+    SubList(AbstractList backing, int fromIndex, int toIndex)
+    {
+      backingList = backing;
+      modCount = backing.modCount;
+      offset = fromIndex;
+      size = toIndex - fromIndex;
+    }
+
+    /**
+     * This method checks the two modCount fields to ensure that there has
+     * not been a concurrent modification, returning if all is okay.
+     *
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     */
+    // This can be inlined. Package visible, for use by iterator.
+    void checkMod()
+    {
+      if (modCount != backingList.modCount)
+        throw new ConcurrentModificationException();
+    }
+
+    /**
+     * This method checks that a value is between 0 and size (inclusive). If
+     * it is not, an exception is thrown.
+     *
+     * @param index the value to check
+     * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
+     */
+    // This will get inlined, since it is private.
+    private void checkBoundsInclusive(int index)
+    {
+      if (index < 0 || index > size)
+        throw new IndexOutOfBoundsException("Index: " + index + ", Size:"
+                                            + size);
+    }
+
+    /**
+     * This method checks that a value is between 0 (inclusive) and size
+     * (exclusive). If it is not, an exception is thrown.
+     *
+     * @param index the value to check
+     * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
+     */
+    // This will get inlined, since it is private.
+    private void checkBoundsExclusive(int index)
+    {
+      if (index < 0 || index >= size)
+        throw new IndexOutOfBoundsException("Index: " + index + ", Size:"
+                                            + size);
+    }
+
+    /**
+     * Specified by AbstractList.subList to return the private field size.
+     *
+     * @return the sublist size
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     */
+    public int size()
+    {
+      checkMod();
+      return size;
+    }
+
+    /**
+     * Specified by AbstractList.subList to delegate to the backing list.
+     *
+     * @param index the location to modify
+     * @param o the new value
+     * @return the old value
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws UnsupportedOperationException if the backing list does not
+     *         support the set operation
+     * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
+     * @throws ClassCastException if o cannot be added to the backing list due
+     *         to its type
+     * @throws IllegalArgumentException if o cannot be added to the backing 
list
+     *         for some other reason
+     */
+    public Object set(int index, Object o)
+    {
+      checkMod();
+      checkBoundsExclusive(index);
+      return backingList.set(index + offset, o);
+    }
+
+    /**
+     * Specified by AbstractList.subList to delegate to the backing list.
+     *
+     * @param index the location to get from
+     * @return the object at that location
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
+     */
+    public Object get(int index)
+    {
+      checkMod();
+      checkBoundsExclusive(index);
+      return backingList.get(index + offset);
+    }
+
+    /**
+     * Specified by AbstractList.subList to delegate to the backing list.
+     *
+     * @param index the index to insert at
+     * @param o the object to add
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
+     * @throws UnsupportedOperationException if the backing list does not
+     *         support the add operation.
+     * @throws ClassCastException if o cannot be added to the backing list due
+     *         to its type.
+     * @throws IllegalArgumentException if o cannot be added to the backing
+     *         list for some other reason.
+     */
+    public void add(int index, Object o)
+    {
+      checkMod();
+      checkBoundsInclusive(index);
+      backingList.add(index + offset, o);
+      size++;
+      modCount = backingList.modCount;
+    }
+
+    /**
+     * Specified by AbstractList.subList to delegate to the backing list.
+     *
+     * @param index the index to remove
+     * @return the removed object
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
+     * @throws UnsupportedOperationException if the backing list does not
+     *         support the remove operation
+     */
+    public Object remove(int index)
+    {
+      checkMod();
+      checkBoundsExclusive(index);
+      Object o = backingList.remove(index + offset);
+      size--;
+      modCount = backingList.modCount;
+      return o;
+    }
+
+    /**
+     * Specified by AbstractList.subList to delegate to the backing list.
+     * This does no bounds checking, as it assumes it will only be called
+     * by trusted code like clear() which has already checked the bounds.
+     *
+     * @param fromIndex the lower bound, inclusive
+     * @param toIndex the upper bound, exclusive
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws UnsupportedOperationException if the backing list does
+     *         not support removing elements.
+     */
+    protected void removeRange(int fromIndex, int toIndex)
+    {
+      checkMod();
 
-  /**
-   * Specified by AbstractList.subList to return a wrapper around the
-   * backing list's iterator.
-   *
-   * @param index the start location of the iterator
-   * @return a list iterator over the sublist
-   * @throws ConcurrentModificationException if the backing list has been
-   *         modified externally to this sublist
-   * @throws IndexOutOfBoundsException if the value is out of range
-   */
-  public ListIterator listIterator(final int index)
-  {
-    checkMod();
-    checkBoundsInclusive(index);
+      backingList.removeRange(offset + fromIndex, offset + toIndex);
+      size -= toIndex - fromIndex;
+      modCount = backingList.modCount;
+    }
+
+    /**
+     * Specified by AbstractList.subList to delegate to the backing list.
+     *
+     * @param index the location to insert at
+     * @param c the collection to insert
+     * @return true if this list was modified, in other words, c is non-empty
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
+     * @throws UnsupportedOperationException if this list does not support the
+     *         addAll operation
+     * @throws ClassCastException if some element of c cannot be added to this
+     *         list due to its type
+     * @throws IllegalArgumentException if some element of c cannot be added
+     *         to this list for some other reason
+     * @throws NullPointerException if the specified collection is null
+     */
+    public boolean addAll(int index, Collection c)
+    {
+      checkMod();
+      checkBoundsInclusive(index);
+      int csize = c.size();
+      boolean result = backingList.addAll(offset + index, c);
+      size += csize;
+      modCount = backingList.modCount;
+      return result;
+    }
+
+    /**
+     * Specified by AbstractList.subList to return addAll(size, c).
+     *
+     * @param c the collection to insert
+     * @return true if this list was modified, in other words, c is non-empty
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws UnsupportedOperationException if this list does not support the
+     *         addAll operation
+     * @throws ClassCastException if some element of c cannot be added to this
+     *         list due to its type
+     * @throws IllegalArgumentException if some element of c cannot be added
+     *         to this list for some other reason
+     * @throws NullPointerException if the specified collection is null
+     */
+    public boolean addAll(Collection c)
+    {
+      return addAll(size, c);
+    }
 
-    return new ListIterator()
+    /**
+     * Specified by AbstractList.subList to return listIterator().
+     *
+     * @return an iterator over the sublist
+     */
+    public Iterator iterator()
     {
-      private final ListIterator i = backingList.listIterator(index + offset);
-      private int position = index;
+      return listIterator();
+    }
 
-      /**
-       * Tests to see if there are any more objects to
-       * return.
-       *
-       * @return True if the end of the list has not yet been
-       *         reached.
-       * @throws ConcurrentModificationException if the
-       *         list has been modified elsewhere.
-       */
-      public boolean hasNext()
-      {
-        checkMod();
-        return position < size;
-      }
-
-      /**
-       * Tests to see if there are objects prior to the
-       * current position in the list.
-       *
-       * @return True if objects exist prior to the current
-       *         position of the iterator.
-       * @throws ConcurrentModificationException if the
-       *         list has been modified elsewhere.
-       */
-      public boolean hasPrevious()
-      {
-        checkMod();
-        return position > 0;
-      }
-
-      /**
-       * Retrieves the next object from the list.
-       *
-       * @return The next object.
-       * @throws NoSuchElementException if there are no
-       *         more objects to retrieve.
-       * @throws ConcurrentModificationException if the
-       *         list has been modified elsewhere.
-       */
-      public Object next()
-      {
-        if (position == size)
-          throw new NoSuchElementException();
-        position++;
-        return i.next();
-      }
-
-      /**
-       * Retrieves the previous object from the list.
-       *
-       * @return The next object.
-       * @throws NoSuchElementException if there are no
-       *         previous objects to retrieve.
-       * @throws ConcurrentModificationException if the
-       *         list has been modified elsewhere.
-       */
-      public Object previous()
-      {
-        if (position == 0)
-          throw new NoSuchElementException();
-        position--;
-        return i.previous();
-      }
-
-      /**
-       * Returns the index of the next element in the
-       * list, which will be retrieved by <code>next()</code>
-       *
-       * @return The index of the next element.
-       * @throws ConcurrentModificationException if the
-       *         list has been modified elsewhere.
-       */
-      public int nextIndex()
-      {
-        return i.nextIndex() - offset;
-      }
+    /**
+     * Specified by AbstractList.subList to return a wrapper around the
+     * backing list's iterator.
+     *
+     * @param index the start location of the iterator
+     * @return a list iterator over the sublist
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws IndexOutOfBoundsException if the value is out of range
+     */
+    public ListIterator listIterator(final int index)
+    {
+      checkMod();
+      checkBoundsInclusive(index);
 
-      /**
-       * Returns the index of the previous element in the
-       * list, which will be retrieved by <code>previous()</code>
-       *
-       * @return The index of the previous element.
-       * @throws ConcurrentModificationException if the
-       *         list has been modified elsewhere.
-       */
-      public int previousIndex()
+      return new ListIterator()
       {
-        return i.previousIndex() - offset;
-      }
+        private final ListIterator i = backingList.listIterator(index + 
offset);
+        private int position = index;
 
-      /**
-       * Removes the last object retrieved by <code>next()</code>
-       * from the list, if the list supports object removal.
-       *
-       * @throws IllegalStateException if the iterator is positioned
-       *         before the start of the list or the last object has already
-       *         been removed.
-       * @throws UnsupportedOperationException if the list does
-       *         not support removing elements.
-       */
-      public void remove()
-      {
-        i.remove();
-        size--;
-        position = nextIndex();
-        modCount = backingList.modCount;
-      }
-
-
-     /**
-      * Replaces the last object retrieved by <code>next()</code>
-      * or <code>previous</code> with o, if the list supports object
-      * replacement and an add or remove operation has not already
-      * been performed.
-      *
-      * @throws IllegalStateException if the iterator is positioned
-      *         before the start of the list or the last object has already
-      *         been removed.
-      * @throws UnsupportedOperationException if the list doesn't support
-      *         the addition or removal of elements.
-      * @throws ClassCastException if the type of o is not a valid type
-      *         for this list.
-      * @throws IllegalArgumentException if something else related to o
-      *         prevents its addition.
-      * @throws ConcurrentModificationException if the list
-      *         has been modified elsewhere.
-      */
-      public void set(Object o)
-      {
-        i.set(o);
-      }
+        /**
+         * Tests to see if there are any more objects to
+         * return.
+         *
+         * @return True if the end of the list has not yet been
+         *         reached.
+         * @throws ConcurrentModificationException if the
+         *         list has been modified elsewhere.
+         */
+        public boolean hasNext()
+        {
+          checkMod();
+          return position < size;
+        }
+
+        /**
+         * Tests to see if there are objects prior to the
+         * current position in the list.
+         *
+         * @return True if objects exist prior to the current
+         *         position of the iterator.
+         * @throws ConcurrentModificationException if the
+         *         list has been modified elsewhere.
+         */
+        public boolean hasPrevious()
+        {
+          checkMod();
+          return position > 0;
+        }
+
+        /**
+         * Retrieves the next object from the list.
+         *
+         * @return The next object.
+         * @throws NoSuchElementException if there are no
+         *         more objects to retrieve.
+         * @throws ConcurrentModificationException if the
+         *         list has been modified elsewhere.
+         */
+        public Object next()
+        {
+          if (position == size)
+            throw new NoSuchElementException();
+          position++;
+          return i.next();
+        }
+
+        /**
+         * Retrieves the previous object from the list.
+         *
+         * @return The next object.
+         * @throws NoSuchElementException if there are no
+         *         previous objects to retrieve.
+         * @throws ConcurrentModificationException if the
+         *         list has been modified elsewhere.
+         */
+        public Object previous()
+        {
+          if (position == 0)
+            throw new NoSuchElementException();
+          position--;
+          return i.previous();
+        }
+
+        /**
+         * Returns the index of the next element in the
+         * list, which will be retrieved by <code>next()</code>
+         *
+         * @return The index of the next element.
+         * @throws ConcurrentModificationException if the
+         *         list has been modified elsewhere.
+         */
+        public int nextIndex()
+        {
+          return i.nextIndex() - offset;
+        }
+
+        /**
+         * Returns the index of the previous element in the
+         * list, which will be retrieved by <code>previous()</code>
+         *
+         * @return The index of the previous element.
+         * @throws ConcurrentModificationException if the
+         *         list has been modified elsewhere.
+         */
+        public int previousIndex()
+        {
+          return i.previousIndex() - offset;
+        }
+
+        /**
+         * Removes the last object retrieved by <code>next()</code>
+         * from the list, if the list supports object removal.
+         *
+         * @throws IllegalStateException if the iterator is positioned
+         *         before the start of the list or the last object has already
+         *         been removed.
+         * @throws UnsupportedOperationException if the list does
+         *         not support removing elements.
+         */
+        public void remove()
+        {
+          i.remove();
+          size--;
+          position = nextIndex();
+          modCount = backingList.modCount;
+        }
+
+
+       /**
+        * Replaces the last object retrieved by <code>next()</code>
+        * or <code>previous</code> with o, if the list supports object
+        * replacement and an add or remove operation has not already
+        * been performed.
+        *
+        * @throws IllegalStateException if the iterator is positioned
+        *         before the start of the list or the last object has already
+        *         been removed.
+        * @throws UnsupportedOperationException if the list doesn't support
+        *         the addition or removal of elements.
+        * @throws ClassCastException if the type of o is not a valid type
+        *         for this list.
+        * @throws IllegalArgumentException if something else related to o
+        *         prevents its addition.
+        * @throws ConcurrentModificationException if the list
+        *         has been modified elsewhere.
+        */
+        public void set(Object o)
+        {
+          i.set(o);
+        }
+
+        /**
+         * Adds the supplied object before the element that would be returned
+         * by a call to <code>next()</code>, if the list supports addition.
+         * 
+         * @param o The object to add to the list.
+         * @throws UnsupportedOperationException if the list doesn't support
+         *         the addition of new elements.
+         * @throws ClassCastException if the type of o is not a valid type
+         *         for this list.
+         * @throws IllegalArgumentException if something else related to o
+         *         prevents its addition.
+         * @throws ConcurrentModificationException if the list
+         *         has been modified elsewhere.
+         */
+        public void add(Object o)
+        {
+          i.add(o);
+          size++;
+          position++;
+          modCount = backingList.modCount;
+        }
+
+        // Here is the reason why the various modCount fields are mostly
+        // ignored in this wrapper listIterator.
+        // If the backing listIterator is failfast, then the following holds:
+        //   Using any other method on this list will call a corresponding
+        //   method on the backing list *after* the backing listIterator
+        //   is created, which will in turn cause a ConcurrentModException
+        //   when this listIterator comes to use the backing one. So it is
+        //   implicitly failfast.
+        // If the backing listIterator is NOT failfast, then the whole of
+        //   this list isn't failfast, because the modCount field of the
+        //   backing list is not valid. It would still be *possible* to
+        //   make the iterator failfast wrt modifications of the sublist
+        //   only, but somewhat pointless when the list can be changed under
+        //   us.
+        // Either way, no explicit handling of modCount is needed.
+        // However modCount = backingList.modCount must be executed in add
+        // and remove, and size must also be updated in these two methods,
+        // since they do not go through the corresponding methods of the 
subList.
+      };
+    }
+  } // class SubList
+
+  /**
+   * This class is a RandomAccess version of SubList, as required by
+   * address@hidden AbstractList#subList(int, int)}.
+   *
+   * @author Eric Blake <address@hidden>
+   */
+  private static final class RandomAccessSubList extends SubList
+    implements RandomAccess
+  {
+    /**
+     * Construct the sublist.
+     *
+     * @param backing the list this comes from
+     * @param fromIndex the lower bound, inclusive
+     * @param toIndex the upper bound, exclusive
+     */
+    RandomAccessSubList(AbstractList backing, int fromIndex, int toIndex)
+    {
+      super(backing, fromIndex, toIndex);
+    }
+  } // class RandomAccessSubList
 
-      /**
-       * Adds the supplied object before the element that would be returned
-       * by a call to <code>next()</code>, if the list supports addition.
-       * 
-       * @param o The object to add to the list.
-       * @throws UnsupportedOperationException if the list doesn't support
-       *         the addition of new elements.
-       * @throws ClassCastException if the type of o is not a valid type
-       *         for this list.
-       * @throws IllegalArgumentException if something else related to o
-       *         prevents its addition.
-       * @throws ConcurrentModificationException if the list
-       *         has been modified elsewhere.
-       */
-      public void add(Object o)
-      {
-        i.add(o);
-        size++;
-        position++;
-        modCount = backingList.modCount;
-      }
-
-      // Here is the reason why the various modCount fields are mostly
-      // ignored in this wrapper listIterator.
-      // If the backing listIterator is failfast, then the following holds:
-      //   Using any other method on this list will call a corresponding
-      //   method on the backing list *after* the backing listIterator
-      //   is created, which will in turn cause a ConcurrentModException
-      //   when this listIterator comes to use the backing one. So it is
-      //   implicitly failfast.
-      // If the backing listIterator is NOT failfast, then the whole of
-      //   this list isn't failfast, because the modCount field of the
-      //   backing list is not valid. It would still be *possible* to
-      //   make the iterator failfast wrt modifications of the sublist
-      //   only, but somewhat pointless when the list can be changed under
-      //   us.
-      // Either way, no explicit handling of modCount is needed.
-      // However modCount = backingList.modCount must be executed in add
-      // and remove, and size must also be updated in these two methods,
-      // since they do not go through the corresponding methods of the subList.
-    };
-  }
-} // class SubList
-
-/**
- * This class is a RandomAccess version of SubList, as required by
- * address@hidden AbstractList#subList(int, int)}.
- *
- * @author Eric Blake <address@hidden>
- */
-final class RandomAccessSubList extends SubList
-  implements RandomAccess
-{
-  /**
-   * Construct the sublist.
-   *
-   * @param backing the list this comes from
-   * @param fromIndex the lower bound, inclusive
-   * @param toIndex the upper bound, exclusive
-   */
-  RandomAccessSubList(AbstractList backing, int fromIndex, int toIndex)
-  {
-    super(backing, fromIndex, toIndex);
-  }
-} // class RandomAccessSubList
+} // class AbstractList

reply via email to

[Prev in Thread] Current Thread [Next in Thread]