summaryrefslogtreecommitdiff
path: root/libjava/classpath/javax/management/openmbean
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/javax/management/openmbean')
-rw-r--r--libjava/classpath/javax/management/openmbean/ArrayType.java417
-rw-r--r--libjava/classpath/javax/management/openmbean/CompositeData.java4
-rw-r--r--libjava/classpath/javax/management/openmbean/CompositeDataInvocationHandler.java190
-rw-r--r--libjava/classpath/javax/management/openmbean/CompositeDataSupport.java12
-rw-r--r--libjava/classpath/javax/management/openmbean/CompositeType.java34
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java48
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfo.java2
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfoSupport.java8
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfo.java8
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java38
-rw-r--r--libjava/classpath/javax/management/openmbean/OpenType.java43
-rw-r--r--libjava/classpath/javax/management/openmbean/SimpleType.java72
-rw-r--r--libjava/classpath/javax/management/openmbean/TabularData.java6
-rw-r--r--libjava/classpath/javax/management/openmbean/TabularDataSupport.java16
-rw-r--r--libjava/classpath/javax/management/openmbean/TabularType.java8
15 files changed, 739 insertions, 167 deletions
diff --git a/libjava/classpath/javax/management/openmbean/ArrayType.java b/libjava/classpath/javax/management/openmbean/ArrayType.java
index d2fc398d623..42f80623d9a 100644
--- a/libjava/classpath/javax/management/openmbean/ArrayType.java
+++ b/libjava/classpath/javax/management/openmbean/ArrayType.java
@@ -1,5 +1,5 @@
/* ArrayType.java -- Open type descriptor for an array.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,6 +40,8 @@ package javax.management.openmbean;
import java.lang.reflect.Array;
import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
/**
* The open type descriptor for arrays of open data values.
@@ -47,8 +49,8 @@ import java.util.Arrays;
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
-public class ArrayType
- extends OpenType
+public class ArrayType<T>
+ extends OpenType<T>
{
/**
@@ -64,7 +66,12 @@ public class ArrayType
/**
* The element type of arrays of this type.
*/
- private OpenType elementType;
+ private OpenType<?> elementType;
+
+ /**
+ * True if this type represents a primitive array.
+ */
+ private boolean primitiveArray;
/**
* The hash code of this instance.
@@ -77,19 +84,183 @@ public class ArrayType
private transient String string;
/**
+ * A cache of {@link ArrayType} instances created
+ * by {@link #getArrayType(OpenType)}.
+ */
+ private static final Map<OpenType<?>,ArrayType<?>> cache =
+ new HashMap<OpenType<?>,ArrayType<?>>();
+
+ /**
+ * A cache of {@link ArrayType} instances created
+ * by {@link #getPrimitiveArrayType(Class)}.
+ */
+ private static final Map<Class<?>,ArrayType<?>> primCache =
+ new HashMap<Class<?>,ArrayType<?>>();
+
+ /**
* Returns the class name of the array, given the element
* class name and its dimensions.
*
- * @param className the name of the class used by the
- * array's elements.
+ * @param elementType the type of the array's elements.
* @param dim the dimensions of the array.
+ * @param primitive true if this should be a primitive array.
* @return the array's class name.
+ * @throws OpenDataException if the class name does not reference
+ * a loadable class.
*/
- private static String getArrayClassName(String className, int dim)
+ private static final String getArrayClassName(OpenType<?> elementType,
+ int dim,
+ boolean primitive)
+ throws OpenDataException
{
- char[] brackets = new char[dim];
- Arrays.fill(brackets, '[');
- return String.valueOf(brackets) + "L" + className;
+ Class<?> type;
+ if (primitive)
+ type = getPrimitiveTypeClass((SimpleType<?>) elementType);
+ else
+ {
+ String className = elementType.getClassName();
+ try
+ {
+ type = Class.forName(className);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new OpenDataException("The class name, " + className +
+ ", is unavailable.");
+ }
+ }
+ while (type.isArray())
+ type = type.getComponentType();
+ return
+ Array.newInstance(type,
+ new int[getDimensions(elementType, dim)]).getClass().getName();
+ }
+
+ /**
+ * Returns the dimensions of the new {@link ArrayType},
+ * based on whether the given element type is already an
+ * {@link ArrayType} or not.
+ *
+ * @param elementType the type of the array.
+ * @param dim the proposed dimensions.
+ * @return the resultant dimensions.
+ * @throws IllegalArgumentException if <code>dim</code> is less than 1.
+ */
+ private static final int getDimensions(OpenType<?> elementType,
+ int dim)
+ {
+ if (dim < 1)
+ throw new IllegalArgumentException("Dimensions must be greater " +
+ "than or equal to 1.");
+ if (elementType instanceof ArrayType)
+ return dim + ((ArrayType) elementType).getDimension();
+ return dim;
+ }
+
+ /**
+ * Returns the appropriate primitive type name, given the
+ * corresponding wrapper class.
+ *
+ * @param type the type to convert.
+ * @return the corresponding primitive type.
+ * @throws OpenDataException if {@code type} is not a valid
+ * {@link Class} for a primitive type.
+ *
+ */
+ private static final SimpleType<?> getPrimitiveType(Class<?> type)
+ throws OpenDataException
+ {
+ if (type.equals(Boolean.TYPE))
+ return SimpleType.BOOLEAN;
+ if (type.equals(Byte.TYPE))
+ return SimpleType.BYTE;
+ if (type.equals(Character.TYPE))
+ return SimpleType.CHARACTER;
+ if (type.equals(Double.TYPE))
+ return SimpleType.DOUBLE;
+ if (type.equals(Float.TYPE))
+ return SimpleType.FLOAT;
+ if (type.equals(Integer.TYPE))
+ return SimpleType.INTEGER;
+ if (type.equals(Long.TYPE))
+ return SimpleType.LONG;
+ if (type.equals(Short.TYPE))
+ return SimpleType.SHORT;
+ if (type.equals(Void.TYPE))
+ return SimpleType.VOID;
+ throw new OpenDataException(type + " is not a primitive type.");
+ }
+
+ /**
+ * Returns the appropriate primitive type name, given the
+ * corresponding wrapper class.
+ *
+ * @param type the type to convert.
+ * @return the corresponding primitive type.
+ * @throws OpenDataException if {@code type} is not a valid
+ * {@link SimpleType} for a primitive type.
+ *
+ */
+ private static final Class<?> getPrimitiveTypeClass(SimpleType<?> type)
+ throws OpenDataException
+ {
+ if (type.equals(SimpleType.BOOLEAN))
+ return Boolean.TYPE;
+ if (type.equals(SimpleType.BYTE))
+ return Byte.TYPE;
+ if (type.equals(SimpleType.CHARACTER))
+ return Character.TYPE;
+ if (type.equals(SimpleType.DOUBLE))
+ return Double.TYPE;
+ if (type.equals(SimpleType.FLOAT))
+ return Float.TYPE;
+ if (type.equals(SimpleType.INTEGER))
+ return Integer.TYPE;
+ if (type.equals(SimpleType.LONG))
+ return Long.TYPE;
+ if (type.equals(SimpleType.SHORT))
+ return Short.TYPE;
+ if (type.equals(SimpleType.VOID))
+ return Void.TYPE;
+ throw new OpenDataException(type + " is not a primitive type.");
+ }
+
+ /**
+ * Returns the element type that will actually be used, if the
+ * specified element type is passed to a constructor. This is
+ * necessary to ensure that a non-array type is still returned when
+ * an {@link ArrayType} is constructed from an {@link ArrayType}.
+ *
+ * @param elemType the element type that was supplied.
+ * @return the element type that will be used.
+ */
+ private static final OpenType<?> getElementType(OpenType<?> elemType)
+ {
+ if (elemType instanceof ArrayType)
+ return ((ArrayType) elemType).getElementOpenType();
+ return elemType;
+ }
+
+ /**
+ * Returns the element type name that will actually be used, if the
+ * specified element type is passed to a constructor. This is
+ * necessary to ensure that a non-array type is still returned when
+ * an {@link ArrayType} is constructed from an {@link ArrayType},
+ * and that primitive arrays are described correctly.
+ *
+ * @param elemType the element type that was supplied.
+ * @return the element type name that will be used.
+ * @throws OpenDataException if the element type is not a valid
+ * {@link SimpleType} for a primitive type.
+ */
+ private static final String getElementTypeName(OpenType<?> elemType)
+ throws OpenDataException
+ {
+ OpenType<?> trueElemType = getElementType(elemType);
+ if (elemType instanceof ArrayType &&
+ ((ArrayType) elemType).isPrimitiveArray())
+ return getPrimitiveTypeClass((SimpleType<?>) trueElemType).getName();
+ return trueElemType.getClassName();
}
/**
@@ -136,23 +307,84 @@ public class ArrayType
* {@link SimpleType}, {@link CompositeType}
* or {@link TabularType}.
*/
- public ArrayType(int dim, OpenType elementType)
+ public ArrayType(int dim, OpenType<?> elementType)
throws OpenDataException
{
- super(getArrayClassName(elementType.getClassName(), dim),
- getArrayClassName(elementType.getClassName(), dim),
- dim + "-dimension array of " + elementType.getClassName());
- if (dim < 1)
- throw new IllegalArgumentException("Dimensions must be greater " +
- "than or equal to 1.");
+ super(getArrayClassName(elementType, dim, false),
+ getArrayClassName(elementType, dim, false),
+ getDimensions(elementType, dim) + "-dimension array of "
+ + getElementTypeName(elementType));
if (!(elementType instanceof SimpleType ||
elementType instanceof CompositeType ||
- elementType instanceof TabularType))
+ elementType instanceof TabularType ||
+ elementType instanceof ArrayType))
throw new OpenDataException("The element type must be a simple " +
- "type, a composite type or a tabular " +
- "type.");
- dimension = dim;
+ "type, an array type, a composite type " +
+ "or a tabular type.");
+ dimension = getDimensions(elementType, dim);
+ this.elementType = getElementType(elementType);
+ primitiveArray = (elementType instanceof ArrayType &&
+ ((ArrayType) elementType).isPrimitiveArray());
+ }
+
+ /**
+ * <p>
+ * Constructs a new {@link ArrayType} instance for a unidimensional
+ * array of the specified {@link SimpleType}. The attributes
+ * used by the superclass, {@link OpenType}, are automatically defined,
+ * based on these values. Both the class name and type name are set
+ * to the value returned by the {@link java.lang.Class#getName()} of
+ * the array's class. If the array is of a primitive type (indicated
+ * by giving {@code primitiveArray} the value {@code true}), the
+ * name will be '[' followed by the appropriate letter for the
+ * primitive type (see {@link java.lang.Class#getName()}). If the
+ * array is not of a primitive type, then the name is formed from
+ * the element type, preceded by '[' and an 'L', in the same way
+ * as when the multi-dimensional constructor is used.
+ * </p>
+ * <p>
+ * The description is based upon the template <code>1-dimension array
+ * of e</code>, where e is either the primitive type or a class name,
+ * depending on whether the array itself is of a primitive type or not.
+ * The class name of the actual elements is obtainable by calling
+ * {@link OpenType#getClassName()} on the result of
+ * {@link #getElementOpenType()}. This will be the appropriate wrapper
+ * class for a primitive type.
+ * </p>
+ * <p>
+ * As an example, the array type returned by
+ * <code>new ArrayType(SimpleType.INTEGER, true)</code> has the following
+ * values:
+ * </p>
+ * <table>
+ * <th><td>Attribute</td><td>Value</td></th>
+ * <tr><td>Class Name</td><td><code>[I</code>
+ * </td></tr>
+ * <tr><td>Type Name</td><td><code>[I</code>
+ * </td></tr>
+ * <tr><td>Description</td><td><code>1-dimension array of int</code></td></tr>
+ * <tr><td>Element Type Class Name</td><td><code>java.lang.Integer</code>
+ * </td></tr>
+ * </table>
+ *
+ * @param elementType the type of the elements of the array.
+ * @param primitiveArray true if the array should be of a primitive type.
+ * @throws OpenDataException if {@code primitiveArray} is {@code true},
+ * and {@link elementType} is not a valid
+ * {@link SimpleType} for a primitive type.
+ * @since 1.6
+ */
+ public ArrayType(SimpleType<?> elementType, boolean primitiveArray)
+ throws OpenDataException
+ {
+ super(getArrayClassName(elementType, 1, primitiveArray),
+ getArrayClassName(elementType, 1, primitiveArray),
+ "1-dimension array of " +
+ (primitiveArray ? getPrimitiveTypeClass(elementType).getName()
+ : elementType.getClassName()));
+ dimension = 1;
this.elementType = elementType;
+ this.primitiveArray = primitiveArray;
}
/**
@@ -166,6 +398,8 @@ public class ArrayType
* {@link ArrayType}.</li>
* <li>The dimensions are equal.</li>
* <li>The element types are equal.</li>
+ * <li>The primitive array flag is set the same in both
+ * instances.</li>
* </ul>
*
* @param obj the object to compare with.
@@ -177,7 +411,118 @@ public class ArrayType
return false;
ArrayType atype = (ArrayType) obj;
return (atype.getDimension() == dimension &&
- atype.getElementOpenType().equals(elementType));
+ atype.getElementOpenType().equals(elementType) &&
+ atype.isPrimitiveArray() == primitiveArray);
+ }
+
+ /**
+ * <p>
+ * Returns a new {@link ArrayType} instance in a type-safe
+ * manner, by ensuring that the type of the given {@link OpenType}
+ * matches the component type used in the type of the
+ * returned instance. If the given {@link OpenType} is a
+ * {@link SimpleType}, {@link CompositeType} or
+ * {@link TabularType}, then a 1-dimensional array of that
+ * type is returned. Otherwise, if the type is
+ * an {@link ArrayType} of n dimensions, the returned
+ * type is also an {@link ArrayType} but of n+1 dimensions.
+ * For example,
+ * {@code ArrayType.getArrayType(ArrayType.getArrayType(SimpleType.STRING))}
+ * returns a 2-dimensional array of {@link SimpleType#String}.
+ * </p>
+ * <p>
+ * This method caches its results, so that the same instance
+ * is returned from subsequent calls with the same parameters.
+ * </p>
+ *
+ * @param elementType the element type of the new array type.
+ * @throws OpenDataException if the class name of {@code elementType}
+ * is not in {@link OpenType#ALLOWED_CLASSNAMES_LIST}.
+ * @since 1.6
+ */
+ public static <E> ArrayType<E[]> getArrayType(OpenType<E> elementType)
+ throws OpenDataException
+ {
+ ArrayType<E[]> arr = (ArrayType<E[]>) cache.get(elementType);
+ if (arr != null)
+ return arr;
+ arr = new ArrayType(1, elementType);
+ cache.put(elementType, arr);
+ return arr;
+ }
+
+ /**
+ * <p>
+ * Returns a new {@link ArrayType} instance for the given
+ * primitive type in a type-safe* manner, by ensuring that
+ * the type of the given {@link OpenType} matches the type
+ * used in the returned instance. If the type is
+ * an array of n dimensions, the returned
+ * type is also an {@link ArrayType} of n dimensions.
+ * </p>
+ * <p>
+ * As an example, the array type returned by
+ * <code>getPrimitiveArrayType(Integer.TYPE)</code> has the
+ * following values:
+ * </p>
+ * <table>
+ * <th><td>Attribute</td><td>Value</td></th>
+ * <tr><td>Class Name</td><td><code>[I</code>
+ * </td></tr>
+ * <tr><td>Type Name</td><td><code>[I</code>
+ * </td></tr>
+ * <tr><td>Description</td><td><code>1-dimension array of int</code></td></tr>
+ * <tr><td>Element Type Class Name</td><td><code>java.lang.Integer</code>
+ * </td></tr>
+ * </table>
+ * <p>
+ * This method caches its results, so that the same instance
+ * is returned from subsequent calls with the same parameters.
+ * </p>
+ *
+ * @param type the type of the new {@link ArrayType}.
+ * @throws IllegalArgumentException if the type is not a primitive
+ * array.
+ * @since 1.6
+ */
+ public static <T> ArrayType<T> getPrimitiveArrayType(Class<T> type)
+ {
+ ArrayType<T> arr = (ArrayType<T>) primCache.get(type);
+ if (arr != null)
+ return arr;
+ Class<?> comType = type;
+ int dim = 0;
+ do
+ {
+ comType = comType.getComponentType();
+ ++dim;
+ if (comType == null)
+ throw new IllegalArgumentException("The given class is " +
+ "not an array.");
+ } while (comType.isArray());
+ String className = type.getName();
+ try
+ {
+ arr = new ArrayType(getPrimitiveType(comType), true);
+ }
+ catch (OpenDataException e)
+ {
+ throw new IllegalArgumentException("The array is not of a primitive " +
+ "type", e);
+ }
+ while (dim > 1)
+ try
+ {
+ arr = new ArrayType(1, arr);
+ --dim;
+ }
+ catch (OpenDataException e)
+ {
+ throw (Error)
+ new InternalError("Couldn't generate extra dimensions").initCause(e);
+ }
+ primCache.put(type, arr);
+ return arr;
}
/**
@@ -197,7 +542,7 @@ public class ArrayType
*
* @return the type of the elements.
*/
- public OpenType getElementOpenType()
+ public OpenType<?> getElementOpenType()
{
return elementType;
}
@@ -207,11 +552,11 @@ public class ArrayType
* Returns the hash code of the array type.
* This is computed as the sum of the hash code of the
* element type together with the number of dimensions
- * the array has. These are the same elements
- * of the type that are compared as part of the
- * {@link #equals(java.lang.Object)} method, thus ensuring
- * that the hashcode is compatible with the equality
- * test.
+ * the array has and the primitive array flag. These
+ * are the same elements of the type that are compared as
+ * part of the {@link #equals(java.lang.Object)} method,
+ * thus ensuring that the hashcode is compatible with the
+ * equality test.
* </p>
* <p>
* As instances of this class are immutable, the hash code
@@ -224,11 +569,24 @@ public class ArrayType
public int hashCode()
{
if (hashCode == null)
- hashCode = Integer.valueOf(dimension + elementType.hashCode());
+ hashCode = Integer.valueOf(dimension +
+ elementType.hashCode() +
+ Boolean.valueOf(primitiveArray).hashCode());
return hashCode.intValue();
}
/**
+ * Returns true if this instance represents an array of
+ * a primitive type.
+ *
+ * @return true if the array is of a primitive type.
+ */
+ public boolean isPrimitiveArray()
+ {
+ return primitiveArray;
+ }
+
+ /**
* <p>
* Returns true if the specified object is a member of this
* array type. The object is judged to be so if it is
@@ -306,6 +664,7 @@ public class ArrayType
+ "[name=" + getTypeName()
+ ", dimension=" + dimension
+ ", elementType=" + elementType
+ + ", primitiveArray=" + primitiveArray
+ "]";
return string;
}
diff --git a/libjava/classpath/javax/management/openmbean/CompositeData.java b/libjava/classpath/javax/management/openmbean/CompositeData.java
index 08f0dc253a5..3134bc4c480 100644
--- a/libjava/classpath/javax/management/openmbean/CompositeData.java
+++ b/libjava/classpath/javax/management/openmbean/CompositeData.java
@@ -1,5 +1,5 @@
/* CompositeData.java -- A composite data structure.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -148,7 +148,7 @@ public interface CompositeData
*
* @return the values of this instance.
*/
- Collection values();
+ Collection<?> values();
}
diff --git a/libjava/classpath/javax/management/openmbean/CompositeDataInvocationHandler.java b/libjava/classpath/javax/management/openmbean/CompositeDataInvocationHandler.java
new file mode 100644
index 00000000000..170ec32c7a9
--- /dev/null
+++ b/libjava/classpath/javax/management/openmbean/CompositeDataInvocationHandler.java
@@ -0,0 +1,190 @@
+/* CompositeDataInvocationHandler.java - Pseudo-accessors for CompositeData.
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.management.openmbean;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+/**
+ * <p>
+ * Provides an {@link java.lang.reflect.InvocationHandler} which
+ * implements a series of accessor methods (those beginning with
+ * {@code "get"} or {@code "is"}) using the content of a
+ * {@link CompositeData} object. An instance of {@link CompositeData}
+ * consists of a series of key-value mappings. This handler assumes
+ * these keys to be the names of attributes, and thus provides
+ * accessor methods by returning the associated value.
+ * </p>
+ * <p>
+ * As an example, consider the following interface:
+ * </p>
+ * <pre>
+ * public interface Person
+ * {
+ * public String getName();
+ * public Date getBirthday();
+ * }
+ * </pre>
+ * <p>
+ * This specifies two accessor methods for retrieving the attributes,
+ * {@code name} and {@code birthday}. An implementation of this interface
+ * can be provided by creating an instance of this class, using a
+ * {@link CompositeData} object with appropriate key-value mappings
+ * (e.g. "name" => "Fred", "birthday" => 30/06/1974), and then passing
+ * that to {@link java.lang.reflect.Proxy#newProxyInstance} along with
+ * the interface itself. The invocation handler implements the methods
+ * by calling {@link CompositeData#get(String)} with the appropriate key.
+ * </p>
+ * <p>
+ * The attribute name is derived by taking the remainder of the method
+ * name following {@code "get"}. If the first letter of this substring
+ * is uppercase, then two attempts are made to retrieve the attribute
+ * from the {@link CompositeData} instance: one using the original substring,
+ * and one with the first letter changed to its lower-case equivalent.
+ * If the first letter is lowercase, only the exact substring is used.
+ * </p>
+ * <p>
+ * An {@link Object#equals(Object)} implementation is provided. This returns
+ * true if the argument is a proxy with a {@link CompositeDataInvocationHandler}
+ * using an equivalent {@link CompositeData} instance. {@link Object#hashCode()}
+ * is also defined so as to match this implementation and give equivalent instances
+ * the same hashcode.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.6
+ */
+public class CompositeDataInvocationHandler
+ implements InvocationHandler
+{
+
+ /**
+ * The {@link CompositeData} providing the key-value mappings.
+ */
+ private CompositeData data;
+
+ /**
+ * Constructs a new {@link CompositeDataInvocationHandler}
+ * with the specified {@link CompositeData} instance.
+ *
+ * @param data the {@link CompositeData} instance to use.
+ * @throws IllegalArgumentException if {@code data} is {@code null}.
+ */
+ public CompositeDataInvocationHandler(CompositeData data)
+ {
+ if (data == null)
+ throw new IllegalArgumentException("The CompositeData instance " +
+ "must be non-null.");
+ this.data = data;
+ }
+
+ /**
+ * Returns the {@link CompositeData} instance which provides
+ * the key-value mappings for this instance. This is never
+ * {@code null}.
+ *
+ * @return the {@link CompositeData} instance.
+ */
+ public CompositeData getCompositeData()
+ {
+ return data;
+ }
+
+ /**
+ * Called by the proxy class whenever a method is called. The
+ * handler only deals with accessor methods (beginning with
+ * {@code "get"} or {@code "is"}), {@code equals}, and
+ * {@code "hashCode"}. Accessor methods are implemented by
+ * returning the appropriate value from the {@link CompositeData}
+ * instance, while {@code equals} and {@code hashCode} allow
+ * two proxies with a {@link CompositeDataInvocationHandler} using
+ * the same {@link CompositeData} instance to be classified
+ * as equivalent.
+ *
+ * @param proxy the proxy on which the method was called.
+ * @param method the method which was called.
+ * @param args the arguments supplied to the method.
+ * @return the return value from the method.
+ * @throws Throwable if an exception is thrown in the process.
+ */
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable
+ {
+ String mName = method.getName();
+ if (mName.equals("equals"))
+ {
+ if (args[0] instanceof Proxy)
+ {
+ InvocationHandler h = Proxy.getInvocationHandler(args[0]);
+ if (h instanceof CompositeDataInvocationHandler)
+ return data.equals(((CompositeDataInvocationHandler)
+ h).getCompositeData());
+ }
+ return false;
+ }
+ if (mName.equals("hashCode"))
+ {
+ return data.hashCode();
+ }
+ String attrib = null;
+ if (mName.startsWith("get"))
+ attrib = mName.substring(3);
+ else if (mName.startsWith("is"))
+ attrib = mName.substring(2);
+ if (attrib == null)
+ throw new NoSuchMethodException(mName + " is not an accessor.");
+ if (!data.containsKey(attrib))
+ {
+ if (Character.isLowerCase(attrib.charAt(0)))
+ throw new NoSuchMethodException("The attribute " +
+ attrib + " is not available " +
+ "in the given CompositeData " +
+ "object");
+ attrib = Character.toLowerCase(attrib.charAt(0))
+ + attrib.substring(1);
+ if (!data.containsKey(attrib))
+ throw new NoSuchMethodException("The attribute " +
+ attrib + " is not available " +
+ "in the given CompositeData " +
+ "object");
+ }
+ return data.get(attrib);
+ }
+
+}
diff --git a/libjava/classpath/javax/management/openmbean/CompositeDataSupport.java b/libjava/classpath/javax/management/openmbean/CompositeDataSupport.java
index 5d5adb727f6..d4c9d450c38 100644
--- a/libjava/classpath/javax/management/openmbean/CompositeDataSupport.java
+++ b/libjava/classpath/javax/management/openmbean/CompositeDataSupport.java
@@ -1,5 +1,5 @@
/* CompositeData.java -- A composite data structure implementation.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -68,7 +68,7 @@ public class CompositeDataSupport
*
* @serial the map of field names to values.
*/
- private SortedMap contents;
+ private SortedMap<String, Object> contents;
/**
* The composite type which represents this composite data instance.
@@ -106,11 +106,11 @@ public class CompositeDataSupport
* {@link java.lang.String} (thus calling a failure
* in converting the keys to an array of strings).
*/
- public CompositeDataSupport(CompositeType type, Map items)
+ public CompositeDataSupport(CompositeType type, Map<String, ?> items)
throws OpenDataException
{
this(type,
- (String[]) items.keySet().toArray(new String[items.size()]),
+ items.keySet().toArray(new String[items.size()]),
items.values().toArray());
}
@@ -158,7 +158,7 @@ public class CompositeDataSupport
if (typeKeys.size() != names.length)
throw new OpenDataException("The number of field names does not match " +
"the type description.");
- contents = new TreeMap();
+ contents = new TreeMap<String, Object>();
for (int a = 0; a < names.length; ++a)
{
if (names[a] == null)
@@ -340,7 +340,7 @@ public class CompositeDataSupport
*
* @return the values of this instance.
*/
- public Collection values()
+ public Collection<?> values()
{
return Collections.unmodifiableCollection(contents.values());
}
diff --git a/libjava/classpath/javax/management/openmbean/CompositeType.java b/libjava/classpath/javax/management/openmbean/CompositeType.java
index 0ae5a4e4bfe..1a213f607c9 100644
--- a/libjava/classpath/javax/management/openmbean/CompositeType.java
+++ b/libjava/classpath/javax/management/openmbean/CompositeType.java
@@ -1,5 +1,5 @@
/* CompositeType.java -- Type descriptor for CompositeData instances.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -51,7 +51,7 @@ import java.util.TreeMap;
* @since 1.5
*/
public class CompositeType
- extends OpenType
+ extends OpenType<CompositeData>
{
/**
@@ -62,12 +62,12 @@ public class CompositeType
/**
* A map of item names to their descriptions.
*/
- private TreeMap nameToDescription;
+ private TreeMap<String,String> nameToDescription;
/**
* A map of item names to their types.
*/
- private TreeMap nameToType;
+ private TreeMap<String,OpenType<?>> nameToType;
/**
* The hash code of this instance.
@@ -109,7 +109,7 @@ public class CompositeType
* before comparison.
*/
public CompositeType(String name, String desc, String[] names,
- String[] descs, OpenType[] types)
+ String[] descs, OpenType<?>[] types)
throws OpenDataException
{
super(CompositeData.class.getName(), name, desc);
@@ -138,7 +138,7 @@ public class CompositeType
"than once.");
nameToDescription.put(fieldName, descs[a]);
}
- nameToType = new TreeMap();
+ nameToType = new TreeMap<String,OpenType<?>>();
for (int a = 0; a < names.length; ++a)
nameToType.put(names[a].trim(), types[a]);
}
@@ -178,16 +178,14 @@ public class CompositeType
CompositeType ctype = (CompositeType) obj;
if (!(ctype.getTypeName().equals(getTypeName())))
return false;
- Set keys = keySet();
+ Set<String> keys = keySet();
if (!(ctype.keySet().equals(keys)))
return false;
- Iterator it = keys.iterator();
- while (it.hasNext())
- {
- String key = (String) it.next();
- if (!(ctype.getType(key).equals(getType(key))))
- return false;
- }
+ for (String key : keys)
+ {
+ if (!(ctype.getType(key).equals(getType(key))))
+ return false;
+ }
return true;
}
@@ -203,7 +201,7 @@ public class CompositeType
*/
public String getDescription(String name)
{
- return (String) nameToDescription.get(name);
+ return nameToDescription.get(name);
}
/**
@@ -216,9 +214,9 @@ public class CompositeType
* @return the type, or <code>null</code> if the
* field doesn't exist.
*/
- public OpenType getType(String name)
+ public OpenType<?> getType(String name)
{
- return (OpenType) nameToType.get(name);
+ return nameToType.get(name);
}
/**
@@ -287,7 +285,7 @@ public class CompositeType
* @return a unmodifiable set containing the field
* name {@link java.lang.String}s.
*/
- public Set keySet()
+ public Set<String> keySet()
{
return Collections.unmodifiableSet(nameToDescription.keySet());
}
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
index 83e043640b4..22667aadf7d 100644
--- a/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
@@ -1,5 +1,5 @@
/* OpenMBeanAttributeInfoSupport.java -- Open typed info about an attribute.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -62,7 +62,7 @@ public class OpenMBeanAttributeInfoSupport
/**
* The open type of the attribute.
*/
- private OpenType openType;
+ private OpenType<?> openType;
/**
* The default value of the attribute (may be <code>null</code>).
@@ -72,17 +72,17 @@ public class OpenMBeanAttributeInfoSupport
/**
* The possible legal values of the attribute (may be <code>null</code>).
*/
- private Set legalValues;
+ private Set<?> legalValues;
/**
* The minimum value of the attribute (may be <code>null</code>).
*/
- private Comparable minValue;
+ private Comparable<Object> minValue;
/**
* The maximum value of the attribute (may be <code>null</code>).
*/
- private Comparable maxValue;
+ private Comparable<Object> maxValue;
/**
* The hash code of this instance.
@@ -112,7 +112,7 @@ public class OpenMBeanAttributeInfoSupport
* or the name or description are
* the empty string.
*/
- public OpenMBeanAttributeInfoSupport(String name, String desc, OpenType type,
+ public OpenMBeanAttributeInfoSupport(String name, String desc, OpenType<?> type,
boolean isReadable, boolean isWritable,
boolean isIs)
{
@@ -157,9 +157,9 @@ public class OpenMBeanAttributeInfoSupport
* open type or the open type is an instance
* of {@link ArrayType} or {@link TabularType}.
*/
- public OpenMBeanAttributeInfoSupport(String name, String desc, OpenType type,
- boolean isReadable, boolean isWritable,
- boolean isIs, Object defaultValue)
+ public <T> OpenMBeanAttributeInfoSupport(String name, String desc, OpenType<T> type,
+ boolean isReadable, boolean isWritable,
+ boolean isIs, T defaultValue)
throws OpenDataException
{
this(name, desc, type, isReadable, isWritable, isIs, defaultValue, null);
@@ -203,11 +203,11 @@ public class OpenMBeanAttributeInfoSupport
* the empty string.
* @throws OpenDataException if any condition in the list above is broken.
*/
- public OpenMBeanAttributeInfoSupport(String name, String desc, OpenType type,
- boolean isReadable, boolean isWritable,
- boolean isIs, Object defaultValue,
- Comparable minimumValue,
- Comparable maximumValue)
+ public <T> OpenMBeanAttributeInfoSupport(String name, String desc, OpenType<T> type,
+ boolean isReadable, boolean isWritable,
+ boolean isIs, T defaultValue,
+ Comparable<T> minimumValue,
+ Comparable<T> maximumValue)
throws OpenDataException
{
this(name, desc, type, isReadable, isWritable, isIs);
@@ -239,8 +239,8 @@ public class OpenMBeanAttributeInfoSupport
openType = type;
this.defaultValue = defaultValue;
- minValue = minimumValue;
- maxValue = maximumValue;
+ minValue = (Comparable<Object>) minimumValue;
+ maxValue = (Comparable<Object>) maximumValue;
}
/**
@@ -280,10 +280,10 @@ public class OpenMBeanAttributeInfoSupport
* the empty string.
* @throws OpenDataException if any condition in the list above is broken.
*/
- public OpenMBeanAttributeInfoSupport(String name, String desc, OpenType type,
- boolean isReadable, boolean isWritable,
- boolean isIs, Object defaultValue,
- Object[] legalValues)
+ public <T> OpenMBeanAttributeInfoSupport(String name, String desc, OpenType<T> type,
+ boolean isReadable, boolean isWritable,
+ boolean isIs, T defaultValue,
+ T[] legalValues)
throws OpenDataException
{
this(name, desc, type, isReadable, isWritable, isIs);
@@ -379,7 +379,7 @@ public class OpenMBeanAttributeInfoSupport
* @return a set of legal values, or <code>null</code> if no such
* set exists.
*/
- public Set getLegalValues()
+ public Set<?> getLegalValues()
{
return legalValues;
}
@@ -390,7 +390,7 @@ public class OpenMBeanAttributeInfoSupport
*
* @return the maximum value, or <code>null</code> if none exists.
*/
- public Comparable getMaxValue()
+ public Comparable<?> getMaxValue()
{
return maxValue;
}
@@ -401,7 +401,7 @@ public class OpenMBeanAttributeInfoSupport
*
* @return the minimum value, or <code>null</code> if none exists.
*/
- public Comparable getMinValue()
+ public Comparable<?> getMinValue()
{
return minValue;
}
@@ -412,7 +412,7 @@ public class OpenMBeanAttributeInfoSupport
*
* @return the open type of this attribute.
*/
- public OpenType getOpenType()
+ public OpenType<?> getOpenType()
{
return openType;
}
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfo.java b/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfo.java
index 8b61329d966..e835b8d131f 100644
--- a/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfo.java
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfo.java
@@ -109,7 +109,7 @@ public interface OpenMBeanOperationInfo
*
* @return the open type of the return value.
*/
- OpenType getReturnOpenType();
+ OpenType<?> getReturnOpenType();
/**
* Returns the return type of the operation, as the class
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfoSupport.java
index 07564897c2c..c01433de0fa 100644
--- a/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfoSupport.java
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfoSupport.java
@@ -1,5 +1,5 @@
/* OpenMBeanOperationInfoSupport.java -- Open typed info about an operation.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -61,7 +61,7 @@ public class OpenMBeanOperationInfoSupport
/**
* The open type representing the return value.
*/
- private OpenType returnOpenType;
+ private OpenType<?> returnOpenType;
/**
* The hash code of this instance.
@@ -108,7 +108,7 @@ public class OpenMBeanOperationInfoSupport
*/
public OpenMBeanOperationInfoSupport(String name, String desc,
OpenMBeanParameterInfo[] sig,
- OpenType type, int impact)
+ OpenType<?> type, int impact)
{
super(name, desc, (MBeanParameterInfo[]) sig,
type == null ? null : type.getClassName(), impact);
@@ -159,7 +159,7 @@ public class OpenMBeanOperationInfoSupport
*
* @return the open type of the return value.
*/
- public OpenType getReturnOpenType()
+ public OpenType<?> getReturnOpenType()
{
return returnOpenType;
}
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfo.java b/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfo.java
index 780e8ba1159..75d1baf941d 100644
--- a/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfo.java
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfo.java
@@ -93,7 +93,7 @@ public interface OpenMBeanParameterInfo
* @return a set of legal values, or <code>null</code> if no such
* set exists.
*/
- Set getLegalValues();
+ Set<?> getLegalValues();
/**
* Returns the maximum value of this parameter, or <code>null</code>
@@ -101,7 +101,7 @@ public interface OpenMBeanParameterInfo
*
* @return the maximum value, or <code>null</code> if none exists.
*/
- Comparable getMaxValue();
+ Comparable<?> getMaxValue();
/**
* Returns the minimum value of this parameter, or <code>null</code>
@@ -109,7 +109,7 @@ public interface OpenMBeanParameterInfo
*
* @return the minimum value, or <code>null</code> if none exists.
*/
- Comparable getMinValue();
+ Comparable<?> getMinValue();
/**
* Returns the name of this parameter.
@@ -124,7 +124,7 @@ public interface OpenMBeanParameterInfo
*
* @return the open type of this parameter.
*/
- OpenType getOpenType();
+ OpenType<?> getOpenType();
/**
* Returns true if this parameter has a default value.
diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java
index af3bda6c738..7fad2a13161 100644
--- a/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java
+++ b/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java
@@ -1,5 +1,5 @@
/* OpenMBeanParameterInfoSupport.java -- Open typed info about a parameter.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -63,7 +63,7 @@ public class OpenMBeanParameterInfoSupport
/**
* The open type of the parameter.
*/
- private OpenType openType;
+ private OpenType<?> openType;
/**
* The default value of the parameter (may be <code>null</code>).
@@ -73,17 +73,17 @@ public class OpenMBeanParameterInfoSupport
/**
* The possible legal values of the parameter (may be <code>null</code>).
*/
- private Set legalValues;
+ private Set<?> legalValues;
/**
* The minimum value of the parameter (may be <code>null</code>).
*/
- private Comparable minValue;
+ private Comparable<Object> minValue;
/**
* The maximum value of the parameter (may be <code>null</code>).
*/
- private Comparable maxValue;
+ private Comparable<Object> maxValue;
/**
* The hash code of this instance.
@@ -109,7 +109,7 @@ public class OpenMBeanParameterInfoSupport
* or the name or description are
* the empty string.
*/
- public OpenMBeanParameterInfoSupport(String name, String desc, OpenType type)
+ public OpenMBeanParameterInfoSupport(String name, String desc, OpenType<?> type)
{
super(name, type == null ? null : type.getClassName(), desc);
if (name == null)
@@ -149,8 +149,8 @@ public class OpenMBeanParameterInfoSupport
* open type or the open type is an instance
* of {@link ArrayType} or {@link TabularType}.
*/
- public OpenMBeanParameterInfoSupport(String name, String desc, OpenType type,
- Object defaultValue)
+ public <T> OpenMBeanParameterInfoSupport(String name, String desc, OpenType<T> type,
+ T defaultValue)
throws OpenDataException
{
this(name, desc, type, defaultValue, null);
@@ -190,9 +190,9 @@ public class OpenMBeanParameterInfoSupport
* the empty string.
* @throws OpenDataException if any condition in the list above is broken.
*/
- public OpenMBeanParameterInfoSupport(String name, String desc, OpenType type,
- Object defaultValue, Comparable minimumValue,
- Comparable maximumValue)
+ public <T> OpenMBeanParameterInfoSupport(String name, String desc, OpenType<T> type,
+ T defaultValue, Comparable<T> minimumValue,
+ Comparable<T> maximumValue)
throws OpenDataException
{
this(name, desc, type);
@@ -223,8 +223,8 @@ public class OpenMBeanParameterInfoSupport
"maximum.");
this.defaultValue = defaultValue;
- minValue = minimumValue;
- maxValue = maximumValue;
+ minValue = (Comparable<Object>) minimumValue;
+ maxValue = (Comparable<Object>) maximumValue;
}
/**
@@ -261,8 +261,8 @@ public class OpenMBeanParameterInfoSupport
* the empty string.
* @throws OpenDataException if any condition in the list above is broken.
*/
- public OpenMBeanParameterInfoSupport(String name, String desc, OpenType type,
- Object defaultValue, Object[] legalValues)
+ public <T> OpenMBeanParameterInfoSupport(String name, String desc, OpenType<T> type,
+ T defaultValue, T[] legalValues)
throws OpenDataException
{
this(name, desc, type);
@@ -351,7 +351,7 @@ public class OpenMBeanParameterInfoSupport
* @return a set of legal values, or <code>null</code> if no such
* set exists.
*/
- public Set getLegalValues()
+ public Set<?> getLegalValues()
{
return legalValues;
}
@@ -362,7 +362,7 @@ public class OpenMBeanParameterInfoSupport
*
* @return the maximum value, or <code>null</code> if none exists.
*/
- public Comparable getMaxValue()
+ public Comparable<?> getMaxValue()
{
return maxValue;
}
@@ -373,7 +373,7 @@ public class OpenMBeanParameterInfoSupport
*
* @return the minimum value, or <code>null</code> if none exists.
*/
- public Comparable getMinValue()
+ public Comparable<?> getMinValue()
{
return minValue;
}
@@ -384,7 +384,7 @@ public class OpenMBeanParameterInfoSupport
*
* @return the open type of this parameter.
*/
- public OpenType getOpenType()
+ public OpenType<?> getOpenType()
{
return openType;
}
diff --git a/libjava/classpath/javax/management/openmbean/OpenType.java b/libjava/classpath/javax/management/openmbean/OpenType.java
index 13c9e8a3e01..f3a97fef3f7 100644
--- a/libjava/classpath/javax/management/openmbean/OpenType.java
+++ b/libjava/classpath/javax/management/openmbean/OpenType.java
@@ -1,5 +1,5 @@
/* OpenType.java -- Superclass of all open types.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,6 +39,9 @@ package javax.management.openmbean;
import java.io.Serializable;
+import java.util.Arrays;
+import java.util.List;
+
/**
* The superclass of all open types, which describe the
* applicable data values for open MBeans. An open type
@@ -48,7 +51,7 @@ import java.io.Serializable;
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
-public abstract class OpenType
+public abstract class OpenType<T>
implements Serializable
{
@@ -76,7 +79,10 @@ public abstract class OpenType
* An array which defines the set of Java types which can be
* used as open types. Note that each type is also available
* in array form, possibly with multiple dimensions.
+ *
+ * @deprecated Use {@link ALLOWED_CLASSNAMES_LIST} instead.
*/
+ @Deprecated
public static final String[] ALLOWED_CLASSNAMES = {
"java.lang.Void",
"java.lang.Boolean",
@@ -97,6 +103,14 @@ public abstract class OpenType
};
/**
+ * A list which defines the set of Java types that may be
+ * used as open types. Note that each type is also available
+ * in array form, possibly with multiple dimensions.
+ */
+ public static final List<String> ALLOWED_CLASSNAMES_LIST =
+ Arrays.asList(ALLOWED_CLASSNAMES);
+
+ /**
* Constructs a new {@link OpenType} for the specified class
* with the given name and description. The name of the class
* must be taken from the list of {@link ALLOWED_CLASSNAMES}.
@@ -126,17 +140,20 @@ public abstract class OpenType
if (desc == null || desc.equals(""))
throw new IllegalArgumentException("The description can not " +
"be null or the empty string.");
- String testString;
- if (className.startsWith("["))
- testString = className.substring(className.indexOf("L") + 1);
- else
- testString = className;
- boolean openTypeFound = false;
- for (int a = 0; a < ALLOWED_CLASSNAMES.length; ++a)
- if (ALLOWED_CLASSNAMES[a].equals(testString))
- openTypeFound = true;
- if (!openTypeFound)
- throw new OpenDataException("The class name, " + testString +
+ Class<?> type;
+ try
+ {
+ type = Class.forName(className);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw (OpenDataException) new OpenDataException("The class name, " + className +
+ ", is unavailable.").initCause(e);
+ }
+ while (type.isArray())
+ type = type.getComponentType();
+ if (!(type.isPrimitive() || ALLOWED_CLASSNAMES_LIST.contains(type.getName())))
+ throw new OpenDataException("The class name, " + className +
", does not specify a valid open type.");
this.className = className;
typeName = name;
diff --git a/libjava/classpath/javax/management/openmbean/SimpleType.java b/libjava/classpath/javax/management/openmbean/SimpleType.java
index 39753f1c6ea..fb3b1bc28b7 100644
--- a/libjava/classpath/javax/management/openmbean/SimpleType.java
+++ b/libjava/classpath/javax/management/openmbean/SimpleType.java
@@ -1,5 +1,5 @@
/* SimpleType.java -- Open type descriptor for the base types.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,6 +40,13 @@ package javax.management.openmbean;
import java.io.InvalidObjectException;
import java.io.ObjectStreamException;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import java.util.Date;
+
+import javax.management.ObjectName;
+
/**
* The open type descriptor for data values that are members
* of one of the simple types (such as an integer or a string).
@@ -53,94 +60,94 @@ import java.io.ObjectStreamException;
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
-public final class SimpleType
- extends OpenType
+public final class SimpleType<T>
+ extends OpenType<T>
{
/**
* The {@link SimpleType} representation of
* <code>java.math.BigDecimal</code>.
*/
- public static final SimpleType BIGDECIMAL;
+ public static final SimpleType<BigDecimal> BIGDECIMAL;
/**
* The {@link SimpleType} representation of
* <code>java.math.BigInteger</code>.
*/
- public static final SimpleType BIGINTEGER;
+ public static final SimpleType<BigInteger> BIGINTEGER;
/**
* The {@link SimpleType} representation of
* <code>java.lang.Boolean</code>.
*/
- public static final SimpleType BOOLEAN;
+ public static final SimpleType<Boolean> BOOLEAN;
/**
* The {@link SimpleType} representation of
* <code>java.lang.Byte</code>.
*/
- public static final SimpleType BYTE;
+ public static final SimpleType<Byte> BYTE;
/**
* The {@link SimpleType} representation of
* <code>java.lang.Character</code>.
*/
- public static final SimpleType CHARACTER;
+ public static final SimpleType<Character> CHARACTER;
/**
* The {@link SimpleType} representation of
* <code>java.util.Date</code>.
*/
- public static final SimpleType DATE;
+ public static final SimpleType<Date> DATE;
/**
* The {@link SimpleType} representation of
* <code>java.lang.Double</code>.
*/
- public static final SimpleType DOUBLE;
+ public static final SimpleType<Double> DOUBLE;
/**
* The {@link SimpleType} representation of
* <code>java.lang.Float</code>.
*/
- public static final SimpleType FLOAT;
+ public static final SimpleType<Float> FLOAT;
/**
* The {@link SimpleType} representation of
* <code>java.lang.Integer</code>.
*/
- public static final SimpleType INTEGER;
+ public static final SimpleType<Integer> INTEGER;
/**
* The {@link SimpleType} representation of
* <code>java.lang.Long</code>.
*/
- public static final SimpleType LONG;
+ public static final SimpleType<Long> LONG;
/**
* The {@link SimpleType} representation of
* <code>javax.management.ObjectName</code>.
*/
- public static final SimpleType OBJECTNAME;
+ public static final SimpleType<ObjectName> OBJECTNAME;
/**
* The {@link SimpleType} representation of
* <code>java.lang.Short</code>.
*/
- public static final SimpleType SHORT;
+ public static final SimpleType<Short> SHORT;
/**
* The {@link SimpleType} representation of
* <code>java.lang.String</code>.
*/
- public static final SimpleType STRING;
+ public static final SimpleType<String> STRING;
/**
* The {@link SimpleType} representation of
* <code>java.lang.Void</code>.
*/
- public static final SimpleType VOID;
+ public static final SimpleType<Void> VOID;
/**
* Compatible with JDK 1.5
@@ -164,27 +171,28 @@ public final class SimpleType
{
try
{
- BIGDECIMAL = new SimpleType("java.math.BigDecimal");
- BIGINTEGER = new SimpleType("java.math.BigInteger");
- BOOLEAN = new SimpleType("java.lang.Boolean");
- BYTE = new SimpleType("java.lang.Byte");
- CHARACTER = new SimpleType("java.lang.Character");
- DATE = new SimpleType("java.util.Date");
- DOUBLE = new SimpleType("java.lang.Double");
- FLOAT = new SimpleType("java.lang.Float");
- INTEGER = new SimpleType("java.lang.Integer");
- LONG = new SimpleType("java.lang.Long");
- OBJECTNAME = new SimpleType("javax.management.ObjectName");
- SHORT = new SimpleType("java.lang.Short");
- STRING = new SimpleType("java.lang.String");
- VOID = new SimpleType("java.lang.Void");
+ BIGDECIMAL = new SimpleType<BigDecimal>("java.math.BigDecimal");
+ BIGINTEGER = new SimpleType<BigInteger>("java.math.BigInteger");
+ BOOLEAN = new SimpleType<Boolean>("java.lang.Boolean");
+ BYTE = new SimpleType<Byte>("java.lang.Byte");
+ CHARACTER = new SimpleType<Character>("java.lang.Character");
+ DATE = new SimpleType<Date>("java.util.Date");
+ DOUBLE = new SimpleType<Double>("java.lang.Double");
+ FLOAT = new SimpleType<Float>("java.lang.Float");
+ INTEGER = new SimpleType<Integer>("java.lang.Integer");
+ LONG = new SimpleType<Long>("java.lang.Long");
+ OBJECTNAME =
+ new SimpleType<ObjectName>("javax.management.ObjectName");
+ SHORT = new SimpleType<Short>("java.lang.Short");
+ STRING = new SimpleType<String>("java.lang.String");
+ VOID = new SimpleType<Void>("java.lang.Void");
}
catch (OpenDataException e)
{
/* In normal circumstances, this shouldn't be possible. */
throw new IllegalStateException("A invalid class name " +
"was passed to the SimpleType " +
- "constructor.");
+ "constructor.", e);
}
}
diff --git a/libjava/classpath/javax/management/openmbean/TabularData.java b/libjava/classpath/javax/management/openmbean/TabularData.java
index 7e57e0fd815..75ab00b7ed4 100644
--- a/libjava/classpath/javax/management/openmbean/TabularData.java
+++ b/libjava/classpath/javax/management/openmbean/TabularData.java
@@ -1,5 +1,5 @@
/* TabularData.java -- Tables of composite data structures.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -165,7 +165,7 @@ public interface TabularData
*
* @return a set containing the keys of this instance.
*/
- Set keySet();
+ Set<?> keySet();
/**
* Adds the specified {@link CompositeData} value to the
@@ -253,7 +253,7 @@ public interface TabularData
*
* @return the values of this instance.
*/
- Collection values();
+ Collection<?> values();
}
diff --git a/libjava/classpath/javax/management/openmbean/TabularDataSupport.java b/libjava/classpath/javax/management/openmbean/TabularDataSupport.java
index 9dc8a0e9727..1d340e86f59 100644
--- a/libjava/classpath/javax/management/openmbean/TabularDataSupport.java
+++ b/libjava/classpath/javax/management/openmbean/TabularDataSupport.java
@@ -1,5 +1,5 @@
/* TabularDataSupport.java -- Tables of composite data structures.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -55,7 +55,7 @@ import java.util.Set;
* @since 1.5
*/
public class TabularDataSupport
- implements TabularData, Serializable, Cloneable, Map
+ implements TabularData, Serializable, Cloneable, Map<Object,Object>
{
/**
@@ -68,7 +68,7 @@ public class TabularDataSupport
*
* @serial the map of rows to column values.
*/
- private Map dataMap;
+ private Map<Object,Object> dataMap;
/**
* The tabular type which represents this tabular data instance.
@@ -113,7 +113,7 @@ public class TabularDataSupport
if (type == null)
throw new IllegalArgumentException("The type may not be null.");
tabularType = type;
- dataMap = new HashMap(cap, lf);
+ dataMap = new HashMap<Object,Object>(cap, lf);
}
/**
@@ -279,7 +279,7 @@ public class TabularDataSupport
* @return the set view of all mapping entries
* @see java.util.Map.Entry
*/
- public Set entrySet()
+ public Set<Map.Entry<Object,Object>> entrySet()
{
return dataMap.entrySet();
}
@@ -413,7 +413,7 @@ public class TabularDataSupport
*
* @return the set view of all keys
*/
- public Set keySet()
+ public Set<Object> keySet()
{
return dataMap.keySet();
}
@@ -535,7 +535,7 @@ public class TabularDataSupport
* of one of the other
* specified values.
*/
- public void putAll(Map m)
+ public void putAll(Map<?,?> m)
{
if (m == null || m.size() == 0)
return;
@@ -643,7 +643,7 @@ public class TabularDataSupport
*
* @return the collection view of all values
*/
- public Collection values()
+ public Collection<Object> values()
{
return dataMap.values();
}
diff --git a/libjava/classpath/javax/management/openmbean/TabularType.java b/libjava/classpath/javax/management/openmbean/TabularType.java
index c38f5ea626e..9a0881e0f92 100644
--- a/libjava/classpath/javax/management/openmbean/TabularType.java
+++ b/libjava/classpath/javax/management/openmbean/TabularType.java
@@ -1,5 +1,5 @@
/* TabularType.java -- Type descriptor for TabularData instances.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -50,7 +50,7 @@ import java.util.List;
* @since 1.5
*/
public class TabularType
- extends OpenType
+ extends OpenType<TabularData>
{
/**
@@ -68,7 +68,7 @@ public class TabularType
* They are retained in the order given by the user, and is
* unmodifiable.
*/
- private List indexNames;
+ private List<String> indexNames;
/**
* The hash code of this instance.
@@ -167,7 +167,7 @@ public class TabularType
* @return an unmodifiable list of the index names used by this
* tabular data structure.
*/
- public List getIndexNames()
+ public List<String> getIndexNames()
{
return indexNames;
}