diff options
| author | Dalibor Topic <robilad@yahoo.com> | 2005-02-03 19:20:04 +0000 |
|---|---|---|
| committer | Dalibor Topic <robilad@yahoo.com> | 2005-02-03 19:20:04 +0000 |
| commit | 06f685dab27ccf70c817ce01a455bb9b0fc18a73 (patch) | |
| tree | 8c85b3022d2a3bdb8079049374c46be1acd07481 /java/security | |
| parent | 239c58d5b47a896ea85459f8ab13f4f2208e1086 (diff) | |
| download | classpath-06f685dab27ccf70c817ce01a455bb9b0fc18a73.tar.gz | |
Small inner classes cleanup
2005-02-03 Dalibor Topic <robilad@kaffe.org>
* 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.
Diffstat (limited to 'java/security')
| -rw-r--r-- | java/security/AllPermission.java | 112 | ||||
| -rw-r--r-- | java/security/BasicPermission.java | 194 | ||||
| -rw-r--r-- | java/security/Permissions.java | 98 |
3 files changed, 202 insertions, 202 deletions
diff --git a/java/security/AllPermission.java b/java/security/AllPermission.java index 32d0b45f5..efe052112 100644 --- a/java/security/AllPermission.java +++ b/java/security/AllPermission.java @@ -135,64 +135,64 @@ public final class AllPermission extends Permission { return new AllPermissionCollection(); } -} // class AllPermission - -/** - * Implements AllPermission.newPermissionCollection, and obeys serialization - * of JDK. - * - * @author Eric Blake <ebb9@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. - * - * @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. + * Implements AllPermission.newPermissionCollection, and obeys serialization + * of JDK. * - * @return the elements in the collection + * @author Eric Blake <ebb9@email.byu.edu> */ - public Enumeration elements() + private static final class AllPermissionCollection extends PermissionCollection { - return all_allowed - ? Collections.enumeration(Collections.singleton(new AllPermission())) - : EmptyEnumeration.getInstance(); - } -} // class AllPermissionCollection + /** + * 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. + * + * @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 diff --git a/java/security/BasicPermission.java b/java/security/BasicPermission.java index a856206f6..3ce0f98c9 100644 --- a/java/security/BasicPermission.java +++ b/java/security/BasicPermission.java @@ -198,111 +198,111 @@ public abstract class BasicPermission extends java.security.Permission { return new BasicPermissionCollection(getClass()); } -} // class BasicPermission -/** - * Implements AllPermission.newPermissionCollection, and obeys serialization - * of JDK. - * - * @author Eric Blake <ebb9@email.byu.edu> - */ -final class BasicPermissionCollection extends PermissionCollection -{ /** - * Compatible with JDK 1.1+. - */ - private static final long serialVersionUID = 739301742472979399L; - - /** - * The permissions in the collection. + * Implements AllPermission.newPermissionCollection, and obeys serialization + * of JDK. * - * @serial a hash mapping name to permissions, all of type permClass + * @author Eric Blake <ebb9@email.byu.edu> */ - private final Hashtable permissions = new Hashtable(); + private static final class BasicPermissionCollection extends PermissionCollection + { + /** + * Compatible with JDK 1.1+. + */ + private static final long serialVersionUID = 739301742472979399L; - /** - * If "*" is in the collection. - * - * @serial true if a permission named "*" is in the collection - */ - private boolean all_allowed; + /** + * The permissions in the collection. + * + * @serial a hash mapping name to permissions, all of type permClass + */ + private final Hashtable permissions = new Hashtable(); - /** - * The runtime class which all entries in the table must belong to. - * - * @serial the limiting subclass of this collection - */ - private final Class permClass; + /** + * If "*" is in the collection. + * + * @serial true if a permission named "*" is in the collection + */ + private boolean all_allowed; - /** - * Construct a collection over the given runtime class. - * - * @param c the class - */ - BasicPermissionCollection(Class c) - { - permClass = c; - } + /** + * The runtime class which all entries in the table must belong to. + * + * @serial the limiting subclass of this collection + */ + private final Class permClass; - /** - * 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); - } + /** + * Construct a collection over the given runtime class. + * + * @param c the class + */ + BasicPermissionCollection(Class c) + { + permClass = c; + } - /** - * 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; + /** + * 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); + } - while (true) - { - if (permissions.get(name) != null) - return true; - prefixLength = name.lastIndexOf('.', prefixLength); - if (prefixLength < 0) - return false; - name = name.substring(0, prefixLength + 1) + '*'; - } - } + /** + * 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; - /** - * Enumerate over the collection. - * - * @return an enumeration of the collection contents - */ - public Enumeration elements() - { - return permissions.elements(); - } -} // class BasicPermissionCollection + 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 diff --git a/java/security/Permissions.java b/java/security/Permissions.java index d44341c94..1efe8f435 100644 --- a/java/security/Permissions.java +++ b/java/security/Permissions.java @@ -188,58 +188,58 @@ public final class Permissions extends PermissionCollection } }; } -} // class Permissions -/** - * Implements the permission collection for all permissions without one of - * their own, and obeys serialization of JDK. - * - * @author Eric Blake <ebb9@email.byu.edu> - */ -class PermissionsHash extends PermissionCollection -{ /** - * Compatible with JDK 1.1+. - */ - private static final long serialVersionUID = -8491988220802933440L; - - /** - * Hashtable where we store permissions. - * - * @serial the stored permissions, both as key and value - */ - 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. + * Implements the permission collection for all permissions without one of + * their own, and obeys serialization of JDK. * - * @param perm the permission to add + * @author Eric Blake <ebb9@email.byu.edu> */ - public void add(Permission perm) + private static final class PermissionsHash extends PermissionCollection { - 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(); - } + /** + * Compatible with JDK 1.1+. + */ + private static final long serialVersionUID = -8491988220802933440L; + + /** + * Hashtable where we store permissions. + * + * @serial the stored permissions, both as key and value + */ + 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) + { + 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 |
