tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r722621 - in /tomcat/trunk/java/org/apache/catalina: users/ util/
Date Tue, 02 Dec 2008 21:34:38 GMT
Author: markt
Date: Tue Dec  2 13:34:37 2008
New Revision: 722621

URL: http://svn.apache.org/viewvc?rev=722621&view=rev
Log:
Generics for o.a.c.users and o.a.c.util

Modified:
    tomcat/trunk/java/org/apache/catalina/users/AbstractGroup.java
    tomcat/trunk/java/org/apache/catalina/users/AbstractUser.java
    tomcat/trunk/java/org/apache/catalina/users/MemoryGroup.java
    tomcat/trunk/java/org/apache/catalina/users/MemoryUser.java
    tomcat/trunk/java/org/apache/catalina/users/MemoryUserDatabase.java
    tomcat/trunk/java/org/apache/catalina/users/MemoryUserDatabaseFactory.java
    tomcat/trunk/java/org/apache/catalina/util/Enumerator.java
    tomcat/trunk/java/org/apache/catalina/util/ParameterMap.java
    tomcat/trunk/java/org/apache/catalina/util/RequestUtil.java
    tomcat/trunk/java/org/apache/catalina/util/ResourceSet.java

Modified: tomcat/trunk/java/org/apache/catalina/users/AbstractGroup.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/users/AbstractGroup.java?rev=722621&r1=722620&r2=722621&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/users/AbstractGroup.java (original)
+++ tomcat/trunk/java/org/apache/catalina/users/AbstractGroup.java Tue Dec  2 13:34:37 2008
@@ -23,6 +23,7 @@
 
 import org.apache.catalina.Group;
 import org.apache.catalina.Role;
+import org.apache.catalina.User;
 import org.apache.catalina.UserDatabase;
 
 
@@ -104,7 +105,7 @@
     /**
      * Return the set of {@link Role}s assigned specifically to this group.
      */
-    public abstract Iterator getRoles();
+    public abstract Iterator<Role> getRoles();
 
 
     /**
@@ -117,7 +118,7 @@
      * Return an Iterator over the set of {@link org.apache.catalina.User}s that 
      * are members of this group.
      */
-    public abstract Iterator getUsers();
+    public abstract Iterator<User> getUsers();
 
 
     // --------------------------------------------------------- Public Methods

Modified: tomcat/trunk/java/org/apache/catalina/users/AbstractUser.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/users/AbstractUser.java?rev=722621&r1=722620&r2=722621&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/users/AbstractUser.java (original)
+++ tomcat/trunk/java/org/apache/catalina/users/AbstractUser.java Tue Dec  2 13:34:37 2008
@@ -85,7 +85,7 @@
     /**
      * Return the set of {@link Group}s to which this user belongs.
      */
-    public abstract Iterator getGroups();
+    public abstract Iterator<Group> getGroups();
 
 
     /**
@@ -117,7 +117,7 @@
     /**
      * Return the set of {@link Role}s assigned specifically to this user.
      */
-    public abstract Iterator getRoles();
+    public abstract Iterator<Role> getRoles();
 
 
     /**

Modified: tomcat/trunk/java/org/apache/catalina/users/MemoryGroup.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/users/MemoryGroup.java?rev=722621&r1=722620&r2=722621&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/users/MemoryGroup.java (original)
+++ tomcat/trunk/java/org/apache/catalina/users/MemoryGroup.java Tue Dec  2 13:34:37 2008
@@ -23,6 +23,7 @@
 import java.util.Iterator;
 
 import org.apache.catalina.Role;
+import org.apache.catalina.User;
 import org.apache.catalina.UserDatabase;
 
 
@@ -72,7 +73,7 @@
     /**
      * The set of {@link Role}s associated with this group.
      */
-    protected ArrayList roles = new ArrayList();
+    protected ArrayList<Role> roles = new ArrayList<Role>();
 
 
     // ------------------------------------------------------------- Properties
@@ -81,7 +82,7 @@
     /**
      * Return the set of {@link Role}s assigned specifically to this group.
      */
