import org.apache.catalina.Group;
import org.apache.catalina.Role;
+import org.apache.catalina.User;
import org.apache.catalina.UserDatabase;
/**
* Return the set of {@link Role}s assigned specifically to this group.
*/
- public abstract Iterator getRoles();
+ public abstract Iterator<Role> getRoles();
/**
* 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
/**
* Return the set of {@link Group}s to which this user belongs.
*/
- public abstract Iterator getGroups();
+ public abstract Iterator<Group> getGroups();
/**
/**
* Return the set of {@link Role}s assigned specifically to this user.
*/
- public abstract Iterator getRoles();
+ public abstract Iterator<Role> getRoles();
/**
import java.util.Iterator;
import org.apache.catalina.Role;
+import org.apache.catalina.User;
import org.apache.catalina.UserDatabase;
/**
* The set of {@link Role}s associated with this group.
*/
- protected ArrayList roles = new ArrayList();
+ protected ArrayList<Role> roles = new ArrayList<Role>();
// ------------------------------------------------------------- Properties
/**
* Return the set of {@link Role}s assigned specifically to this group.
*/
- public Iterator getRoles() {
+ public Iterator<Role> getRoles() {
synchronized (roles) {
return (roles.iterator());
/**
* 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);
}
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("\"");
}
/**
* 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
/**
* Return the set of {@link Group}s to which this user belongs.
*/
- public Iterator getGroups() {
+ public Iterator<Group> getGroups() {
synchronized (groups) {
return (groups.iterator());
/**
* Return the set of {@link Role}s assigned specifically to this user.
*/
- public Iterator getRoles() {
+ public Iterator<Role> getRoles() {
synchronized (roles) {
return (roles.iterator());
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("\"");
}
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("\"");
}
* 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>();
/**
* 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>();
/**
* 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
/**
* 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());
/**
* 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());
/**
* 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());
public Group findGroup(String groupname) {
synchronized (groups) {
- return ((Group) groups.get(groupname));
+ return groups.get(groupname);
}
}
public Role findRole(String rolename) {
synchronized (roles) {
- return ((Role) roles.get(rolename));
+ return roles.get(rolename);
}
}
public User findUser(String username) {
synchronized (users) {
- return ((User) users.get(username));
+ return users.get(username);
}
}
try {
fis.close();
} catch (Throwable t) {
- ;
+ // Ignore
}
throw e;
}
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());
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());
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(" ");
* 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
* @version $Revision$ $Date$
*/
-public final class Enumerator implements Enumeration {
+public final class Enumerator<T> implements Enumeration<T> {
// ----------------------------------------------------------- Constructors
*
* @param collection Collection whose values should be enumerated
*/
- public Enumerator(Collection collection) {
+ public Enumerator(Collection<T> collection) {
this(collection.iterator());
* @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);
*
* @param iterator Iterator to be wrapped
*/
- public Enumerator(Iterator iterator) {
+ public Enumerator(Iterator<T> iterator) {
super();
this.iterator = iterator;
* @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());
}
*
* @param map Map whose values should be enumerated
*/
- public Enumerator(Map map) {
+ public Enumerator(Map<?,T> map) {
this(map.values().iterator());
* @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);
* 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
*
* @exception NoSuchElementException if no more elements exist
*/
- public Object nextElement() throws NoSuchElementException {
+ public T nextElement() throws NoSuchElementException {
return (iterator.next());
* @version $Revision$ $Date$
*/
-public final class ParameterMap extends HashMap {
+public final class ParameterMap<K,V> extends HashMap<K,V> {
// ----------------------------------------------------------- Constructors
*
* @param map Map whose contents are dupliated in the new map
*/
- public ParameterMap(Map map) {
+ public ParameterMap(Map<K,V> map) {
super(map);
*
* @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
*
* @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
*
* @exception IllegalStateException if this map is currently locked
*/
- public Object remove(Object key) {
+ public V remove(Object key) {
if (locked)
throw new IllegalStateException
*
* @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)) {
* @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;
*
* @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;
* @version $Revision$ $Date$
*/
-public final class ResourceSet extends HashSet {
+public final class ResourceSet<T> extends HashSet<T> {
// ----------------------------------------------------------- Constructors
*
* @param coll The collection whose contents we should copy
*/
- public ResourceSet(Collection coll) {
+ public ResourceSet(Collection<T> coll) {
super(coll);
*
* @exception IllegalStateException if this ResourceSet is locked
*/
- public boolean add(Object o) {
+ public boolean add(T o) {
if (locked)
throw new IllegalStateException