diff options
Diffstat (limited to 'java/security/Permissions.java')
-rw-r--r-- | java/security/Permissions.java | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/java/security/Permissions.java b/java/security/Permissions.java index d814064e0..40087ba02 100644 --- a/java/security/Permissions.java +++ b/java/security/Permissions.java @@ -1,5 +1,5 @@ /* Permissions.java -- a collection of permission collections - Copyright (C) 1998, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1998, 2001, 2002, 2004, 2005, 2014 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -78,7 +78,8 @@ public final class Permissions extends PermissionCollection * * @serial maps Class to PermissionCollection */ - final Hashtable perms = new Hashtable(); + final Hashtable<Class<?>,PermissionCollection> perms = + new Hashtable<Class<?>,PermissionCollection>(); /** * This method initializes a new instance of <code>Permissions</code>. @@ -99,6 +100,7 @@ public final class Permissions extends PermissionCollection * @param perm the <code>Permission</code> to add * @throws SecurityException if this collection is marked as read only */ + @Override public void add(Permission perm) { if (isReadOnly()) @@ -114,8 +116,7 @@ public final class Permissions extends PermissionCollection } else { - PermissionCollection pc - = (PermissionCollection) perms.get(perm.getClass()); + PermissionCollection pc = perms.get(perm.getClass()); if (pc == null) { pc = perm.newPermissionCollection(); @@ -134,12 +135,12 @@ public final class Permissions extends PermissionCollection * @param perm the <code>Permission</code> to test * @return true if the specified permission is implied by this */ + @Override public boolean implies(Permission perm) { if (allPermission != null) return true; - PermissionCollection pc - = (PermissionCollection) perms.get(perm.getClass()); + PermissionCollection pc = perms.get(perm.getClass()); return pc == null ? false : pc.implies(perm); } @@ -150,41 +151,41 @@ public final class Permissions extends PermissionCollection * * @return an <code>Enumeration</code> of this collection's elements */ + @Override public Enumeration<Permission> elements() { - return new Enumeration() + return new Enumeration<Permission>() { - Enumeration main_enum = perms.elements(); - Enumeration sub_enum; + Enumeration<PermissionCollection> mainEnum = perms.elements(); + Enumeration<Permission> subEnum; public boolean hasMoreElements() { - if (sub_enum == null) + if (subEnum == null) { - if (main_enum == null) + if (mainEnum == null) return false; - if (! main_enum.hasMoreElements()) + if (! mainEnum.hasMoreElements()) { - main_enum = null; + mainEnum = null; return false; } - PermissionCollection pc = - (PermissionCollection) main_enum.nextElement(); - sub_enum = pc.elements(); + PermissionCollection pc = mainEnum.nextElement(); + subEnum = pc.elements(); } - if (! sub_enum.hasMoreElements()) + if (! subEnum.hasMoreElements()) { - sub_enum = null; + subEnum = null; return hasMoreElements(); } return true; } - public Object nextElement() + public Permission nextElement() { if (! hasMoreElements()) throw new NoSuchElementException(); - return sub_enum.nextElement(); + return subEnum.nextElement(); } }; } @@ -207,7 +208,8 @@ public final class Permissions extends PermissionCollection * * @serial the stored permissions, both as key and value */ - private final Hashtable perms = new Hashtable(); + private final Hashtable<Permission,Permission> perms = + new Hashtable<Permission,Permission>(); /** * Add a permission. We don't need to check for read-only, as this @@ -216,6 +218,7 @@ public final class Permissions extends PermissionCollection * * @param perm the permission to add */ + @Override public void add(Permission perm) { perms.put(perm, perm); @@ -228,13 +231,14 @@ public final class Permissions extends PermissionCollection * @return true if it is implied */ // FIXME: Should this method be synchronized? + @Override public boolean implies(Permission perm) { - Enumeration elements = elements(); + Enumeration<Permission> elements = elements(); while (elements.hasMoreElements()) { - Permission p = (Permission)elements.nextElement(); + Permission p = elements.nextElement(); if (p.implies(perm)) return true; } @@ -246,7 +250,8 @@ public final class Permissions extends PermissionCollection * * @return the elements */ - public Enumeration elements() + @Override + public Enumeration<Permission> elements() { return perms.elements(); } |