-    public Iterator getRoles() {
+    public Iterator<Role> getRoles() {
 
         synchronized (roles) {
             return (roles.iterator());
@@ -103,12 +104,12 @@
     /**
      * Return the set of {@link org.apache.catalina.User}s that are members of this group.
      */
-    public Iterator getUsers() {
+    public Iterator<User> getUsers() {
 
-        ArrayList results = new ArrayList();
-        Iterator users = database.getUsers();
+        ArrayList<User> results = new ArrayList<User>();
+        Iterator<User> users = database.getUsers();
         while (users.hasNext()) {
-            MemoryUser user = (MemoryUser) users.next();
+            User user = users.next();
             if (user.isInGroup(this)) {
                 results.add(user);
             }
@@ -194,13 +195,13 @@
             if (roles.size() > 0) {
                 sb.append(" roles=\"");
                 int n = 0;
-                Iterator values = roles.iterator();
+                Iterator<Role> values = roles.iterator();
                 while (values.hasNext()) {
                     if (n > 0) {
                         sb.append(',');
                     }
                     n++;
-                    sb.append((String) ((Role) values.next()).getRolename());
+                    sb.append((values.next()).getRolename());
                 }
                 sb.append("\"");
             }

Modified: tomcat/trunk/java/org/apache/catalina/users/MemoryUser.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/users/MemoryUser.java?rev=722621&r1=722620&r2=722621&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/users/MemoryUser.java (original)
+++ tomcat/trunk/java/org/apache/catalina/users/MemoryUser.java Tue Dec  2 13:34:37 2008
@@ -75,13 +75,13 @@
     /**
      * The set of {@link Group}s that this user is a member of.
      */
-    protected ArrayList groups = new ArrayList();
+    protected ArrayList<Group> groups = new ArrayList<Group>();
 
 
     /**
      * The set of {@link Role}s associated with this user.
      */
-    protected ArrayList roles = new ArrayList();
+    protected ArrayList<Role> roles = new ArrayList<Role>();
 
 
     // ------------------------------------------------------------- Properties
@@ -90,7 +90,7 @@
     /**
      * Return the set of {@link Group}s to which this user belongs.
      */
-    public Iterator getGroups() {
+    public Iterator<Group> getGroups() {
 
         synchronized (groups) {
             return (groups.iterator());
@@ -102,7 +102,7 @@
     /**
      * Return the set of {@link Role}s assigned specifically to this user.
      */
-    public Iterator getRoles() {
+    public Iterator<Role> getRoles() {
 
         synchronized (roles) {
             return (roles.iterator());
@@ -262,13 +262,13 @@
             if (groups.size() > 0) {
                 sb.append(" groups=\"");
                 int n = 0;
-                Iterator values = groups.iterator();
+                Iterator<Group> values = groups.iterator();
                 while (values.hasNext()) {
                     if (n > 0) {
                         sb.append(',');
                     }
                     n++;
-                    sb.append(RequestUtil.filter(((Group) values.next()).getGroupname()));
+                    sb.append(RequestUtil.filter(values.next().getGroupname()));
                 }
                 sb.append("\"");
             }
@@ -277,13 +277,13 @@
             if (roles.size() > 0) {
                 sb.append(" roles=\"");
                 int n = 0;
-                Iterator values = roles.iterator();
+                Iterator<Role> values = roles.iterator();
                 while (values.hasNext()) {
                     if (n > 0) {
                         sb.append(',');
                     }
                     n++;
-                    sb.append(RequestUtil.filter(((Role) values.next()).getRolename()));
+                    sb.append(RequestUtil.filter(values.next().getRolename()));
                 }
                 sb.append("\"");
             }

Modified: tomcat/trunk/java/org/apache/catalina/users/MemoryUserDatabase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/users/MemoryUserDatabase.java?rev=722621&r1=722620&r2=722621&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/users/MemoryUserDatabase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/users/MemoryUserDatabase.java Tue Dec  2 13:34:37
2008
@@ -87,7 +87,7 @@
      * The set of {@link Group}s defined in this database, keyed by
      * group name.
      */
-    protected HashMap groups = new HashMap();
+    protected HashMap<String,Group> groups = new HashMap<String,Group>();
 
 
     /**
@@ -126,7 +126,7 @@
      * The set of {@link Role}s defined in this database, keyed by
      * role name.
      */
-    protected HashMap roles = new HashMap();
+    protected HashMap<String,Role> roles = new HashMap<String,Role>();
 
 
     /**
@@ -140,7 +140,7 @@
      * The set of {@link User}s defined in this database, keyed by
      * user name.
      */
-    protected HashMap users = new HashMap();
+    protected HashMap<String,User> users = new HashMap<String,User>();
 
 
     // ------------------------------------------------------------- Properties
@@ -149,7 +149,7 @@
     /**
      * Return the set of {@link Group}s defined in this user database.
      */
-    public Iterator getGroups() {
+    public Iterator<Group> getGroups() {
 
         synchronized (groups) {
             return (groups.values().iterator());
@@ -217,7 +217,7 @@
     /**
      * Return the set of {@link Role}s defined in this user database.
      */
-    public Iterator getRoles() {
+    public Iterator<Role> getRoles() {
 
         synchronized (roles) {
             return (roles.values().iterator());
@@ -229,7 +229,7 @@
     /**
      * Return the set of {@link User}s defined in this user database.
      */
-    public Iterator getUsers() {
+    public Iterator<User> getUsers() {
 
         synchronized (users) {
             return (users.values().iterator());
@@ -323,7 +323,7 @@
     public Group findGroup(String groupname) {
 
         synchronized (groups) {
-            return ((Group) groups.get(groupname));
+            return groups.get(groupname);
         }
 
     }
@@ -338,7 +338,7 @@
     public Role findRole(String rolename) {
 
         synchronized (roles) {
-            return ((Role) roles.get(rolename));
+            return roles.get(rolename);
         }
 
     }
@@ -353,7 +353,7 @@
     public User findUser(String username) {
 
         synchronized (users) {
-            return ((User) users.get(username));
+            return users.get(username);
         }
 
     }
@@ -405,7 +405,7 @@
                     try {
                         fis.close();
                     } catch (Throwable t) {
-                        ;
+                        // Ignore
                     }
                     throw e;
                 }
@@ -424,9 +424,9 @@
     public void removeGroup(Group group) {
 
         synchronized (groups) {
-            Iterator users = getUsers();
+            Iterator<User> users = getUsers();
             while (users.hasNext()) {
-                User user = (User) users.next();
+                User user = users.next();
                 user.removeGroup(group);
             }
             groups.remove(group.getGroupname());
@@ -443,14 +443,14 @@
     public void removeRole(Role role) {
 
         synchronized (roles) {
-            Iterator groups = getGroups();
+            Iterator<Group> groups = getGroups();
             while (groups.hasNext()) {
-                Group group = (Group) groups.next();
+                Group group = groups.next();
                 group.removeRole(role);
             }
-            Iterator users = getUsers();
+            Iterator<User> users = getUsers();
             while (users.hasNext()) {
-                User user = (User) users.next();
+                User user = users.next();
                 user.removeRole(role);
             }
             roles.remove(role.getRolename());
@@ -527,7 +527,7 @@
             writer.println("<tomcat-users>");
 
             // Print entries for each defined role, group, and user
-            Iterator values = null;
+            Iterator<?> values = null;
             values = getRoles();
             while (values.hasNext()) {
                 writer.print("  ");

Modified: tomcat/trunk/java/org/apache/catalina/users/MemoryUserDatabaseFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/users/MemoryUserDatabaseFactory.java?rev=722621&r1=722620&r2=722621&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/users/MemoryUserDatabaseFactory.java (original)
+++ tomcat/trunk/java/org/apache/catalina/users/MemoryUserDatabaseFactory.java Tue Dec  2
13:34:37 2008
@@ -71,7 +71,7 @@
      *  creating this object
      */
     public Object getObjectInstance(Object obj, Name name, Context nameCtx,
-                                    Hashtable environment)
+                                    Hashtable<?,?> environment)
         throws Exception {
 
         // We only know how to deal with <code>javax.naming.Reference</code>s

Modified: tomcat/trunk/java/org/apache/catalina/util/Enumerator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/Enumerator.java?rev=722621&r1=722620&r2=722621&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/Enumerator.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/Enumerator.java Tue Dec  2 13:34:37 2008
@@ -38,7 +38,7 @@
  * @version $Revision$ $Date$
  */
 
-public final class Enumerator implements Enumeration {
+public final class Enumerator<T> implements Enumeration<T> {
 
 
     // ----------------------------------------------------------- Constructors
@@ -49,7 +49,7 @@
      *
      * @param collection Collection whose values should be enumerated
      */
-    public Enumerator(Collection collection) {
+    public Enumerator(Collection<T> collection) {
 
         this(collection.iterator());
 
@@ -62,7 +62,7 @@
      * @param collection Collection whose values should be enumerated
      * @param clone true to clone iterator
      */
-    public Enumerator(Collection collection, boolean clone) {
+    public Enumerator(Collection<T> collection, boolean clone) {
 
         this(collection.iterator(), clone);
 
@@ -75,7 +75,7 @@
      *
      * @param iterator Iterator to be wrapped
      */
-    public Enumerator(Iterator iterator) {
+    public Enumerator(Iterator<T> iterator) {
 
         super();
         this.iterator = iterator;
@@ -90,13 +90,13 @@
      * @param iterator Iterator to be wrapped
      * @param clone true to clone iterator
      */
-    public Enumerator(Iterator iterator, boolean clone) {
+    public Enumerator(Iterator<T> iterator, boolean clone) {
 
         super();
         if (!clone) {
             this.iterator = iterator;
         } else {
-            List list = new ArrayList();
+            List<T> list = new ArrayList<T>();
             while (iterator.hasNext()) {
                 list.add(iterator.next());
             }
@@ -111,7 +111,7 @@
      *
      * @param map Map whose values should be enumerated
      */
-    public Enumerator(Map map) {
+    public Enumerator(Map<?,T> map) {
 
         this(map.values().iterator());
 
@@ -124,7 +124,7 @@
      * @param map Map whose values should be enumerated
      * @param clone true to clone iterator
      */
-    public Enumerator(Map map, boolean clone) {
+    public Enumerator(Map<?,T> map, boolean clone) {
 
         this(map.values().iterator(), clone);
 
@@ -138,7 +138,7 @@
      * The <code>Iterator</code> over which the <code>Enumeration</code>
      * represented by this class actually operates.
      */
-    private Iterator iterator = null;
+    private Iterator<T> iterator = null;
 
 
     // --------------------------------------------------------- Public Methods
@@ -166,7 +166,7 @@
      *
      * @exception NoSuchElementException if no more elements exist
      */
-    public Object nextElement() throws NoSuchElementException {
+    public T nextElement() throws NoSuchElementException {
 
         return (iterator.next());
 

Modified: tomcat/trunk/java/org/apache/catalina/util/ParameterMap.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/ParameterMap.java?rev=722621&r1=722620&r2=722621&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/ParameterMap.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/ParameterMap.java Tue Dec  2 13:34:37 2008
@@ -34,7 +34,7 @@
  * @version $Revision$ $Date$
  */
 
-public final class ParameterMap extends HashMap {
+public final class ParameterMap<K,V> extends HashMap<K,V> {
 
 
     // ----------------------------------------------------------- Constructors
@@ -83,7 +83,7 @@
      *
      * @param map Map whose contents are dupliated in the new map
      */
-    public ParameterMap(Map map) {
+    public ParameterMap(Map<K,V> map) {
 
         super(map);
 
@@ -160,7 +160,7 @@
      *
      * @exception IllegalStateException if this map is currently locked
      */
-    public Object put(Object key, Object value) {
+    public V put(K key, V value) {
 
         if (locked)
             throw new IllegalStateException
@@ -179,7 +179,7 @@
      *
      * @exception IllegalStateException if this map is currently locked
      */
-    public void putAll(Map map) {
+    public void putAll(Map<? extends K,? extends V> map) {
 
         if (locked)
             throw new IllegalStateException
@@ -199,7 +199,7 @@
      *
      * @exception IllegalStateException if this map is currently locked
      */
-    public Object remove(Object key) {
+    public V remove(Object key) {
 
         if (locked)
             throw new IllegalStateException

Modified: tomcat/trunk/java/org/apache/catalina/util/RequestUtil.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/RequestUtil.java?rev=722621&r1=722620&r2=722621&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/RequestUtil.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/RequestUtil.java Tue Dec  2 13:34:37 2008
@@ -159,8 +159,8 @@
      *
      * @exception IllegalArgumentException if the data is malformed
      */
-    public static void parseParameters(Map map, String data, String encoding)
-        throws UnsupportedEncodingException {
+    public static void parseParameters(Map<String,String[]> map, String data,
+            String encoding) throws UnsupportedEncodingException {
 
         if ((data != null) && (data.length() > 0)) {
 
@@ -328,9 +328,10 @@
      * @param name The parameter name
      * @param value The parameter value
      */
-    private static void putMapEntry( Map map, String name, String value) {
+    private static void putMapEntry( Map<String,String[]> map, String name,
+            String value) {
         String[] newValues = null;
-        String[] oldValues = (String[]) map.get(name);
+        String[] oldValues = map.get(name);
         if (oldValues == null) {
             newValues = new String[1];
             newValues[0] = value;
@@ -362,8 +363,8 @@
      *
      * @exception UnsupportedEncodingException if the data is malformed
      */
-    public static void parseParameters(Map map, byte[] data, String encoding)
-        throws UnsupportedEncodingException {
+    public static void parseParameters(Map<String,String[]> map, byte[] data,
+            String encoding) throws UnsupportedEncodingException {
 
         if (data != null && data.length > 0) {
             int    ix = 0;

Modified: tomcat/trunk/java/org/apache/catalina/util/ResourceSet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/ResourceSet.java?rev=722621&r1=722620&r2=722621&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/ResourceSet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/ResourceSet.java Tue Dec  2 13:34:37 2008
@@ -34,7 +34,7 @@
  * @version $Revision$ $Date$
  */
 
-public final class ResourceSet extends HashSet {
+public final class ResourceSet<T> extends HashSet<T> {
 
 
     // ----------------------------------------------------------- Constructors
@@ -83,7 +83,7 @@
      *
      * @param coll The collection whose contents we should copy
      */
-    public ResourceSet(Collection coll) {
+    public ResourceSet(Collection<T> coll) {
 
         super(coll);
 
@@ -139,7 +139,7 @@
      *
      * @exception IllegalStateException if this ResourceSet is locked
      */
-    public boolean add(Object o) {
+    public boolean add(T o) {
 
         if (locked)
             throw new IllegalStateException



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message