[kaffe] CVS kaffe (robilad): Made 'inner' classes truely inner
classes
Kaffe CVS
cvs-commits at kaffe.org
Wed Feb 2 15:20:53 PST 2005
PatchSet 5963
Date: 2005/02/02 23:16:09
Author: robilad
Branch: HEAD
Tag: (none)
Log:
Made 'inner' classes truely inner classes
2005-02-02 Dalibor Topic <robilad at kaffe.org>
* libraries/javalib/gnu/regexp/RE.java,
libraries/javalib/java/io/ObjectInputStream.java,
libraries/javalib/java/io/ObjectStreamClass.java,
libraries/javalib/java/lang/Math.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.
Members:
ChangeLog:1.3502->1.3503
libraries/javalib/gnu/regexp/RE.java:1.3->1.4
libraries/javalib/java/io/ObjectInputStream.java:1.47->1.48
libraries/javalib/java/io/ObjectStreamClass.java:1.29->1.30
libraries/javalib/java/lang/Math.java:1.10->1.11
libraries/javalib/java/lang/SecurityManager.java:1.24->1.25
libraries/javalib/java/security/AllPermission.java:1.3->1.4
libraries/javalib/java/security/BasicPermission.java:1.6->1.7
libraries/javalib/java/security/Permissions.java:1.5->1.6
libraries/javalib/java/text/MessageFormat.java:1.34->1.35
libraries/javalib/java/util/AbstractList.java:1.11->1.12
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3502 kaffe/ChangeLog:1.3503
--- kaffe/ChangeLog:1.3502 Wed Feb 2 13:03:03 2005
+++ kaffe/ChangeLog Wed Feb 2 23:16:09 2005
@@ -1,3 +1,18 @@
+2005-02-02 Dalibor Topic <robilad at kaffe.org>
+
+ * libraries/javalib/gnu/regexp/RE.java,
+ libraries/javalib/java/io/ObjectInputStream.java,
+ libraries/javalib/java/io/ObjectStreamClass.java,
+ libraries/javalib/java/lang/Math.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.
+
2005-02-02 Jim Huang <jserv at kaffe.org>
* kaffe/kaffe/Makefile.am,
Index: kaffe/libraries/javalib/gnu/regexp/RE.java
diff -u kaffe/libraries/javalib/gnu/regexp/RE.java:1.3 kaffe/libraries/javalib/gnu/regexp/RE.java:1.4
--- kaffe/libraries/javalib/gnu/regexp/RE.java:1.3 Fri Dec 10 21:29:36 2004
+++ kaffe/libraries/javalib/gnu/regexp/RE.java Wed Feb 2 23:16:12 2005
@@ -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: kaffe/libraries/javalib/java/io/ObjectInputStream.java
diff -u kaffe/libraries/javalib/java/io/ObjectInputStream.java:1.47 kaffe/libraries/javalib/java/io/ObjectInputStream.java:1.48
--- kaffe/libraries/javalib/java/io/ObjectInputStream.java:1.47 Sat Jan 22 18:21:56 2005
+++ kaffe/libraries/javalib/java/io/ObjectInputStream.java Wed Feb 2 23:16:12 2005
@@ -1946,24 +1946,24 @@
System.loadLibrary ("io");
}
}
-}
-
-// 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: kaffe/libraries/javalib/java/io/ObjectStreamClass.java
diff -u kaffe/libraries/javalib/java/io/ObjectStreamClass.java:1.29 kaffe/libraries/javalib/java/io/ObjectStreamClass.java:1.30
--- kaffe/libraries/javalib/java/io/ObjectStreamClass.java:1.29 Mon Dec 6 17:39:57 2004
+++ kaffe/libraries/javalib/java/io/ObjectStreamClass.java Wed Feb 2 23:16:12 2005
@@ -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: kaffe/libraries/javalib/java/lang/Math.java
diff -u kaffe/libraries/javalib/java/lang/Math.java:1.10 kaffe/libraries/javalib/java/lang/Math.java:1.11
--- kaffe/libraries/javalib/java/lang/Math.java:1.10 Fri Apr 12 12:56:39 2002
+++ kaffe/libraries/javalib/java/lang/Math.java Wed Feb 2 23:16:13 2005
@@ -144,14 +144,15 @@
return(angdeg * PI / 180);
}
-}
-
-/**
- * This is here we we only init the random number generator when we
- * actually use it.
- */
-class MathRandom {
-
-static Random random = new Random();
+ /**
+ * This is here we we only init the random number generator when we
+ * actually use it.
+ */
+ private static final class MathRandom {
+
+ static Random random = new Random();
+
+ }
}
+
Index: kaffe/libraries/javalib/java/lang/SecurityManager.java
diff -u kaffe/libraries/javalib/java/lang/SecurityManager.java:1.24 kaffe/libraries/javalib/java/lang/SecurityManager.java:1.25
--- kaffe/libraries/javalib/java/lang/SecurityManager.java:1.24 Wed Dec 8 07:22:33 2004
+++ kaffe/libraries/javalib/java/lang/SecurityManager.java Wed Feb 2 23:16:13 2005
@@ -1052,11 +1052,3 @@
}
}
} // class SecurityManager
-
-// XXX This class is unnecessary.
-class SecurityContext {
- Class[] classes;
- SecurityContext(Class[] classes) {
- this.classes = classes;
- }
-}
Index: kaffe/libraries/javalib/java/security/AllPermission.java
diff -u kaffe/libraries/javalib/java/security/AllPermission.java:1.3 kaffe/libraries/javalib/java/security/AllPermission.java:1.4
--- kaffe/libraries/javalib/java/security/AllPermission.java:1.3 Sat Oct 23 18:18:13 2004
+++ kaffe/libraries/javalib/java/security/AllPermission.java Wed Feb 2 23:16:13 2005
@@ -135,64 +135,64 @@
{
return new AllPermissionCollection();
}
-} // class AllPermission
-
-/**
- * Implements AllPermission.newPermissionCollection, and obeys serialization
- * of JDK.
- *
- * @author Eric Blake <ebb9 at email.byu.edu>
- */
-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 <ebb9 at email.byu.edu>
*/
- 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: kaffe/libraries/javalib/java/security/BasicPermission.java
diff -u kaffe/libraries/javalib/java/security/BasicPermission.java:1.6 kaffe/libraries/javalib/java/security/BasicPermission.java:1.7
--- kaffe/libraries/javalib/java/security/BasicPermission.java:1.6 Sat Oct 23 18:18:13 2004
+++ kaffe/libraries/javalib/java/security/BasicPermission.java Wed Feb 2 23:16:13 2005
@@ -198,111 +198,111 @@
{
return new BasicPermissionCollection(getClass());
}
-} // class BasicPermission
-
-/**
- * Implements AllPermission.newPermissionCollection, and obeys serialization
- * of JDK.
- *
- * @author Eric Blake <ebb9 at email.byu.edu>
- */
-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 <ebb9 at email.byu.edu>
*/
- 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: kaffe/libraries/javalib/java/security/Permissions.java
diff -u kaffe/libraries/javalib/java/security/Permissions.java:1.5 kaffe/libraries/javalib/java/security/Permissions.java:1.6
--- kaffe/libraries/javalib/java/security/Permissions.java:1.5 Tue Nov 9 22:08:19 2004
+++ kaffe/libraries/javalib/java/security/Permissions.java Wed Feb 2 23:16:13 2005
@@ -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 <ebb9 at email.byu.edu>
- */
-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 <ebb9 at email.byu.edu>
*/
- 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: kaffe/libraries/javalib/java/text/MessageFormat.java
diff -u kaffe/libraries/javalib/java/text/MessageFormat.java:1.34 kaffe/libraries/javalib/java/text/MessageFormat.java:1.35
--- kaffe/libraries/javalib/java/text/MessageFormat.java:1.34 Tue Jan 18 15:23:58 2005
+++ kaffe/libraries/javalib/java/text/MessageFormat.java Wed Feb 2 23:16:15 2005
@@ -46,107 +46,107 @@
import java.util.Locale;
import java.util.Vector;
-/**
- * @author Tom Tromey <tromey at cygnus.com>
- * @author Jorge Aliss <jaliss at hotmail.com>
- * @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)
+ /**
+ * @author Tom Tromey <tromey at cygnus.com>
+ * @author Jorge Aliss <jaliss at hotmail.com>
+ * @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
{
- 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);
- }
+ // 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;
+
+ 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: kaffe/libraries/javalib/java/util/AbstractList.java
diff -u kaffe/libraries/javalib/java/util/AbstractList.java:1.11 kaffe/libraries/javalib/java/util/AbstractList.java:1.12
--- kaffe/libraries/javalib/java/util/AbstractList.java:1.11 Wed Aug 18 13:44:24 2004
+++ kaffe/libraries/javalib/java/util/AbstractList.java Wed Feb 2 23:16:15 2005
@@ -751,476 +751,475 @@
return new SubList(this, fromIndex, toIndex);
}
-} // class AbstractList
-
-
-/**
- * This class follows the implementation requirements set forth in
- * {@link 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 <ebb9 at email.byu.edu>
- */
-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 < 0 || index > 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 < 0 || index >= 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
*** Patch too long, truncated ***
More information about the kaffe
mailing list