diff options
author | Andrew Haley <aph@redhat.com> | 2016-09-30 16:24:48 +0000 |
---|---|---|
committer | Andrew Haley <aph@gcc.gnu.org> | 2016-09-30 16:24:48 +0000 |
commit | 07b78716af6a9d7c9fd1e94d9baf94a52c873947 (patch) | |
tree | 3f22b3241c513ad168c8353805614ae1249410f4 /libjava/classpath/javax/management/openmbean | |
parent | eae993948bae8b788c53772bcb9217c063716f93 (diff) | |
download | gcc-07b78716af6a9d7c9fd1e94d9baf94a52c873947.zip gcc-07b78716af6a9d7c9fd1e94d9baf94a52c873947.tar.gz gcc-07b78716af6a9d7c9fd1e94d9baf94a52c873947.tar.bz2 |
Makefile.def: Remove libjava.
2016-09-30 Andrew Haley <aph@redhat.com>
* Makefile.def: Remove libjava.
* Makefile.tpl: Likewise.
* Makefile.in: Regenerate.
* configure.ac: Likewise.
* configure: Likewise.
* gcc/java: Remove.
* libjava: Likewise.
From-SVN: r240662
Diffstat (limited to 'libjava/classpath/javax/management/openmbean')
25 files changed, 0 insertions, 6214 deletions
diff --git a/libjava/classpath/javax/management/openmbean/ArrayType.java b/libjava/classpath/javax/management/openmbean/ArrayType.java deleted file mode 100644 index fc18870..0000000 --- a/libjava/classpath/javax/management/openmbean/ArrayType.java +++ /dev/null @@ -1,672 +0,0 @@ -/* ArrayType.java -- Open type descriptor for an array. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. - -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.Array; - -import java.util.HashMap; -import java.util.Map; - -/** - * The open type descriptor for arrays of open data values. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public class ArrayType<T> - extends OpenType<T> -{ - - /** - * Compatible with JDK 1.5 - */ - private static final long serialVersionUID = 720504429830309770L; - - /** - * The number of dimensions arrays of this type has. - */ - private int dimension; - - /** - * The element type of arrays of this type. - */ - private OpenType<?> elementType; - - /** - * True if this type represents a primitive array. - */ - private boolean primitiveArray; - - /** - * The hash code of this instance. - */ - private transient Integer hashCode; - - /** - * The <code>toString()</code> result of this instance. - */ - 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 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 final String getArrayClassName(OpenType<?> elementType, - int dim, - boolean primitive) - throws OpenDataException - { - 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(); - } - - /** - * <p> - * Constructs a new {@link ArrayType} instance for an array of the - * specified type with the supplied number of dimensions. 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 (i.e. the element type, preceded by n instances of - * '[' and an 'L', where n is the number of dimensions the array has). - * The description is based upon the template <code>n-dimension array - * of e</code>, where n is the number of dimensions of the array, and - * e is the element type. The class name of the actual elements is - * obtainable by calling {@link OpenType#getClassName()} on the result - * of {@link #getElementOpenType()}. - * </p> - * <p> - * As an example, the array type returned by - * <code>new ArrayType(6, SimpleType.INTEGER)</code> has the following - * values: - * </p> - * <table> - * <th><td>Attribute</td><td>Value</td></th> - * <tr><td>Class Name</td><td><code>[[[[[[Ljava.lang.Integer;</code> - * </td></tr> - * <tr><td>Type Name</td><td><code>[[[[[[Ljava.lang.Integer;</code> - * </td></tr> - * <tr><td>Description</td><td><code>6-dimension array of - * java.lang.Integer</code></td></tr> - * <tr><td>Element Type Class Name</td><td><code>java.lang.Integer</code> - * </td></tr> - * </table> - * <p> - * The dimensions of the array must be equal to or greater than 1. The - * element type must be an instance of {@link SimpleType}, - * {@link CompositeType} or {@link TabularType}. - * </p> - * - * @param dim the dimensions of the array. - * @param elementType the type of the elements of the array. - * @throws IllegalArgumentException if <code>dim</code> is less than 1. - * @throws OpenDataException if the element type is not an instance of either - * {@link SimpleType}, {@link CompositeType} - * or {@link TabularType}. - */ - public ArrayType(int dim, OpenType<?> elementType) - throws OpenDataException - { - 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 ArrayType)) - throw new OpenDataException("The element type must be a simple " + - "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; - } - - /** - * <p> - * Compares this array type with another object - * for equality. The objects are judged to be equal if: - * </p> - * <ul> - * <li><code>obj</code> is not null.</li> - * <li><code>obj</code> is an instance of - * {@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. - * @return true if the conditions above hold. - */ - public boolean equals(Object obj) - { - if (!(obj instanceof ArrayType)) - return false; - ArrayType<?> atype = (ArrayType<?>) obj; - return (atype.getDimension() == dimension && - 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 - */ - @SuppressWarnings("unchecked") - 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<E[]>(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 - */ - @SuppressWarnings("unchecked") - 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()); - try - { - arr = new ArrayType<T>(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<T>(1, arr); - --dim; - } - catch (OpenDataException e) - { - throw (Error) - new InternalError("Couldn't generate extra dimensions").initCause(e); - } - primCache.put(type, arr); - return arr; - } - - /** - * Returns the number of dimensions used by arrays - * of this type. - * - * @return the number of dimensions. - */ - public int getDimension() - { - return dimension; - } - - /** - * Returns the open type descriptor which describes - * the type of the elements of this array type. - * - * @return the type of the elements. - */ - public OpenType<?> getElementOpenType() - { - return elementType; - } - - /** - * <p> - * 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 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 - * is computed just once for each instance and reused - * throughout its life. - * </p> - * - * @return the hash code of this instance. - */ - public int hashCode() - { - if (hashCode == null) - 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 - * non-null, an array and one of the following two conditions - * holds: - * </p> - * <ul> - * <li>This {@link ArrayType} instance has a {@link SimpleType} - * as its element type. Thus, the object must have the same - * class name as that returned by {@link SimpleType#getClassName()} - * for this class.</li> - * <li>This {@link ArrayType} instance has a {@link CompositeType} - * or a {@link TabularType} as its element type. Thus, the object - * must be assignable to such an array, and have elements which - * are either null or valid values for the element type.</li> - * </ul> - * - * @param obj the object to test for membership. - * @return true if the object is a member of this type. - */ - public boolean isValue(Object obj) - { - if (obj == null) - return false; - Class<?> objClass = obj.getClass(); - if (!(objClass.isArray())) - return false; - if (elementType instanceof SimpleType) - return getClassName().equals(objClass.getName()); - Class<?> elementClass = null; - try - { - elementClass = Class.forName(getClassName()); - } - catch (ClassNotFoundException e) - { - throw new IllegalStateException("The array type's element " + - "class could not be found.", e); - } - if (!(elementClass.isAssignableFrom(objClass))) - return false; - for (int a = 0; a < Array.getLength(obj); ++a) - { - Object elem = Array.get(obj, a); - if (elem != null && - (!(elementType.isValue(elem)))) - return false; - } - return true; - } - - /** - * <p> - * Returns a textual representation of this instance. This - * is constructed using the class name - * (<code>javax.management.openmbean.ArrayType</code>) - * and each element of the instance which is relevant to - * the definition of {@link equals(java.lang.Object)} and - * {@link hashCode()} (i.e. the type name, the number of - * dimensions and the element type). - * </p> - * <p> - * As instances of this class are immutable, the return value - * is computed just once for each instance and reused - * throughout its life. - * </p> - * - * @return a @link{java.lang.String} instance representing - * the instance in textual form. - */ - public String toString() - { - if (string == null) - string = getClass().getName() - + "[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 deleted file mode 100644 index c3d2b2d..0000000 --- a/libjava/classpath/javax/management/openmbean/CompositeData.java +++ /dev/null @@ -1,153 +0,0 @@ -/* CompositeData.java -- A composite data structure. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. - -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.util.Collection; - -/** - * Provides an interface to a composite data structure, - * in order to aid interoperability. The composite data - * structure is represented by mapping field names to - * values. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public interface CompositeData -{ - - /** - * Returns true if this {@link CompositeData} instance contains - * the specified key. This method always returns false for - * an input key equal to <code>null</code> or the empty string. - * - * @param key the key to find in the structure. - * @return true if the key exists. - */ - boolean containsKey(String key); - - /** - * Returns true if this {@link CompositeData} instance has - * a value equal to that supplied. - * - * @param value the value to look for. - * @return true if the value exists. - */ - boolean containsValue(Object value); - - /** - * Compares the specified object with this object for equality. - * The object is judged equivalent if it is non-null, and also - * an instance of {@link CompositeData} with the same name-value - * mappings and types. The two compared instances may be - * equivalent even if they represent different implementations of - * {@link CompositeData}. - * - * @param obj the object to compare for equality. - * @return true if <code>obj</code> is equal to <code>this</code>. - */ - boolean equals(Object obj); - - /** - * Retrieves the value for the specified key. - * - * @param key the key whose value should be returned. - * @return the matching value. - * @throws IllegalArgumentException if the key is <code>null</code> - * or the empty string. - * @throws InvalidKeyException if the key does not exist. - */ - Object get(String key); - - /** - * Returns the appropriate value for each key in the given array, - * using the same ordering. - * - * @param keys the keys whose values should be returned. - * @return the matching values. - * @throws IllegalArgumentException if one of the keys is - * <code>null</code> or the - * empty string. - * @throws InvalidKeyException if one of the keys does not exist. - */ - Object[] getAll(String[] keys); - - /** - * Returns the composite type which corresponds to this instance - * of {@link CompositeData}. - * - * @return the composite type for this instance. - */ - CompositeType getCompositeType(); - - /** - * Returns the hash code of this instance. The hash code is - * computed as the sum of the hash codes of all the values plus - * the hash code of the composite type. As equality comparisons - * take place using this same information, this ensures that - * the property, <code>e1.equals(e2)</code> implies - * <code>e1.hashCode() == e2.hashCode(), holds for any pair - * of instances, <code>e1</code> and <code>e2</code>. - * - * @return the hash code of this {@link CompositeData}. - * @see Object#equals(Object) - */ - int hashCode(); - - /** - * Returns a textual representation of this instance. The - * exact format is left up to the implementation, but it - * should contain the name of the implementing class, - * the name of the type and a mapping of the form - * <code>key=value</code> for each pair of key and value. - * - * @return a {@link java.lang.String} representation of the - * object. - */ - String toString(); - - /** - * Returns a read-only collection of the values associated with - * this instance. The values are sorted using the lexicographic - * ordering of the corresponding keys. - * - * @return the values of this instance. - */ - Collection<?> values(); - -} diff --git a/libjava/classpath/javax/management/openmbean/CompositeDataInvocationHandler.java b/libjava/classpath/javax/management/openmbean/CompositeDataInvocationHandler.java deleted file mode 100644 index 4f10f6e..0000000 --- a/libjava/classpath/javax/management/openmbean/CompositeDataInvocationHandler.java +++ /dev/null @@ -1,190 +0,0 @@ -/* 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 deleted file mode 100644 index 2cc6f40..0000000 --- a/libjava/classpath/javax/management/openmbean/CompositeDataSupport.java +++ /dev/null @@ -1,345 +0,0 @@ -/* CompositeData.java -- A composite data structure implementation. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. - -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.io.Serializable; - -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.SortedMap; -import java.util.TreeMap; - -/** - * Provides an implementation of the {@link CompositeData} - * interface. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public class CompositeDataSupport - implements CompositeData, Serializable -{ - - /** - * Compatible with JDK 1.5 - */ - private static final long serialVersionUID = 8003518976613702244L; - - /** - * Mapping of field names to values. - * - * @serial the map of field names to values. - */ - private SortedMap<String, Object> contents; - - /** - * The composite type which represents this composite data instance. - * - * @serial the type information for this instance. - */ - private CompositeType compositeType; - - /** - * Constructs a new {@link CompositeDataSupport} instance with the - * specified type using field names and values from the supplied map. - * The keys of the map become the field names, while the values - * become the values of each respective field. This constructor simply - * calls the other constructor, with the two arrays formed using the - * keys and values of this map, respectively. Thus, the input parameters - * given should conform to the same requirements given there (i.e. no - * null values or empty strings). - * - * @param type the composite type of this composite data structure. - * @param items a mapping of field names to values. This should match - * the mappings given by the type (i.e. for each mapping - * in the type, there should be a corresponding field name - * with a value of the correct type). - * @throws IllegalArgumentException if the type, the map or any of the keys - * or values in the map are <code>null</code>, - * or if any key from the map is an empty - * string. - * @throws OpenDataException if a mismatch occurs between the map and the - * field name/type specification given by the - * {@link CompositeType} instance. This may be - * due to the two having a different size, a - * mismatch between keys or an incorrectly typed - * value. - * @throws ArrayStoreException if one of the keys is not a - * {@link java.lang.String} (thus calling a failure - * in converting the keys to an array of strings). - */ - public CompositeDataSupport(CompositeType type, Map<String, ?> items) - throws OpenDataException - { - this(type, - items.keySet().toArray(new String[items.size()]), - items.values().toArray()); - } - - /** - * Constructs a new {@link CompositeDataSupport} instance with the - * specified type using the supplied arrays of field names and - * values. Neither the type, the two arrays or any elements of the - * arrays may be <code>null</code>. The {@link java.lang.String}s - * within the <code>names</code> array must be non-empty. The - * arrays must match in size and order, as each element of the - * <code>names</code> array is matched against the corresponding - * value in the <code>values</code> array. Internally, the two are - * stored in a map, lexographically ordered using the field names. - * The data given should also conform to the description of the - * instance given by the {@link CompositeType} instance supplied. - * - * @param type the composite type of this composite data structure. - * @param names the field names. - * @param values the corresponding values of the fields. - * @throws IllegalArgumentException if the type, the arrays or any of the keys - * or values in the arrays are <code>null</code>, - * or if any key from <code>names</code> is - * an empty string. This also occurs if the - * arrays differ in length. - * @throws OpenDataException if a mismatch occurs between the arrays and the - * field name/type specification given by the - * {@link CompositeType} instance. This may be - * due to a differing number of field names, a - * mismatch between names or an incorrectly typed - * value. - */ - public CompositeDataSupport(CompositeType type, String[] names, Object[] values) - throws OpenDataException - { - if (type == null) - throw new IllegalArgumentException("The given composite type is null."); - compositeType = type; - if (names == null) - throw new IllegalArgumentException("The names array is null."); - if (values == null) - throw new IllegalArgumentException("The values array is null."); - if (names.length != values.length) - throw new IllegalArgumentException("The sizes of the arrays differ."); - Set<String> typeKeys = type.keySet(); - if (typeKeys.size() != names.length) - throw new OpenDataException("The number of field names does not match " + - "the type description."); - contents = new TreeMap<String, Object>(); - for (int a = 0; a < names.length; ++a) - { - if (names[a] == null) - throw new IllegalArgumentException("Element " + a + " of the names " + - "array is null."); - if (names[a].length() == 0) - throw new IllegalArgumentException("Element " + a + " of the names " + - "array is an empty string."); - if (values[a] == null) - throw new IllegalArgumentException("Element " + a + " of the values " + - "array is null."); - if (!(typeKeys.contains(names[a]))) - throw new OpenDataException("The name, " + names[a] + ", is not a " + - "field in the given type description."); - if (!(type.getType(names[a]).isValue(values[a]))) - throw new OpenDataException("The value, " + values[a] + ", is not a " + - "valid value for the " + names[a] + " field."); - contents.put(names[a], values[a]); - } - } - - /** - * Returns true if this {@link CompositeData} instance contains - * the specified key. This method always returns false for - * an input key equal to <code>null</code> or the empty string. - * - * @param key the key to find in the structure. - * @return true if the key exists. - */ - public boolean containsKey(String key) - { - if (key == null || key.length() == 0) - return false; - else - return contents.containsKey(key); - } - - /** - * Returns true if this {@link CompositeData} instance has - * a value equal to that supplied. - * - * @param value the value to look for. - * @return true if the value exists. - */ - public boolean containsValue(Object value) - { - return contents.containsValue(value); - } - - - /** - * Compares the specified object with this object for equality. - * The object is judged equivalent if it is non-null, and also - * an instance of {@link CompositeData} with the same name-value - * mappings and types. The two compared instances may be - * equivalent even if they represent different implementations of - * {@link CompositeData}. - * - * @param obj the object to compare for equality. - * @return true if <code>obj</code> is equal to <code>this</code>. - */ - public boolean equals(Object obj) - { - if (!(obj instanceof CompositeData)) - return false; - CompositeData data = (CompositeData) obj; - if (!(data.getCompositeType().equals(compositeType))) - return false; - for (String key : contents.keySet()) - { - if (!(data.containsKey(key))) - return false; - if (!(data.get(key).equals(contents.get(key)))) - return false; - } - return true; - } - - /** - * Retrieves the value for the specified key. - * - * @param key the key whose value should be returned. - * @return the matching value. - * @throws IllegalArgumentException if the key is <code>null</code> - * or the empty string. - * @throws InvalidKeyException if the key does not exist. - */ - public Object get(String key) - { - if (key == null) - throw new IllegalArgumentException("The supplied key is null."); - if (key.length() == 0) - throw new IllegalArgumentException("The supplied key is the empty string."); - if (!(contents.containsKey(key))) - throw new InvalidKeyException("The supplied key does not exist."); - return contents.get(key); - } - - /** - * Returns the appropriate value for each key in the given array, - * using the same ordering. - * - * @param keys the keys whose values should be returned. - * @return the matching values. - * @throws IllegalArgumentException if one of the keys is - * <code>null</code> or the - * empty string. - * @throws InvalidKeyException if one of the keys does not exist. - */ - public Object[] getAll(String[] keys) - { - Object[] values = new Object[keys.length]; - for (int a = 0; a < keys.length; ++a) - values[a] = get(keys[a]); - return values; - } - - - /** - * Returns the composite type which corresponds to this instance - * of {@link CompositeData}. - * - * @return the composite type for this instance. - */ - public CompositeType getCompositeType() - { - return compositeType; - } - - /** - * Returns the hash code of this instance. The hash code is - * computed as the sum of the hash codes of all the values plus - * the hash code of the composite type. As equality comparisons - * take place using this same information, this should ensure that - * the property, <code>e1.equals(e2)</code> implies - * <code>e1.hashCode() == e2.hashCode(), holds for any pair - * of instances, <code>e1</code> and <code>e2</code>. However, - * this relies on the other instance implementing the - * <code>hashCode</code> method correctly, if it is not an - * instance of {@link CompositeDataSupport}. - * - * @return the hash code of this {@link CompositeData}. - * @see Object#equals(Object) - */ - public int hashCode() - { - int code = compositeType.hashCode(); - for (Object o : contents.values()) - code += o.hashCode(); - return code; - } - - - /** - * Returns a textual representation of this instance. The - * exact format is left up to the implementation, but it - * should contain the name of the implementing class, - * the name of the type and a mapping of the form - * <code>key=value</code> for each pair of key and value. - * - * @return a {@link java.lang.String} representation of the - * object. - */ - public String toString() - { - return getClass().getName() + - "[compositeType=" + compositeType + - ",contents=" + contents + - "]"; - } - - /** - * Returns a read-only collection of the values associated with - * this instance. The values are sorted using the lexicographic - * ordering of the corresponding keys. - * - * @return the values of this instance. - */ - 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 deleted file mode 100644 index e36fed1..0000000 --- a/libjava/classpath/javax/management/openmbean/CompositeType.java +++ /dev/null @@ -1,320 +0,0 @@ -/* CompositeType.java -- Type descriptor for CompositeData instances. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. - -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.util.Collections; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - -/** - * The open type descriptor for instances of the - * {@link CompositeData} class. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public class CompositeType - extends OpenType<CompositeData> -{ - - /** - * Compatible with JDK 1.5 - */ - private static final long serialVersionUID = -5366242454346948798L; - - /** - * A map of item names to their descriptions. - */ - private TreeMap<String,String> nameToDescription; - - /** - * A map of item names to their types. - */ - private TreeMap<String,OpenType<?>> nameToType; - - /** - * The hash code of this instance. - */ - private transient Integer hashCode; - - /** - * The <code>toString()</code> result of this instance. - */ - private transient String string; - - /** - * <p> - * Constructs a new {@link CompositeType} instance for the given - * type name with the specified field names, descriptions and types. - * All parameters, and the elements of the array parameters, must be - * non-null and {@link java.lang.String} values must be something other - * than the empty string. The arrays must be non-empty, and be of - * equal size. - * </p> - * <p> - * The result of <code>CompositeData.class.getName()</code> is adopted - * as the class name (see {@link OpenType}) and changes to the array - * elements following construction of the {@link CompositeType} instance - * will <strong>not</strong> affect the values used by the instance. - * The field names are sorted in to ascending alphanumeric order internally, - * and so ordering can not be used to differentiate between two instances. - * </p> - * - * @param name the name of this composite type. - * @param desc a description of this composite type. - * @param names the names of each field within the composite type. - * @param descs the descriptions of each field within the composite type. - * @param types the types of each field within the composite type. - * @throws IllegalArgumentException if any validity constraint listed above - * is broken. - * @throws OpenDataException if duplicate item names are provided. Item names - * are case-sensitive, but whitespace is removed - * before comparison. - */ - public CompositeType(String name, String desc, String[] names, - String[] descs, OpenType<?>[] types) - throws OpenDataException - { - super(CompositeData.class.getName(), name, desc); - if (names.length == 0 - || names.length != descs.length - || names.length != types.length) - throw new IllegalArgumentException("Arrays must be non-empty " + - "and of equal size."); - nameToDescription = new TreeMap<String,String>(); - for (int a = 0; a < names.length; ++a) - { - if (names[a] == null) - throw new IllegalArgumentException("Name " + a + " is null."); - if (descs[a] == null) - throw new IllegalArgumentException("Description " + a + - " is null."); - String fieldName = names[a].trim(); - if (fieldName.length() == 0) - throw new IllegalArgumentException("Name " + a + " is " + - "the empty string."); - if (descs[a].length() == 0) - throw new IllegalArgumentException("Description " + a + " is " + - "the empty string."); - if (nameToDescription.containsKey(fieldName)) - throw new OpenDataException(fieldName + " appears more " + - "than once."); - nameToDescription.put(fieldName, descs[a]); - } - nameToType = new TreeMap<String,OpenType<?>>(); - for (int a = 0; a < names.length; ++a) - nameToType.put(names[a].trim(), types[a]); - } - - /** - * Returns true if this composite data type has a field - * with the given name. - * - * @param name the name of the field to check for. - * @return true if a field of that name exists. - */ - public boolean containsKey(String name) - { - return nameToDescription.containsKey(name); - } - - /** - * <p> - * Compares this composite data type with another object - * for equality. The objects are judged to be equal if: - * </p> - * <ul> - * <li><code>obj</code> is not null.</li> - * <li><code>obj</code> is an instance of - * {@link CompositeType}.</li> - * <li>The type names are equal.</li> - * <li>The fields and their types match.</li> - * </ul> - * - * @param obj the object to compare with. - * @return true if the conditions above hold. - */ - public boolean equals(Object obj) - { - if (!(obj instanceof CompositeType)) - return false; - CompositeType ctype = (CompositeType) obj; - if (!(ctype.getTypeName().equals(getTypeName()))) - return false; - Set<String> keys = keySet(); - if (!(ctype.keySet().equals(keys))) - return false; - for (String key : keys) - { - if (!(ctype.getType(key).equals(getType(key)))) - return false; - } - return true; - } - - /** - * Returns the description for the given field name, - * or <code>null</code> if the field name does not - * exist within this composite data type. - * - * @param name the name of the field whose description - * should be returned. - * @return the description, or <code>null</code> if the - * field doesn't exist. - */ - public String getDescription(String name) - { - return nameToDescription.get(name); - } - - /** - * Returns the type for the given field name, - * or <code>null</code> if the field name does not - * exist within this composite data type. - * - * @param name the name of the field whose type - * should be returned. - * @return the type, or <code>null</code> if the - * field doesn't exist. - */ - public OpenType<?> getType(String name) - { - return nameToType.get(name); - } - - /** - * <p> - * Returns the hash code of the composite data type. - * This is computed as the sum of the hash codes of - * each field name and its type, together with the hash - * code of the type name. 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 - * is computed just once for each instance and reused - * throughout its life. - * </p> - * - * @return the hash code of this instance. - */ - public int hashCode() - { - if (hashCode == null) - { - int elementTotal = 0; - for (Map.Entry<String,OpenType<?>> entry : nameToType.entrySet()) - { - elementTotal += (entry.getKey().hashCode() + - entry.getValue().hashCode()); - } - hashCode = Integer.valueOf(elementTotal - + getTypeName().hashCode()); - } - return hashCode.intValue(); - } - - /** - * Returns true if the specified object is a member of this - * composite type. The object is judged to be so if it is - * an instance of {@link CompositeData} with an equivalent - * type, according to the definition of - * {@link #equals(java.lang.Object)} for {@link CompositeType}. - * - * @param obj the object to test for membership. - * @return true if the object is a member of this type. - */ - public boolean isValue(Object obj) - { - if (obj instanceof CompositeData) - { - CompositeData data = (CompositeData) obj; - return equals(data.getCompositeType()); - } - return false; - } - - /** - * Returns an unmodifiable {@link java.util.Set}-based - * view of the field names that form part of this - * {@link CompositeType} instance. The names are stored - * in ascending alphanumeric order. - * - * @return a unmodifiable set containing the field - * name {@link java.lang.String}s. - */ - public Set<String> keySet() - { - return Collections.unmodifiableSet(nameToDescription.keySet()); - } - - /** - * <p> - * Returns a textual representation of this instance. This - * is constructed using the class name - * (<code>javax.management.openmbean.CompositeType</code>) - * and each element of the instance which is relevant to - * the definition of {@link equals(java.lang.Object)} and - * {@link hashCode()} (i.e. the type name, and the name - * and type of each field). - * </p> - * <p> - * As instances of this class are immutable, the return value - * is computed just once for each instance and reused - * throughout its life. - * </p> - * - * @return a @link{java.lang.String} instance representing - * the instance in textual form. - */ - public String toString() - { - if (string == null) - string = getClass().getName() - + "[name=" + getTypeName() - + ", fields=" + nameToType - + "]"; - return string; - } - -} diff --git a/libjava/classpath/javax/management/openmbean/InvalidKeyException.java b/libjava/classpath/javax/management/openmbean/InvalidKeyException.java deleted file mode 100644 index e9458ba..0000000 --- a/libjava/classpath/javax/management/openmbean/InvalidKeyException.java +++ /dev/null @@ -1,76 +0,0 @@ -/* InvalidKeyException.java -- Thrown by an invalid composite/tabular key. - Copyright (C) 2006 Free Software Foundation, Inc. - -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; - -/** - * Thrown when an invalid key (a field name or row index) is - * passed to a method of the {@link CompositeData} or - * {@link TabularData} classes. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public class InvalidKeyException - extends IllegalArgumentException -{ - - /** - * Compatible with JDK 1.5 - */ - private static final long serialVersionUID = 4224269443946322062L; - - /** - * Constructs a new <code>InvalidKeyException</code>. - */ - public InvalidKeyException() - { - super(); - } - - /** - * Constructs a new <code>InvalidKeyException</code> - * with the specified message. - * - * @param message the error message to give to the user. - */ - public InvalidKeyException(String message) - { - super(message); - } - -} diff --git a/libjava/classpath/javax/management/openmbean/InvalidOpenTypeException.java b/libjava/classpath/javax/management/openmbean/InvalidOpenTypeException.java deleted file mode 100644 index b4f49ba..0000000 --- a/libjava/classpath/javax/management/openmbean/InvalidOpenTypeException.java +++ /dev/null @@ -1,75 +0,0 @@ -/* InvalidOpenTypeException.java -- Thrown by an invalid open type. - Copyright (C) 2006 Free Software Foundation, Inc. - -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; - -/** - * Thrown when a open data value has an erroneous open - * type. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public class InvalidOpenTypeException - extends IllegalArgumentException -{ - - /** - * Compatible with JDK 1.5 - */ - private static final long serialVersionUID = -2837312755412327534L; - - /** - * Constructs a new <code>InvalidOpenTypeException</code>. - */ - public InvalidOpenTypeException() - { - super(); - } - - /** - * Constructs a new <code>InvalidOpenTypeException</code> - * with the specified message. - * - * @param message the error message to give to the user. - */ - public InvalidOpenTypeException(String message) - { - super(message); - } - -} diff --git a/libjava/classpath/javax/management/openmbean/KeyAlreadyExistsException.java b/libjava/classpath/javax/management/openmbean/KeyAlreadyExistsException.java deleted file mode 100644 index 69b22c4..0000000 --- a/libjava/classpath/javax/management/openmbean/KeyAlreadyExistsException.java +++ /dev/null @@ -1,76 +0,0 @@ -/* KeyAlreadyExistsException.java -- Thrown when a key clashes with another. - Copyright (C) 2006 Free Software Foundation, Inc. - -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; - -/** - * Thrown when a key (a field name or row index) is passed to a method - * of the {@link CompositeData} or {@link TabularData} classes and it - * is found to already be in use. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public class KeyAlreadyExistsException - extends IllegalArgumentException -{ - - /** - * Compatible with JDK 1.5 - */ - private static final long serialVersionUID = 1845183636745282866L; - - /** - * Constructs a new <code>KeyAlreadyExistsException</code>. - */ - public KeyAlreadyExistsException() - { - super(); - } - - /** - * Constructs a new <code>KeyAlreadyExistsException</code> - * with the specified message. - * - * @param message the error message to give to the user. - */ - public KeyAlreadyExistsException(String message) - { - super(message); - } - -} diff --git a/libjava/classpath/javax/management/openmbean/OpenDataException.java b/libjava/classpath/javax/management/openmbean/OpenDataException.java deleted file mode 100644 index 5e2a0b7..0000000 --- a/libjava/classpath/javax/management/openmbean/OpenDataException.java +++ /dev/null @@ -1,78 +0,0 @@ -/* OpenDataException.java -- Thrown by invalid open bean data. - Copyright (C) 2006 Free Software Foundation, Inc. - -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 javax.management.JMException; - -/** - * Thrown when an instance of one of the open types, open - * data objects or open metadata information objects could - * not be created due to invalid construction parameters. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public class OpenDataException - extends JMException -{ - - /** - * Compatible with JDK 1.5 - */ - private static final long serialVersionUID = 8346311255433349870L; - - /** - * Constructs a new <code>OpenDataException</code>. - */ - public OpenDataException() - { - super(); - } - - /** - * Constructs a new <code>OpenDataException</code> - * with the specified message. - * - * @param message the error message to give to the user. - */ - public OpenDataException(String message) - { - super(message); - } - -} diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfo.java b/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfo.java deleted file mode 100644 index d521306..0000000 --- a/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfo.java +++ /dev/null @@ -1,120 +0,0 @@ -/* OpenMBeanAttributeInfo.java -- Open typed info about an attribute. - Copyright (C) 2006 Free Software Foundation, Inc. - -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; - -/** - * Describes an attribute associated with an open management bean. - * This interface includes those methods specified by {@link - * javax.management.MBeanAttributeInfo}, so implementations should - * extend this class. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public interface OpenMBeanAttributeInfo - extends OpenMBeanParameterInfo -{ - - /** - * Compares this attribute with the supplied object. This returns - * true iff the object is an instance of {@link OpenMBeanAttributeInfo} - * with an equal name and open type, the same default, minimum, - * maximum and legal values and the same access properties - * ({@link #isIs()}, {@link #isReadable()}, {@link #isWritable()}). - * - * @param obj the object to compare. - * @return true if the object is a {@link OpenMBeanParameterInfo} - * instance, - * <code>name.equals(object.getName())</code>, - * <code>openType.equals(object.getOpenType())</code>, - * <code>defaultValue.equals(object.getDefaultValue())</code>, - * <code>minValue.equals(object.getMinValue())</code>, - * <code>maxValue.equals(object.getMaxValue())</code>, - * <code>legalValues.equals(object.getLegalValues())</code>, - * <code>is == object.isIs()</code>, - * <code>isRead == object.isReadable()</code>, - * and <code>isWrite == object.isWritable()</code>. - */ - boolean equals(Object obj); - - /** - * Returns the hashcode of the attribute information as the sum of - * the hashcodes of the name, open type, default value, maximum - * value, minimum value, the set of legal values and the access - * properties. - * - * @return the hashcode of the attribute information. - */ - int hashCode(); - - /** - * Returns true if the accessor method of this attribute - * is of the form <code>isXXX</code>. - * - * @return true if the accessor takes the form <code>isXXX</code>. - */ - boolean isIs(); - - /** - * Returns true if value of this attribute can be read. - * - * @return true if the value of the attribute can be read. - */ - boolean isReadable(); - - /** - * Returns true if the value of this attribute can be changed. - * - * @return true if the value of the attribute can be changed. - */ - boolean isWritable(); - - /** - * Returns a textual representation of this instance. This - * is constructed using the class name - * (<code>javax.management.openmbean.OpenMBeanAttributeInfo</code>) - * along with the name, open type, default, minimum, maximum - * and legal values of the parameter and the access permissions - * ({@link #isIs()}, {@link #isReadable()}, {@link #isWritable()}). - * - * @return a @link{java.lang.String} instance representing - * the instance in textual form. - */ - String toString(); - -} diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java deleted file mode 100644 index 098f72e..0000000 --- a/libjava/classpath/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java +++ /dev/null @@ -1,547 +0,0 @@ -/* OpenMBeanAttributeInfoSupport.java -- Open typed info about an attribute. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. - -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.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import javax.management.MBeanAttributeInfo; - -/** - * Describes an attribute of an open management bean. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public class OpenMBeanAttributeInfoSupport - extends MBeanAttributeInfo - implements OpenMBeanAttributeInfo -{ - - /** - * Compatible with JDK 1.5 - */ - private static final long serialVersionUID = -4867215622149721849L; - - /** - * The open type of the attribute. - */ - private OpenType<?> openType; - - /** - * The default value of the attribute (may be <code>null</code>). - */ - private Object defaultValue; - - /** - * The possible legal values of the attribute (may be <code>null</code>). - */ - private Set<?> legalValues; - - /** - * The minimum value of the attribute (may be <code>null</code>). - */ - private Comparable<?> minValue; - - /** - * The maximum value of the attribute (may be <code>null</code>). - */ - private Comparable<?> maxValue; - - /** - * The hash code of this instance. - */ - private transient Integer hashCode; - - /** - * The <code>toString()</code> result of this instance. - */ - private transient String string; - - /** - * Constructs a new {@link OpenMBeanAttributeInfo} using the - * specified name, description, open type and access properties. - * The name, description and open type may not be <code>null</code> - * and the name and description may not be equal to the empty - * string. - * - * @param name the name of the attribute. - * @param desc a description of the attribute. - * @param type the open type of the attribute. - * @param isReadable true if the attribute's value can be read. - * @param isWritable true if the attribute's value can be changed. - * @param isIs true if the attribute uses an accessor of the form isXXX. - * @throws IllegalArgumentException if the name, description or - * open type are <code>null</code> - * or the name or description are - * the empty string. - */ - public OpenMBeanAttributeInfoSupport(String name, String desc, OpenType<?> type, - boolean isReadable, boolean isWritable, - boolean isIs) - { - super(name, type == null ? null : type.getClassName(), desc, isReadable, - isWritable, isIs); - if (name == null) - throw new IllegalArgumentException("The name may not be null."); - if (desc == null) - throw new IllegalArgumentException("The description may not be null."); - if (type == null) - throw new IllegalArgumentException("The type may not be null."); - if (name.length() == 0) - throw new IllegalArgumentException("The name may not be the empty string."); - if (desc.length() == 0) - throw new IllegalArgumentException("The description may not be the " + - "empty string."); - } - - /** - * Constructs a new {@link OpenMBeanAttributeInfo} using the - * specified name, description, open type and default value. The - * name, description and open type cannot be <code>null</code> and - * the name and description may not be equal to the empty string. - * The default value may be <code>null</code>. If non-null, it must - * be a valid value of the given open type. Default values are not - * applicable to the open types, {@link ArrayType} and {@link - * TabularType}. - * - * @param name the name of the attribute. - * @param desc a description of the attribute. - * @param type the open type of the attribute. - * @param isReadable true if the attribute's value can be read. - * @param isWritable true if the attribute's value can be changed. - * @param isIs true if the attribute uses an accessor of the form isXXX. - * @param defaultValue the default value of the attribute. - * @throws IllegalArgumentException if the name, description or - * open type are <code>null</code> - * or the name or description are - * the empty string. - * @throws OpenDataException if <code>defaultValue<code> is non-null - * and is either not a value of the given - * open type or the open type is an instance - * of {@link ArrayType} or {@link TabularType}. - */ - 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); - } - - /** - * <p> - * Constructs a new {@link OpenMBeanAttributeInfo} using the - * specified name, description, open type, access properties, - * default, maximum and minimum values. The name, description - * and open type cannot be <code>null</code> and the name and - * description may not be equal to the empty string. The - * default, maximum and minimum values may be <code>null</code>. - * The following conditions apply when the attributes mentioned - * are non-null: - * </p> - * <ul> - * <li>The values must be valid values for the given open type.</li> - * <li>Default values are not applicable to the open types, {@link - * ArrayType} and {@link TabularType}.</li> - * <li>The minimum value must be smaller than or equal to the maximum value - * (literally, <code>minValue.compareTo(maxValue) <= 0</code>.</li> - * <li>The minimum value must be smaller than or equal to the default value - * (literally, <code>minValue.compareTo(defaultValue) <= 0</code>.</li> - * <li>The default value must be smaller than or equal to the maximum value - * (literally, <code>defaultValue.compareTo(maxValue) <= 0</code>.</li> - * </ul> - * - * @param name the name of the attribute. - * @param desc a description of the attribute. - * @param type the open type of the attribute. - * @param isReadable true if the attribute's value can be read. - * @param isWritable true if the attribute's value can be changed. - * @param isIs true if the attribute uses an accessor of the form isXXX. - * @param defaultValue the default value of the attribute, or <code>null</code>. - * @param minimumValue the minimum value of the attribute, or <code>null</code>. - * @param maximumValue the maximum value of the attribute, or <code>null</code>. - * @throws IllegalArgumentException if the name, description or - * open type are <code>null</code> - * or the name or description are - * the empty string. - * @throws OpenDataException if any condition in the list above is broken. - */ - @SuppressWarnings("unchecked") - 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); - if (defaultValue != null && !(type.isValue(defaultValue))) - throw new OpenDataException("The default value is not a member of the " + - "open type given."); - if (minimumValue != null && !(type.isValue(minimumValue))) - throw new OpenDataException("The minimum value is not a member of the " + - "open type given."); - if (maximumValue != null && !(type.isValue(maximumValue))) - throw new OpenDataException("The maximum value is not a member of the " + - "open type given."); - if (defaultValue != null && (type instanceof ArrayType || - type instanceof TabularType)) - throw new OpenDataException("Default values are not applicable for " + - "array or tabular types."); - if (minimumValue != null && maximumValue != null - && minimumValue.compareTo((T) maximumValue) > 0) - throw new OpenDataException("The minimum value is greater than the " + - "maximum."); - if (minimumValue != null && defaultValue != null - && minimumValue.compareTo(defaultValue) > 0) - throw new OpenDataException("The minimum value is greater than the " + - "default."); - if (defaultValue != null && maximumValue != null - && maximumValue.compareTo(defaultValue) < 0) - throw new OpenDataException("The default value is greater than the " + - "maximum."); - - openType = type; - this.defaultValue = defaultValue; - minValue = minimumValue; - maxValue = maximumValue; - } - - /** - * <p> - * Constructs a new {@link OpenMBeanAttributeInfo} using the - * specified name, description, open type, access properties, default - * value and set of legal values. The name, description and open type - * cannot be <code>null</code> and the name and description may not be - * equal to the empty string. The default, maximum and minimum values - * may be <code>null</code>. The following conditions apply when the - * attributes mentioned are non-null: - * </p> - * <ul> - * <li>The default value and each of the legal values must be a valid - * value for the given open type.</li> - * <li>Default and legal values are not applicable to the open types, {@link - * ArrayType} and {@link TabularType}.</li> - * <li>The default value is not in the set of legal values.</li> - * </ul> - * <p> - * The legal values are copied from the array into a unmodifiable set, - * so future modifications to the array have no effect. - * </p> - * - * @param name the name of the attribute. - * @param desc a description of the attribute. - * @param type the open type of the attribute. - * @param isReadable true if the attribute's value can be read. - * @param isWritable true if the attribute's value can be changed. - * @param isIs true if the attribute uses an accessor of the form isXXX. - * @param defaultValue the default value of the attribute, or <code>null</code>. - * @param legalValues the legal values of the attribute. May be - * <code>null</code> or an empty array. - * @throws IllegalArgumentException if the name, description or - * open type are <code>null</code> - * or the name or description are - * the empty string. - * @throws OpenDataException if any condition in the list above is broken. - */ - 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); - if (defaultValue != null && !(type.isValue(defaultValue))) - throw new OpenDataException("The default value is not a member of the " + - "open type given."); - if (defaultValue != null && (type instanceof ArrayType || - type instanceof TabularType)) - throw new OpenDataException("Default values are not applicable for " + - "array or tabular types."); - if (legalValues != null && (type instanceof ArrayType || - type instanceof TabularType)) - throw new OpenDataException("Legal values are not applicable for " + - "array or tabular types."); - if (legalValues != null && legalValues.length > 0) - { - Set<T> lv = new HashSet<T>(legalValues.length); - for (int a = 0; a < legalValues.length; ++a) - { - if (legalValues[a] != null && - !(type.isValue(legalValues[a]))) - throw new OpenDataException("The legal value, " - + legalValues[a] + - "is not a member of the " + - "open type given."); - lv.add(legalValues[a]); - } - if (defaultValue != null && !(lv.contains(defaultValue))) - throw new OpenDataException("The default value is not in the set " + - "of legal values."); - this.legalValues = Collections.unmodifiableSet(lv); - } - openType = type; - this.defaultValue = defaultValue; - } - - /** - * Compares this attribute with the supplied object. This returns - * true iff the object is an instance of {@link OpenMBeanAttributeInfo} - * with an equal name and open type and the same default, minimum, - * maximum and legal values and the same access properties. - * - * @param obj the object to compare. - * @return true if the object is a {@link OpenMBeanAttributeInfo} - * instance, - * <code>name.equals(object.getName())</code>, - * <code>openType.equals(object.getOpenType())</code>, - * <code>isRead == object.isReadable()</code>, - * <code>isWrite == object.isWritable()</code>, - * <code>isIs == object.isIs()</code>, - * <code>defaultValue.equals(object.getDefaultValue())</code>, - * <code>minValue.equals(object.getMinValue())</code>, - * <code>maxValue.equals(object.getMaxValue())</code>, - * and <code>legalValues.equals(object.getLegalValues())</code>. - */ - public boolean equals(Object obj) - { - if (!(obj instanceof OpenMBeanAttributeInfo)) - return false; - OpenMBeanAttributeInfo o = (OpenMBeanAttributeInfo) obj; - return getName().equals(o.getName()) && - openType.equals(o.getOpenType()) && - isReadable() == o.isReadable() && - isWritable() == o.isWritable() && - isIs() == o.isIs() && - (defaultValue == null ? o.getDefaultValue() == null : - defaultValue.equals(o.getDefaultValue())) && - (minValue == null ? o.getMinValue() == null : - minValue.equals(o.getMinValue())) && - (maxValue == null ? o.getMaxValue() == null : - maxValue.equals(o.getMaxValue())) && - (legalValues == null ? o.getLegalValues() == null : - legalValues.equals(o.getLegalValues())); - } - - /** - * Returns the default value of this attribute, or <code>null</code> - * if there is no default value. - * - * @return the default value of the attribute, or <code>null</code> - * if there is no default. - */ - public Object getDefaultValue() - { - return defaultValue; - } - - /** - * Returns a {@link java.util.Set} enumerating the legal values - * of this attribute, or <code>null</code> if no such limited - * set exists for this attribute. - * - * @return a set of legal values, or <code>null</code> if no such - * set exists. - */ - public Set<?> getLegalValues() - { - return legalValues; - } - - /** - * Returns the maximum value of this attribute, or <code>null</code> - * if there is no maximum. - * - * @return the maximum value, or <code>null</code> if none exists. - */ - public Comparable<?> getMaxValue() - { - return maxValue; - } - - /** - * Returns the minimum value of this attribute, or <code>null</code> - * if there is no minimum. - * - * @return the minimum value, or <code>null</code> if none exists. - */ - public Comparable<?> getMinValue() - { - return minValue; - } - - /** - * Returns the open type instance which represents the type of this - * attribute. - * - * @return the open type of this attribute. - */ - public OpenType<?> getOpenType() - { - return openType; - } - - /** - * Returns true if this attribute has a default value - * (i.e. the value is non-null). - * - * @return true if this attribute has a default. - */ - public boolean hasDefaultValue() - { - return defaultValue != null; - } - - /** - * <p> - * Returns the hashcode of the attribute information as the sum of - * the hashcodes of the name, open type, default value, maximum - * value, minimum value and the set of legal values. - * </p> - * <p> - * As instances of this class are immutable, the hash code - * is computed just once for each instance and reused - * throughout its life. - * </p> - * - * @return the hashcode of the attribute information. - */ - public int hashCode() - { - if (hashCode == null) - hashCode = Integer.valueOf(getName().hashCode() + - openType.hashCode() + - Boolean.valueOf(isReadable()).hashCode() + - (2 * - Boolean.valueOf(isWritable()).hashCode()) + - (4 * Boolean.valueOf(isIs()).hashCode()) + - (defaultValue == null ? 0 : - defaultValue.hashCode()) + - (minValue == null ? 0 : - minValue.hashCode()) + - (maxValue == null ? 0 : - maxValue.hashCode()) + - (legalValues == null ? 0 : - legalValues.hashCode())); - return hashCode.intValue(); - } - - /** - * Returns true if there is a set of legal values for this - * attribute (i.e. the value is non-null). - * - * @return true if a set of legal values exists for this - * attribute. - */ - public boolean hasLegalValues() - { - return legalValues != null; - } - - /** - * Returns true if there is a maximum value for this attribute - * (i.e. the value is non-null). - * - * @return true if a maximum value exists for this attribute. - */ - public boolean hasMaxValue() - { - return maxValue != null; - } - - /** - * Returns true if there is a minimum value for this attribute. - * (i.e. the value is non-null). - * - * @return true if a minimum value exists for this attribute. - */ - public boolean hasMinValue() - { - return minValue != null; - } - - /** - * Returns true if the specified object is a valid value for - * this attribute. - * - * @param obj the object to test. - * @return true if <code>obj</code> is a valid value for this - * attribute. - */ - public boolean isValue(Object obj) - { - return openType.isValue(obj); - } - - /** - * <p> - * Returns a textual representation of this instance. This - * is constructed using the class name - * (<code>javax.management.openmbean.OpenMBeanAttributeInfo</code>) - * along with the name, open type, access properties, default, - * minimum, maximum and legal values of the attribute. - * </p> - * <p> - * As instances of this class are immutable, the return value - * is computed just once for each instance and reused - * throughout its life. - * </p> - * - * @return a @link{java.lang.String} instance representing - * the instance in textual form. - */ - public String toString() - { - if (string == null) - string = getClass().getName() - + "[name=" + getName() - + ",openType=" + openType - + ",isReadable=" + isReadable() - + ",isWritable=" + isWritable() - + ",isIs=" + isIs() - + ",defaultValue=" + defaultValue - + ",minValue=" + minValue - + ",maxValue=" + maxValue - + ",legalValues=" + legalValues - + "]"; - return string; - } - -} diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanConstructorInfo.java b/libjava/classpath/javax/management/openmbean/OpenMBeanConstructorInfo.java deleted file mode 100644 index 5bccdb6..0000000 --- a/libjava/classpath/javax/management/openmbean/OpenMBeanConstructorInfo.java +++ /dev/null @@ -1,112 +0,0 @@ -/* OpenMBeanConstructorInfo.java -- Open typed info about a constructor. - Copyright (C) 2006 Free Software Foundation, Inc. - -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 javax.management.MBeanParameterInfo; - -/** - * Describes a constructor for an open management bean. - * This interface includes those methods specified by {@link - * javax.management.MBeanConstructorInfo}, so implementations should - * extend this class. The {@link #getSignature()} method should - * return an array containing instances of {@link OpenMBeanParameterInfo}. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public interface OpenMBeanConstructorInfo -{ - - /** - * Compares this attribute with the supplied object. This returns - * true iff the object is an instance of {@link OpenMBeanConstructorInfo} - * with an equal name and signature. - * - * @param obj the object to compare. - * @return true if the object is a {@link OpenMBeanParameterInfo} - * instance, - * <code>name.equals(object.getName())</code>, - * and <code>signature.equals(object.getSignature())</code>. - */ - boolean equals(Object obj); - - /** - * Returns a description of this constructor. - * - * @return a human-readable description. - */ - String getDescription(); - - /** - * Returns the name of this constructor. - * - * @return the name of the constructor. - */ - String getName(); - - /** - * Returns the constructor's signature, in the form of - * information on each parameter. Each parameter is - * described by an instance of {@link OpenMBeanParameterInfo}. - * - * @return an array of {@link OpenMBeanParameterInfo} objects, - * describing the constructor parameters. - */ - MBeanParameterInfo[] getSignature(); - - /** - * Returns the hashcode of the constructor information as the sum of - * the hashcodes of the name and signature (calculated by - * <code>java.util.Arrays.asList(signature).hashCode()</code>). - * - * @return the hashcode of the constructor information. - */ - int hashCode(); - - /** - * Returns a textual representation of this instance. This - * is constructed using the class name - * (<code>javax.management.openmbean.OpenMBeanConstructorInfo</code>) - * along with the name and signature. - * - * @return a @link{java.lang.String} instance representing - * the instance in textual form. - */ - String toString(); - -} diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanConstructorInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanConstructorInfoSupport.java deleted file mode 100644 index c187d5d..0000000 --- a/libjava/classpath/javax/management/openmbean/OpenMBeanConstructorInfoSupport.java +++ /dev/null @@ -1,174 +0,0 @@ -/* OpenMBeanConstructorInfoSupport.java -- Open typed info about an constructor. - Copyright (C) 2006 Free Software Foundation, Inc. - -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.util.Arrays; - -import javax.management.MBeanConstructorInfo; -import javax.management.MBeanParameterInfo; - -/** - * Describes a constructor for an open management bean. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public class OpenMBeanConstructorInfoSupport - extends MBeanConstructorInfo - implements OpenMBeanConstructorInfo -{ - - /** - * Compatible with JDK 1.5 - */ - private static final long serialVersionUID = -4400441579007477003L; - - /** - * The hash code of this instance. - */ - private transient Integer hashCode; - - /** - * The <code>toString()</code> result of this instance. - */ - private transient String string; - - /** - * Constructs a @link{OpenMBeanConstructorInfo} with the specified - * name, description and parameter information. A <code>null</code> - * value for the parameter information is the same as passing in - * an empty array. Neither the name nor the description may be - * null or equal to the empty string. A copy of the parameter array - * is taken, so later changes have no effect. - * - * @param name the name of the constructor. - * @param desc a description of the constructor. - * @param sig the signature of the constructor, as a series - * of {@link MBeanParameterInfo} objects, one for - * each parameter. - * @throws IllegalArgumentException if the name or description is - * either <code>null</code> - * or the empty string. - * @throws ArrayStoreException if the members of the signature array - * are not assignable to - * {@link javax.management.MBeanParameterInfo} - */ - public OpenMBeanConstructorInfoSupport(String name, String desc, - OpenMBeanParameterInfo[] sig) - { - super(name, desc, (MBeanParameterInfo[]) sig); - if (name == null) - throw new IllegalArgumentException("The name may not be null."); - if (desc == null) - throw new IllegalArgumentException("The description may not be null."); - if (name.length() == 0) - throw new IllegalArgumentException("The name may not be the empty string."); - if (desc.length() == 0) - throw new IllegalArgumentException("The description may not be the " + - "empty string."); - } - - /** - * Compares this attribute with the supplied object. This returns - * true iff the object is an instance of {@link OpenMBeanConstructorInfo} - * with an equal name and signature. - * - * @param obj the object to compare. - * @return true if the object is a {@link OpenMBeanParameterInfo} - * instance, - * <code>name.equals(object.getName())</code>, - * and <code>signature.equals(object.getSignature())</code>. - */ - public boolean equals(Object obj) - { - if (!(obj instanceof OpenMBeanConstructorInfo)) - return false; - OpenMBeanConstructorInfo o = (OpenMBeanConstructorInfo) obj; - return getName().equals(o.getName()) && - getSignature().equals(o.getSignature()); - } - - /** - * <p> - * Returns the hashcode of the constructor information as the sum of - * the hashcodes of the name and signature (calculated by - * <code>java.util.Arrays.asList(signature).hashCode()</code>). - * </p> - * <p> - * As instances of this class are immutable, the return value - * is computed just once for each instance and reused - * throughout its life. - * </p> - * - * @return the hashcode of the constructor information. - */ - public int hashCode() - { - if (hashCode == null) - hashCode = Integer.valueOf(getName().hashCode() + - Arrays.asList(getSignature()).hashCode()); - return hashCode.intValue(); - } - - /** - * <p> - * Returns a textual representation of this instance. This - * is constructed using the class name - * (<code>javax.management.openmbean.OpenMBeanConstructorInfo</code>) - * along with the name and signature. - * </p> - * <p> - * As instances of this class are immutable, the return value - * is computed just once for each instance and reused - * throughout its life. - * </p> - * - * @return a @link{java.lang.String} instance representing - * the instance in textual form. - */ - public String toString() - { - if (string == null) - string = getClass().getName() - + "[name=" + getName() - + ",signature=" + Arrays.toString(getSignature()) - + "]"; - return string; - } - -} diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanInfo.java b/libjava/classpath/javax/management/openmbean/OpenMBeanInfo.java deleted file mode 100644 index 98da260..0000000 --- a/libjava/classpath/javax/management/openmbean/OpenMBeanInfo.java +++ /dev/null @@ -1,154 +0,0 @@ -/* OpenMBeanInfo.java -- Open typed info about a management bean. - Copyright (C) 2006 Free Software Foundation, Inc. - -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 javax.management.MBeanAttributeInfo; -import javax.management.MBeanConstructorInfo; -import javax.management.MBeanNotificationInfo; -import javax.management.MBeanOperationInfo; - -/** - * Describes an open management bean. Open management beans are - * management beans where {@link - * javax.management.DynamicMBean#getMBeanInfo()} returns an - * implementation of this interface. This interface includes those - * methods specified by {@link javax.management.MBeanInfo}, - * so implementations should extend this class. Each method - * which returns an array of one of the <code>MBeanXXXInfo</code> - * classes should return an array containing instances - * of the equivalent open version (<code>OpenMBeanXXXInfo</code>). - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public interface OpenMBeanInfo -{ - - /** - * Compares this attribute with the supplied object. This returns - * true iff the object is an instance of {@link OpenMBeanInfo} - * with the same class name and equal instances of the info classes. - * - * @param obj the object to compare. - * @return true if the object is a {@link OpenMBeanInfo} - * instance, - * <code>className.equals(object.getClassName())</code> - * and each info class has an equal in the other object. - */ - boolean equals(Object obj); - - /** - * Returns descriptions of each of the attributes provided by this - * management bean. The elements should be implementations of the - * {@link OpenMBeanAttributeInfo} class. - * - * @return an array of {@link OpenMBeanAttributeInfo} objects, - * representing the attributes emitted by this - * management bean. - */ - MBeanAttributeInfo[] getAttributes(); - - /** - * Returns the class name of the management bean. - * - * @return the bean's class name. - */ - String getClassName(); - - /** - * Returns descriptions of each of the constructors provided by this - * management bean. The elements should be implementations of the - * {@link OpenMBeanConstructorInfo} class. - * - * @return an array of {@link OpenMBeanConstructorInfo} objects, - * representing the constructors emitted by this - * management bean. - */ - MBeanConstructorInfo[] getConstructors(); - - /** - * Returns a description of this operation. - * - * @return a human-readable description. - */ - String getDescription(); - - /** - * Returns descriptions of each of the notifications provided by this - * management bean. The elements should be implementations of the - * {@link OpenMBeanNotificationInfo} class. - * - * @return an array of {@link OpenMBeanNotificationInfo} objects, - * representing the notifications emitted by this - * management bean. - */ - MBeanNotificationInfo[] getNotifications(); - - /** - * Returns descriptions of each of the operations provided by this - * management bean. The elements should be implementations of the - * {@link OpenMBeanOperationInfo} class. - * - * @return an array of {@link OpenMBeanOperationInfo} objects, - * representing the operations emitted by this - * management bean. - */ - MBeanOperationInfo[] getOperations(); - - /** - * Returns the hashcode of the bean information as the sum of the - * hashcodes of the class name and each array (calculated using - * java.util.HashSet(<code>java.util.Arrays.asList(signature)).hashCode()</code>). - * - * @return the hashcode of the bean information. - */ - int hashCode(); - - /** - * Returns a textual representation of this instance. This - * is constructed using the class name - * (<code>javax.management.openmbean.OpenMBeanInfo</code>) - * along with the class name and textual representations - * of each array. - * - * @return a @link{java.lang.String} instance representing - * the instance in textual form. - */ - String toString(); - -} diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanInfoSupport.java deleted file mode 100644 index c335d75..0000000 --- a/libjava/classpath/javax/management/openmbean/OpenMBeanInfoSupport.java +++ /dev/null @@ -1,191 +0,0 @@ -/* OpenMBeanInfoSupport.java -- Open typed info about a bean. - Copyright (C) 2006 Free Software Foundation, Inc. - -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.util.Arrays; -import java.util.HashSet; - -import javax.management.MBeanInfo; -import javax.management.MBeanAttributeInfo; -import javax.management.MBeanConstructorInfo; -import javax.management.MBeanNotificationInfo; -import javax.management.MBeanOperationInfo; - -/** - * Describes an open management bean. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public class OpenMBeanInfoSupport - extends MBeanInfo - implements OpenMBeanInfo -{ - - /** - * Compatible with JDK 1.5 - */ - private static final long serialVersionUID = 4349395935420511492L; - - /** - * The hash code of this instance. - */ - private transient Integer hashCode; - - /** - * The <code>toString()</code> result of this instance. - */ - private transient String string; - - /** - * Constructs a new {@link OpenMBeanInfo} using the supplied - * class name and description with the given attributes, - * operations, constructors and notifications. The class - * name does not have to actually specify a valid class that - * can be loaded by the MBean server or class loader; it merely - * has to be a syntactically correct class name. Any of the - * arrays may be <code>null</code>; this will be treated as if - * an empty array was supplied. A copy of the arrays is - * taken, so later changes have no effect. - * - * @param name the name of the class this instance describes. - * @param desc a description of the bean. - * @param attribs the attribute descriptions for the bean, - * or <code>null</code>. - * @param cons the constructor descriptions for the bean, - * or <code>null</code>. - * @param ops the operation descriptions for the bean, - * or <code>null</code>. - * @param notifs the notification descriptions for the bean, - * or <code>null</code>. - * @throws ArrayStoreException if a members of an array - * is not assignable to the equivalent - * <code>MBeanXXXInfo</code> class. - */ - public OpenMBeanInfoSupport(String name, String desc, - OpenMBeanAttributeInfo[] attribs, - OpenMBeanConstructorInfo[] cons, - OpenMBeanOperationInfo[] ops, - MBeanNotificationInfo[] notifs) - { - super(name, desc, (MBeanAttributeInfo[]) attribs, - (MBeanConstructorInfo[]) cons, - (MBeanOperationInfo[]) ops, - notifs); - } - - /** - * Compares this attribute with the supplied object. This returns - * true iff the object is an instance of {@link OpenMBeanInfo} - * with the same class name and equal instances of the info classes. - * - * @param obj the object to compare. - * @return true if the object is a {@link OpenMBeanInfo} - * instance, - * <code>className.equals(object.getClassName())</code> - * and each info class has an equal in the other object. - */ - public boolean equals(Object obj) - { - if (!(obj instanceof OpenMBeanInfo)) - return false; - OpenMBeanInfo o = (OpenMBeanInfo) obj; - return getClassName().equals(o.getClassName()) && - getAttributes().equals(o.getAttributes()) && - getConstructors().equals(o.getConstructors()) && - getNotifications().equals(o.getNotifications()) && - getOperations().equals(o.getOperations()); - } - - /** - * <p> - * Returns the hashcode of the bean information as the sum of the - * hashcodes of the class name and each array (calculated using - * java.util.HashSet(<code>java.util.Arrays.asList(signature)).hashCode()</code>). - * </p> - * <p> - * As instances of this class are immutable, the return value - * is computed just once for each instance and reused - * throughout its life. - * </p> - * - * @return the hashcode of the bean information. - */ - public int hashCode() - { - if (hashCode == null) - hashCode = - Integer.valueOf(getClassName().hashCode() + - new HashSet<MBeanAttributeInfo>(Arrays.asList(getAttributes())).hashCode() + - new HashSet<MBeanConstructorInfo>(Arrays.asList(getConstructors())).hashCode() + - new HashSet<MBeanNotificationInfo>(Arrays.asList(getNotifications())).hashCode() + - new HashSet<MBeanOperationInfo>(Arrays.asList(getOperations())).hashCode()); - return hashCode.intValue(); - } - - /** - * <p> - * Returns a textual representation of this instance. This - * is constructed using the class name - * (<code>javax.management.openmbean.OpenMBeanInfo</code>) - * along with the class name and textual representations - * of each array. - * </p> - * <p> - * As instances of this class are immutable, the return value - * is computed just once for each instance and reused - * throughout its life. - * </p> - * - * @return a @link{java.lang.String} instance representing - * the instance in textual form. - */ - public String toString() - { - if (string == null) - string = getClass().getName() - + "[className=" + getClassName() - + ",attributes=" + Arrays.toString(getAttributes()) - + ",constructors=" + Arrays.toString(getConstructors()) - + ",notifications=" + Arrays.toString(getNotifications()) - + ",operations=" + Arrays.toString(getOperations()) - + "]"; - return string; - } - -} diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfo.java b/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfo.java deleted file mode 100644 index 3b5bf92..0000000 --- a/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfo.java +++ /dev/null @@ -1,154 +0,0 @@ -/* OpenMBeanOperationInfo.java -- Open typed info about a operation. - Copyright (C) 2006 Free Software Foundation, Inc. - -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 javax.management.MBeanParameterInfo; - -/** - * Describes a operation for an open management bean. - * This interface includes those methods specified by {@link - * javax.management.MBeanOperationInfo}, so implementations should - * extend this class. The {@link #getSignature()} method should - * return an array containing instances of {@link OpenMBeanParameterInfo}. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public interface OpenMBeanOperationInfo -{ - - /** - * Compares this attribute with the supplied object. This returns - * true iff the object is an instance of {@link OpenMBeanOperationInfo} - * with an equal name, signature, open return type and impact. - * - * @param obj the object to compare. - * @return true if the object is a {@link OpenMBeanParameterInfo} - * instance, - * <code>name.equals(object.getName())</code>, - * <code>signature.equals(object.getSignature())</code>, - * <code>returnOpenType.equals(object.getReturnOpenType())</code>, - * and <code>impact == object.getImpact()</code>. - */ - boolean equals(Object obj); - - /** - * Returns a description of this operation. - * - * @return a human-readable description. - */ - String getDescription(); - - /** - * <p> - * Returns the impact of performing this operation. - * The value is equal to one of the following: - * </p> - * <ol> - * <li>{@link javax.management.MBeanOperationInfo#INFO} - * — the method just returns - * information (akin to an accessor).</li> - * <li>{@link javax.management.MBeanOperationInfo#ACTION} - * the method just alters the state of the bean, without - * returning a value (akin to a mutator).</li> - * <li>{@link javax.management.MBeanOperationInfo#ACTION_INFO} - * the method both makes state changes and returns a value.</li> - * <li>{@link javax.management.MBeanOperationInfo#UNKNOWN} - * the behaviour of the operation is unknown.</li> - * </ol> - * - * @return the impact of performing the operation. - */ - int getImpact(); - - /** - * Returns the name of this operation. - * - * @return the name of the operation. - */ - String getName(); - - /** - * Returns the open type instance which represents the type of the - * return value. - * - * @return the open type of the return value. - */ - OpenType<?> getReturnOpenType(); - - /** - * Returns the return type of the operation, as the class - * name. This should be identical to - * <code>getReturnOpenType.getClassName()</code>. - * - * @return the return type. - */ - String getReturnType(); - - /** - * Returns the operation's signature, in the form of - * information on each parameter. Each parameter is - * described by an instance of {@link OpenMBeanParameterInfo}. - * - * @return an array of {@link OpenMBeanParameterInfo} objects, - * describing the operation parameters. - */ - MBeanParameterInfo[] getSignature(); - - /** - * Returns the hashcode of the operation information as the sum of - * the hashcodes of the name, open return type, impact and signature - * (calculated by - * <code>java.util.Arrays.asList(signature).hashCode()</code>). - * - * @return the hashcode of the operation information. - */ - int hashCode(); - - /** - * Returns a textual representation of this instance. This - * is constructed using the class name - * (<code>javax.management.openmbean.OpenMBeanOperationInfo</code>) - * along with the name, signature, open return type and impact. - * - * @return a @link{java.lang.String} instance representing - * the instance in textual form. - */ - String toString(); - -} diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfoSupport.java deleted file mode 100644 index 992df34..0000000 --- a/libjava/classpath/javax/management/openmbean/OpenMBeanOperationInfoSupport.java +++ /dev/null @@ -1,240 +0,0 @@ -/* OpenMBeanOperationInfoSupport.java -- Open typed info about an operation. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. - -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.util.Arrays; - -import javax.management.MBeanOperationInfo; -import javax.management.MBeanParameterInfo; - -/** - * Describes a operation for an open management bean. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public class OpenMBeanOperationInfoSupport - extends MBeanOperationInfo - implements OpenMBeanOperationInfo -{ - - /** - * Compatible with JDK 1.5 - */ - private static final long serialVersionUID = 4996859732565369366L; - - /** - * The open type representing the return value. - */ - private OpenType<?> returnOpenType; - - /** - * The hash code of this instance. - */ - private transient Integer hashCode; - - /** - * The <code>toString()</code> result of this instance. - */ - private transient String string; - - /** - * Constructs a @link{OpenMBeanOperationInfo} with the specified name, - * description, parameter information, open return type and impact. A - * <code>null</code> value for the parameter information is the same - * as passing in an empty array. A copy of the parameter array is - * taken, so later changes have no effect. The name and the - * description may not be equal to the empty string, and neither - * the name, description nor the open return type may be - * <code>null</code>. The value of <code>impact</code> must be - * one of the four valid values - * ({@link javax.management.MBeanOperationInfo#INFO}, - * {@link javax.management.MBeanOperationInfo#ACTION}, - * {@link javax.management.MBeanOperationInfo#ACTION_INFO} and - * {@link javax.management.MBeanOperationInfo#UNKNOWN}). - * - * - * @param name the name of the constructor. - * @param desc a description of the attribute. - * @param sig the signature of the method, as a series - * of {@link MBeanParameterInfo} objects, one for - * each parameter. - * @param type the open return type of the method. - * @param impact the impact of performing the operation. - * @throws IllegalArgumentException if the name, description or - * open return type is <code>null</code>, - * the name or description are equal to - * the empty string, or the impact factor - * is not one of the values enumerated - * above. - * @throws ArrayStoreException if the members of the signature array - * are not assignable to - * {@link javax.management.MBeanParameterInfo} - */ - public OpenMBeanOperationInfoSupport(String name, String desc, - OpenMBeanParameterInfo[] sig, - OpenType<?> type, int impact) - { - super(name, desc, (MBeanParameterInfo[]) sig, - type == null ? null : type.getClassName(), impact); - if (name == null) - throw new IllegalArgumentException("The name may not be null."); - if (desc == null) - throw new IllegalArgumentException("The description may not be null."); - if (type == null) - throw new IllegalArgumentException("The type may not be null."); - if (name.length() == 0) - throw new IllegalArgumentException("The name may not be the empty string."); - if (desc.length() == 0) - throw new IllegalArgumentException("The description may not be the " + - "empty string."); - if (impact != ACTION && impact != INFO && - impact != ACTION_INFO && impact != UNKNOWN) - throw new IllegalArgumentException("The impact factor is an invalid value."); - returnOpenType = type; - } - - /** - * Compares this attribute with the supplied object. This returns - * true iff the object is an instance of {@link OpenMBeanOperationInfo} - * with an equal name, signature, open return type and impact. - * - * @param obj the object to compare. - * @return true if the object is a {@link OpenMBeanParameterInfo} - * instance, - * <code>name.equals(object.getName())</code>, - * <code>signature.equals(object.getSignature())</code>, - * <code>returnOpenType.equals(object.getReturnOpenType())</code>, - * and <code>impact == object.getImpact()</code>. - */ - public boolean equals(Object obj) - { - if (!(obj instanceof OpenMBeanOperationInfo)) - return false; - OpenMBeanOperationInfo o = (OpenMBeanOperationInfo) obj; - return getName().equals(o.getName()) && - getSignature().equals(o.getSignature()) && - returnOpenType.equals(o.getReturnOpenType()) && - getImpact() == o.getImpact(); - } - - /** - * Returns the open type instance which represents the type of the - * return value. - * - * @return the open type of the return value. - */ - public OpenType<?> getReturnOpenType() - { - return returnOpenType; - } - - /** - * <p> - * Returns the hashcode of the operation information as the sum of - * the hashcodes of the name, open return type, impact and signature - * (calculated by - * <code>java.util.Arrays.asList(signature).hashCode()</code>). - * </p> - * <p> - * As instances of this class are immutable, the return value - * is computed just once for each instance and reused - * throughout its life. - * </p> - * - * @return the hashcode of the operation information. - */ - public int hashCode() - { - if (hashCode == null) - hashCode = Integer.valueOf(getName().hashCode() + - returnOpenType.hashCode() + - Integer.valueOf(getImpact()).hashCode() + - Arrays.asList(getSignature()).hashCode()); - return hashCode.intValue(); - } - - /** - * <p> - * Returns a textual representation of this instance. This - * is constructed using the class name - * (<code>javax.management.openmbean.OpenMBeanOperationInfo</code>) - * along with the name, signature, open return type and impact. - * </p> - * <p> - * As instances of this class are immutable, the return value - * is computed just once for each instance and reused - * throughout its life. - * </p> - * - * @return a @link{java.lang.String} instance representing - * the instance in textual form. - */ - public String toString() - { - if (string == null) - { - String impactString; - switch (getImpact()) - { - case INFO: - impactString = "INFO"; - break; - case ACTION: - impactString = "ACTION"; - break; - case ACTION_INFO: - impactString = "ACTION_INFO"; - break; - case UNKNOWN: - impactString = "UNKNOWN"; - break; - default: - impactString = "ERRONEOUS VALUE"; - } - string = getClass().getName() - + "[name=" + getName() - + ",signature=" + Arrays.toString(getSignature()) - + ",returnOpenType=" + returnOpenType - + ",impact=" + impactString - + "]"; - } - return string; - } - -} diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfo.java b/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfo.java deleted file mode 100644 index 0869a68..0000000 --- a/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfo.java +++ /dev/null @@ -1,190 +0,0 @@ -/* OpenMBeanParameterInfo.java -- Open typed info about a parameter. - Copyright (C) 2006 Free Software Foundation, Inc. - -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.util.Set; - -/** - * Describes the parameters of a constructor or operation associated - * with an open management bean. This interface includes those methods - * specified by {@link javax.management.MBeanParameterInfo}, so - * implementations should extend this class. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public interface OpenMBeanParameterInfo -{ - - /** - * Compares this parameter with the supplied object. This returns - * true iff the object is an instance of {@link OpenMBeanParameterInfo} - * with an equal name and open type and the same default, minimum, - * maximum and legal values. - * - * @param obj the object to compare. - * @return true if the object is a {@link OpenMBeanParameterInfo} - * instance, - * <code>name.equals(object.getName())</code>, - * <code>openType.equals(object.getOpenType())</code>, - * <code>defaultValue.equals(object.getDefaultValue())</code>, - * <code>minValue.equals(object.getMinValue())</code>, - * <code>maxValue.equals(object.getMaxValue())</code>, - * and <code>legalValues.equals(object.getLegalValues())</code>. - */ - boolean equals(Object obj); - - /** - * Returns the default value of this parameter, or <code>null</code> - * if there is no default value. - * - * @return the default value of the parameter, or <code>null</code> - * if there is no default. - */ - Object getDefaultValue(); - - /** - * Returns a description of this parameter. - * - * @return a human-readable description. - */ - String getDescription(); - - /** - * Returns a {@link java.util.Set} enumerating the legal values - * of this parameter, or <code>null</code> if no such limited - * set exists for this parameter. - * - * @return a set of legal values, or <code>null</code> if no such - * set exists. - */ - Set<?> getLegalValues(); - - /** - * Returns the maximum value of this parameter, or <code>null</code> - * if there is no maximum. - * - * @return the maximum value, or <code>null</code> if none exists. - */ - Comparable<?> getMaxValue(); - - /** - * Returns the minimum value of this parameter, or <code>null</code> - * if there is no minimum. - * - * @return the minimum value, or <code>null</code> if none exists. - */ - Comparable<?> getMinValue(); - - /** - * Returns the name of this parameter. - * - * @return the name of the parameter. - */ - String getName(); - - /** - * Returns the open type instance which represents the type of this - * parameter. - * - * @return the open type of this parameter. - */ - OpenType<?> getOpenType(); - - /** - * Returns true if this parameter has a default value. - * - * @return true if this parameter has a default. - */ - boolean hasDefaultValue(); - - /** - * Returns the hashcode of the parameter information as the sum of - * the hashcodes of the name, open type, default value, maximum - * value, minimum value and the set of legal values. - * - * @return the hashcode of the parameter information. - */ - int hashCode(); - - /** - * Returns true if there is a set of legal values for this - * parameter. - * - * @return true if a set of legal values exists for this - * parameter. - */ - boolean hasLegalValues(); - - /** - * Returns true if there is a maximum value for this parameter. - * - * @return true if a maximum value exists for this parameter. - */ - boolean hasMaxValue(); - - /** - * Returns true if there is a minimum value for this parameter. - * - * @return true if a minimum value exists for this parameter. - */ - boolean hasMinValue(); - - /** - * Returns true if the specified object is a valid value for - * this parameter. - * - * @param obj the object to test. - * @return true if <code>obj</code> is a valid value for this - * parameter. - */ - boolean isValue(Object obj); - - /** - * Returns a textual representation of this instance. This - * is constructed using the class name - * (<code>javax.management.openmbean.OpenMBeanParameterInfo</code>) - * along with the name, open type, default, minimum, maximum - * and legal values of the parameter. - * - * @return a @link{java.lang.String} instance representing - * the instance in textual form. - */ - String toString(); - -} diff --git a/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java b/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java deleted file mode 100644 index 78ad1c5..0000000 --- a/libjava/classpath/javax/management/openmbean/OpenMBeanParameterInfoSupport.java +++ /dev/null @@ -1,512 +0,0 @@ -/* OpenMBeanParameterInfoSupport.java -- Open typed info about a parameter. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. - -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.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import javax.management.MBeanParameterInfo; - -/** - * Describes the parameters of a constructor or operation associated - * with an open management bean. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public class OpenMBeanParameterInfoSupport - extends MBeanParameterInfo - implements OpenMBeanParameterInfo -{ - - /** - * Compatible with JDK 1.5 - */ - private static final long serialVersionUID = -7235016873758443122L; - - /** - * The open type of the parameter. - */ - private OpenType<?> openType; - - /** - * The default value of the parameter (may be <code>null</code>). - */ - private Object defaultValue; - - /** - * The possible legal values of the parameter (may be <code>null</code>). - */ - private Set<?> legalValues; - - /** - * The minimum value of the parameter (may be <code>null</code>). - */ - private Comparable<?> minValue; - - /** - * The maximum value of the parameter (may be <code>null</code>). - */ - private Comparable<?> maxValue; - - /** - * The hash code of this instance. - */ - private transient Integer hashCode; - - /** - * The <code>toString()</code> result of this instance. - */ - private transient String string; - - /** - * Constructs a new {@link OpenMBeanParameterInfo} using the specified - * name, description and open type. None of these values may be - * <code>null</code> and the name and description may not be equal - * to the empty string. - * - * @param name the name of the parameter. - * @param desc a description of the parameter. - * @param type the open type of the parameter. - * @throws IllegalArgumentException if the name, description or - * open type are <code>null</code> - * or the name or description are - * the empty string. - */ - public OpenMBeanParameterInfoSupport(String name, String desc, OpenType<?> type) - { - super(name, type == null ? null : type.getClassName(), desc); - if (name == null) - throw new IllegalArgumentException("The name may not be null."); - if (desc == null) - throw new IllegalArgumentException("The description may not be null."); - if (type == null) - throw new IllegalArgumentException("The type may not be null."); - if (name.length() == 0) - throw new IllegalArgumentException("The name may not be the empty string."); - if (desc.length() == 0) - throw new IllegalArgumentException("The description may not be the " + - "empty string."); - openType = type; - } - - /** - * Constructs a new {@link OpenMBeanParameterInfo} using the - * specified name, description, open type and default value. The - * name, description and open type cannot be <code>null</code> and - * the name and description may not be equal to the empty string. - * The default value may be <code>null</code>. If non-null, it must - * be a valid value of the given open type. Default values are not - * applicable to the open types, {@link ArrayType} and {@link - * TabularType}. - * - * @param name the name of the parameter. - * @param desc a description of the parameter. - * @param type the open type of the parameter. - * @param defaultValue the default value of the parameter. - * @throws IllegalArgumentException if the name, description or - * open type are <code>null</code> - * or the name or description are - * the empty string. - * @throws OpenDataException if <code>defaultValue<code> is non-null - * and is either not a value of the given - * open type or the open type is an instance - * of {@link ArrayType} or {@link TabularType}. - */ - public <T> OpenMBeanParameterInfoSupport(String name, String desc, OpenType<T> type, - T defaultValue) - throws OpenDataException - { - this(name, desc, type, defaultValue, null); - } - - /** - * <p> - * Constructs a new {@link OpenMBeanParameterInfo} using the - * specified name, description, open type, default, maximum and - * minimum values. The name, description and open type cannot be - * <code>null</code> and the name and description may not be equal - * to the empty string. The default, maximum and minimum values may - * be <code>null</code>. The following conditions apply when the - * parameters mentioned are non-null: - * </p> - * <ul> - * <li>The values must be valid values for the given open type.</li> - * <li>Default values are not applicable to the open types, {@link - * ArrayType} and {@link TabularType}.</li> - * <li>The minimum value must be smaller than or equal to the maximum value - * (literally, <code>minValue.compareTo(maxValue) <= 0</code>.</li> - * <li>The minimum value must be smaller than or equal to the default value - * (literally, <code>minValue.compareTo(defaultValue) <= 0</code>.</li> - * <li>The default value must be smaller than or equal to the maximum value - * (literally, <code>defaultValue.compareTo(maxValue) <= 0</code>.</li> - * </ul> - * - * @param name the name of the parameter. - * @param desc a description of the parameter. - * @param type the open type of the parameter. - * @param defaultValue the default value of the parameter, or <code>null</code>. - * @param minimumValue the minimum value of the parameter, or <code>null</code>. - * @param maximumValue the maximum value of the parameter, or <code>null</code>. - * @throws IllegalArgumentException if the name, description or - * open type are <code>null</code> - * or the name or description are - * the empty string. - * @throws OpenDataException if any condition in the list above is broken. - */ - @SuppressWarnings("unchecked") - public <T> OpenMBeanParameterInfoSupport(String name, String desc, OpenType<T> type, - T defaultValue, Comparable<T> minimumValue, - Comparable<T> maximumValue) - throws OpenDataException - { - this(name, desc, type); - if (defaultValue != null && !(type.isValue(defaultValue))) - throw new OpenDataException("The default value is not a member of the " + - "open type given."); - if (minimumValue != null && !(type.isValue(minimumValue))) - throw new OpenDataException("The minimum value is not a member of the " + - "open type given."); - if (maximumValue != null && !(type.isValue(maximumValue))) - throw new OpenDataException("The maximum value is not a member of the " + - "open type given."); - if (defaultValue != null && (type instanceof ArrayType || - type instanceof TabularType)) - throw new OpenDataException("Default values are not applicable for " + - "array or tabular types."); - if (minimumValue != null && maximumValue != null - && minimumValue.compareTo((T) maximumValue) > 0) - throw new OpenDataException("The minimum value is greater than the " + - "maximum."); - if (minimumValue != null && defaultValue != null - && minimumValue.compareTo(defaultValue) > 0) - throw new OpenDataException("The minimum value is greater than the " + - "default."); - if (defaultValue != null && maximumValue != null - && maximumValue.compareTo(defaultValue) < 0) - throw new OpenDataException("The default value is greater than the " + - "maximum."); - - this.defaultValue = defaultValue; - minValue = minimumValue; - maxValue = maximumValue; - } - - /** - * <p> - * Constructs a new {@link OpenMBeanParameterInfo} using the - * specified name, description, open type, default value and - * set of legal values. The name, description and open type cannot be - * <code>null</code> and the name and description may not be equal - * to the empty string. The default, maximum and minimum values may - * be <code>null</code>. The following conditions apply when the - * parameters mentioned are non-null: - * </p> - * <ul> - * <li>The default value and each of the legal values must be a valid - * value for the given open type.</li> - * <li>Default and legal values are not applicable to the open types, {@link - * ArrayType} and {@link TabularType}.</li> - * <li>The default value is not in the set of legal values.</li> - * </ul> - * <p> - * The legal values are copied from the array into a unmodifiable set, - * so future modifications to the array have no effect. - * </p> - * - * @param name the name of the parameter. - * @param desc a description of the parameter. - * @param type the open type of the parameter. - * @param defaultValue the default value of the parameter, or <code>null</code>. - * @param legalValues the legal values of the parameter. May be - * <code>null</code> or an empty array. - * @throws IllegalArgumentException if the name, description or - * open type are <code>null</code> - * or the name or description are - * the empty string. - * @throws OpenDataException if any condition in the list above is broken. - */ - public <T> OpenMBeanParameterInfoSupport(String name, String desc, OpenType<T> type, - T defaultValue, T[] legalValues) - throws OpenDataException - { - this(name, desc, type); - if (defaultValue != null && !(type.isValue(defaultValue))) - throw new OpenDataException("The default value is not a member of the " + - "open type given."); - if (defaultValue != null && (type instanceof ArrayType || - type instanceof TabularType)) - throw new OpenDataException("Default values are not applicable for " + - "array or tabular types."); - if (legalValues != null && (type instanceof ArrayType || - type instanceof TabularType)) - throw new OpenDataException("Legal values are not applicable for " + - "array or tabular types."); - if (legalValues != null && legalValues.length > 0) - { - Set<T> lv = new HashSet<T>(legalValues.length); - for (int a = 0; a < legalValues.length; ++a) - { - if (legalValues[a] != null && - !(type.isValue(legalValues[a]))) - throw new OpenDataException("The legal value, " - + legalValues[a] + - "is not a member of the " + - "open type given."); - lv.add(legalValues[a]); - } - if (defaultValue != null && !(lv.contains(defaultValue))) - throw new OpenDataException("The default value is not in the set " + - "of legal values."); - this.legalValues = Collections.unmodifiableSet(lv); - } - this.defaultValue = defaultValue; - } - - /** - * Compares this parameter with the supplied object. This returns - * true iff the object is an instance of {@link OpenMBeanParameterInfo} - * with an equal name and open type and the same default, minimum, - * maximum and legal values. - * - * @param obj the object to compare. - * @return true if the object is a {@link OpenMBeanParameterInfo} - * instance, - * <code>name.equals(object.getName())</code>, - * <code>openType.equals(object.getOpenType())</code>, - * <code>defaultValue.equals(object.getDefaultValue())</code>, - * <code>minValue.equals(object.getMinValue())</code>, - * <code>maxValue.equals(object.getMaxValue())</code>, - * and <code>legalValues.equals(object.getLegalValues())</code>. - */ - public boolean equals(Object obj) - { - if (!(obj instanceof OpenMBeanParameterInfo)) - return false; - OpenMBeanParameterInfo o = (OpenMBeanParameterInfo) obj; - return getName().equals(o.getName()) && - openType.equals(o.getOpenType()) && - (defaultValue == null ? o.getDefaultValue() == null : - defaultValue.equals(o.getDefaultValue())) && - (minValue == null ? o.getMinValue() == null : - minValue.equals(o.getMinValue())) && - (maxValue == null ? o.getMaxValue() == null : - maxValue.equals(o.getMaxValue())) && - (legalValues == null ? o.getLegalValues() == null : - legalValues.equals(o.getLegalValues())); - } - - /** - * Returns the default value of this parameter, or <code>null</code> - * if there is no default value. - * - * @return the default value of the parameter, or <code>null</code> - * if there is no default. - */ - public Object getDefaultValue() - { - return defaultValue; - } - - /** - * Returns a {@link java.util.Set} enumerating the legal values - * of this parameter, or <code>null</code> if no such limited - * set exists for this parameter. - * - * @return a set of legal values, or <code>null</code> if no such - * set exists. - */ - public Set<?> getLegalValues() - { - return legalValues; - } - - /** - * Returns the maximum value of this parameter, or <code>null</code> - * if there is no maximum. - * - * @return the maximum value, or <code>null</code> if none exists. - */ - public Comparable<?> getMaxValue() - { - return maxValue; - } - - /** - * Returns the minimum value of this parameter, or <code>null</code> - * if there is no minimum. - * - * @return the minimum value, or <code>null</code> if none exists. - */ - public Comparable<?> getMinValue() - { - return minValue; - } - - /** - * Returns the open type instance which represents the type of this - * parameter. - * - * @return the open type of this parameter. - */ - public OpenType<?> getOpenType() - { - return openType; - } - - /** - * Returns true if this parameter has a default value - * (i.e. the value is non-null). - * - * @return true if this parameter has a default. - */ - public boolean hasDefaultValue() - { - return defaultValue != null; - } - - /** - * <p> - * Returns the hashcode of the parameter information as the sum of - * the hashcodes of the name, open type, default value, maximum - * value, minimum value and the set of legal values. - * </p> - * <p> - * As instances of this class are immutable, the hash code - * is computed just once for each instance and reused - * throughout its life. - * </p> - * - * @return the hashcode of the parameter information. - */ - public int hashCode() - { - if (hashCode == null) - hashCode = Integer.valueOf(getName().hashCode() + - openType.hashCode() + - (defaultValue == null ? 0 : - defaultValue.hashCode()) + - (minValue == null ? 0 : - minValue.hashCode()) + - (maxValue == null ? 0 : - maxValue.hashCode()) + - (legalValues == null ? 0 : - legalValues.hashCode())); - return hashCode.intValue(); - } - - /** - * Returns true if there is a set of legal values for this - * parameter (i.e. the value is non-null). - * - * @return true if a set of legal values exists for this - * parameter. - */ - public boolean hasLegalValues() - { - return legalValues != null; - } - - /** - * Returns true if there is a maximum value for this parameter - * (i.e. the value is non-null). - * - * @return true if a maximum value exists for this parameter. - */ - public boolean hasMaxValue() - { - return maxValue != null; - } - - /** - * Returns true if there is a minimum value for this parameter. - * (i.e. the value is non-null). - * - * @return true if a minimum value exists for this parameter. - */ - public boolean hasMinValue() - { - return minValue != null; - } - - /** - * Returns true if the specified object is a valid value for - * this parameter. - * - * @param obj the object to test. - * @return true if <code>obj</code> is a valid value for this - * parameter. - */ - public boolean isValue(Object obj) - { - return openType.isValue(obj); - } - - /** - * <p> - * Returns a textual representation of this instance. This - * is constructed using the class name - * (<code>javax.management.openmbean.OpenMBeanParameterInfo</code>) - * along with the name, open type, default, minimum, maximum - * and legal values of the parameter. - * </p> - * <p> - * As instances of this class are immutable, the return value - * is computed just once for each instance and reused - * throughout its life. - * </p> - * - * @return a @link{java.lang.String} instance representing - * the instance in textual form. - */ - public String toString() - { - if (string == null) - string = getClass().getName() - + "[name=" + getName() - + ",openType=" + openType - + ",defaultValue=" + defaultValue - + ",minValue=" + minValue - + ",maxValue=" + maxValue - + ",legalValues=" + legalValues - + "]"; - return string; - } - -} diff --git a/libjava/classpath/javax/management/openmbean/OpenType.java b/libjava/classpath/javax/management/openmbean/OpenType.java deleted file mode 100644 index d8abc7c..0000000 --- a/libjava/classpath/javax/management/openmbean/OpenType.java +++ /dev/null @@ -1,247 +0,0 @@ -/* OpenType.java -- Superclass of all open types. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. - -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.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 - * is defined by its name and description, and the name - * of the Java class it maps to. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public abstract class OpenType<T> - implements Serializable -{ - - /** - * Compatible with JDK 1.5 - */ - private static final long serialVersionUID = -9195195325186646468L; - - /** - * The name of the Java class this type represents. - */ - private String className; - - /** - * The name of this type. - */ - private String typeName; - - /** - * A description of this type. - */ - private String description; - - /** - * 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", - "java.lang.Character", - "java.lang.Byte", - "java.lang.Short", - "java.lang.Integer", - "java.lang.Long", - "java.lang.Float", - "java.lang.Double", - "java.lang.String", - "java.math.BigDecimal", - "java.math.BigInteger", - "java.util.Date", - "javax.management.ObjectName", - CompositeData.class.getName(), - TabularData.class.getName() - }; - - /** - * 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}. - * Arrays are implictly included in this, and follow the usual - * syntax of {@link java.lang.Class#getName()} with the name - * preceded by n instances of '[' (where n is the number of - * dimensions) and an L. The name and description can not be - * <code>null</code> or the empty string. - * - * @param className the name of the Java class this type - * represents. - * @param name the name of the type. - * @param desc the description of the type. - * @throws IllegalArgumentException if either of <code>name</code> - * or <code>desc</code> are - * <code>null</code> or the empty - * string. - * @throws OpenDataException if the class name does not reference - * a listed class (from @{link ALLOWED_CLASSNAMES}) - */ - protected OpenType(String className, String name, String desc) - throws OpenDataException - { - if (name == null || name.equals("")) - throw new IllegalArgumentException("The name can not be null " + - "or the empty string."); - if (desc == null || desc.equals("")) - throw new IllegalArgumentException("The description can not " + - "be null or the empty string."); - 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; - description = desc; - } - - /** - * Performs an equality test on this object and the one specified. - * - * @param obj the object to test against this one. - * @return true if the two objects are equivalent. - * @see java.lang.Object#hashCode() - */ - public abstract boolean equals(Object obj); - - /** - * Returns the name of the Java class this type represents. This must - * be one of the {@link ALLOWED_CLASSNAMES} or an array of one of them. - * The specification of arrays follows the standard set by - * {@link java.lang.Class#getName()} i.e. the name is the class name - * preceded by n instances of '[' and an 'L', where n is number of - * dimensions used by the array. - * - * @return the class name. - */ - public String getClassName() - { - return className; - } - - /** - * Returns a description of this open type. - * - * @return the description. - */ - public String getDescription() - { - return description; - } - - /** - * Returns the name of this open type. - * - * @return the type name. - */ - public String getTypeName() - { - return typeName; - } - - /** - * Returns a hash code for this open type. The hash code - * should be consistent with the {@link equals()} method. - * Thus, it should continue to return the same value while - * the values used by the {@link equals()} method remain - * the same, and should return different hash codes for - * objects which are judged to be different using the - * {@link equals()} method. - * - * @return the hash code of this instance. - */ - public abstract int hashCode(); - - /** - * Returns true if this open type represents an array type. - * - * @return true if this open type represents an array type. - */ - public boolean isArray() - { - return className.startsWith("["); - } - - /** - * Returns true if the specified object is a member of this - * type. - * - * @param obj the object to test for membership. - * @return true if the object is a member of this type. - */ - public abstract boolean isValue(Object obj); - - /** - * Returns a textual representation of this type. - * - * @return a {@link java.lang.String} representation of this - * type. - */ - public abstract String toString(); - -} diff --git a/libjava/classpath/javax/management/openmbean/SimpleType.java b/libjava/classpath/javax/management/openmbean/SimpleType.java deleted file mode 100644 index 81b991b..0000000 --- a/libjava/classpath/javax/management/openmbean/SimpleType.java +++ /dev/null @@ -1,350 +0,0 @@ -/* SimpleType.java -- Open type descriptor for the base types. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. - -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.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). - * The other open types ({@link ArrayType}, {@link CompositeType}, - * {@link TabularType}) are constructed from one or more of these - * types. The simple types are formed from a small subset of - * basic Java types. As a result, the valid instances of this - * class are predefined, and no constructor is given for creating - * new instances. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public final class SimpleType<T> - extends OpenType<T> -{ - - /** - * The {@link SimpleType} representation of - * <code>java.math.BigDecimal</code>. - */ - public static final SimpleType<BigDecimal> BIGDECIMAL; - - /** - * The {@link SimpleType} representation of - * <code>java.math.BigInteger</code>. - */ - public static final SimpleType<BigInteger> BIGINTEGER; - - /** - * The {@link SimpleType} representation of - * <code>java.lang.Boolean</code>. - */ - public static final SimpleType<Boolean> BOOLEAN; - - /** - * The {@link SimpleType} representation of - * <code>java.lang.Byte</code>. - */ - public static final SimpleType<Byte> BYTE; - - /** - * The {@link SimpleType} representation of - * <code>java.lang.Character</code>. - */ - public static final SimpleType<Character> CHARACTER; - - /** - * The {@link SimpleType} representation of - * <code>java.util.Date</code>. - */ - public static final SimpleType<Date> DATE; - - /** - * The {@link SimpleType} representation of - * <code>java.lang.Double</code>. - */ - public static final SimpleType<Double> DOUBLE; - - /** - * The {@link SimpleType} representation of - * <code>java.lang.Float</code>. - */ - public static final SimpleType<Float> FLOAT; - - /** - * The {@link SimpleType} representation of - * <code>java.lang.Integer</code>. - */ - public static final SimpleType<Integer> INTEGER; - - /** - * The {@link SimpleType} representation of - * <code>java.lang.Long</code>. - */ - public static final SimpleType<Long> LONG; - - /** - * The {@link SimpleType} representation of - * <code>javax.management.ObjectName</code>. - */ - public static final SimpleType<ObjectName> OBJECTNAME; - - - /** - * The {@link SimpleType} representation of - * <code>java.lang.Short</code>. - */ - public static final SimpleType<Short> SHORT; - - /** - * The {@link SimpleType} representation of - * <code>java.lang.String</code>. - */ - public static final SimpleType<String> STRING; - - /** - * The {@link SimpleType} representation of - * <code>java.lang.Void</code>. - */ - public static final SimpleType<Void> VOID; - - /** - * Compatible with JDK 1.5 - */ - private static final long serialVersionUID = 2215577471957694503L; - - /** - * The hash code of this instance. - */ - private transient Integer hashCode; - - /** - * The <code>toString()</code> result of this instance. - */ - private transient String string; - - /** - * Static construction of the {@link SimpleType} instances. - */ - static - { - try - { - 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.", e); - } - } - - /** - * Constructs a new {@link SimpleType} instance for the given - * class name. The class name is also used as the type name - * and description of the {@link OpenType} instance. - * - * @param name the name of the class this instance should - * represent. - * @throws OpenDataException if somehow the constructor of the - * superclass is passed an invalid - * class name. - */ - private SimpleType(String name) - throws OpenDataException - { - super(name, name, name); - } - - /** - * <p> - * Compares this simple data type with another object - * for equality. The objects are judged to be equal if: - * </p> - * <ul> - * <li><code>obj</code> is not null.</li> - * <li><code>obj</code> is an instance of - * {@link SimpleType}.</li> - * <li>The class names are equal.</li> - * </ul> - * - * @param obj the object to compare with. - * @return true if the conditions above hold. - */ - public boolean equals(Object obj) - { - if (!(obj instanceof SimpleType)) - return false; - SimpleType<?> sType = (SimpleType<?>) obj; - return sType.getClassName().equals(getClassName()); - } - - /** - * <p> - * Returns the hash code of the simple data type. - * This is simply the hash code of the class name, - * which is the same element of the type 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 - * is computed just once for each instance and reused - * throughout its life. - * </p> - * - * @return the hash code of this instance. - */ - public int hashCode() - { - if (hashCode == null) - hashCode = Integer.valueOf(getClassName().hashCode()); - return hashCode.intValue(); - } - - /** - * Returns true if the specified object is a member of this - * simple type. The object is judged to be so if it is - * non-null and its class name is the same as that returned - * by {@link SimpleType#getClassName()}. - * - * @param obj the object to test for membership. - * @return true if the object is a member of this type. - */ - public boolean isValue(Object obj) - { - if (obj == null) - return false; - return obj.getClass().getName().equals(getClassName()); - } - - /** - * Replaces instances of this class read from an - * {@link java.io.ObjectInputStream} with one of the predefined - * values. This ensures that each existing instance of - * this class is one of these unique instances. - * - * @return the replacement object. - * @throws ObjectStreamException if the object can not be - * resolved. - */ - public Object readResolve() - throws ObjectStreamException - { - if (equals(BIGDECIMAL)) - return BIGDECIMAL; - if (equals(BIGINTEGER)) - return BIGINTEGER; - if (equals(BOOLEAN)) - return BOOLEAN; - if (equals(BYTE)) - return BYTE; - if (equals(CHARACTER)) - return CHARACTER; - if (equals(DATE)) - return DATE; - if (equals(DOUBLE)) - return DOUBLE; - if (equals(FLOAT)) - return FLOAT; - if (equals(INTEGER)) - return INTEGER; - if (equals(LONG)) - return LONG; - if (equals(OBJECTNAME)) - return OBJECTNAME; - if (equals(SHORT)) - return SHORT; - if (equals(STRING)) - return STRING; - if (equals(VOID)) - return VOID; - throw new InvalidObjectException("Invalid simple type instance " + - "deserialized."); - } - - /** - * <p> - * Returns a textual representation of this instance. This - * is constructed using the class name - * (<code>javax.management.openmbean.SimpleType</code>) - * and the name of the class the type represents. - * </p> - * <p> - * As instances of this class are immutable, the return value - * is computed just once for each instance and reused - * throughout its life. - * </p> - * - * @return a @link{java.lang.String} instance representing - * the instance in textual form. - */ - public String toString() - { - if (string == null) - string = getClass().getName() - + "[name=" + getClassName() - + "]"; - return string; - } - -} diff --git a/libjava/classpath/javax/management/openmbean/TabularData.java b/libjava/classpath/javax/management/openmbean/TabularData.java deleted file mode 100644 index 8bceae8..0000000 --- a/libjava/classpath/javax/management/openmbean/TabularData.java +++ /dev/null @@ -1,258 +0,0 @@ -/* TabularData.java -- Tables of composite data structures. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. - -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.util.Collection; -import java.util.Set; - -/** - * Provides an interface to a specific type of composite - * data structure, where keys (the columns) map to the - * {@link CompositeData} objects that form the rows of - * the table. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public interface TabularData -{ - - /** - * Calculates the index the specified {@link CompositeData} value - * would have, if it was to be added to this {@link TabularData} - * instance. This method includes a check that the type of the - * given value is the same as the row type of this instance, but not - * a check for existing instances of the given value. The value - * must also not be <code>null</code>. Possible indices are - * returned by the {@link TabularType#getIndexNames()} method of - * this instance's tabular type. The returned indices are the - * values of the fields in the supplied {@link CompositeData} - * instance that match the names given in the {@link TabularType}. - * - * @param val the {@link CompositeData} value whose index should - * be calculated. - * @return the index the value would take on, if it were to be added. - * @throws NullPointerException if the value is <code>null</code>. - * @throws InvalidOpenTypeException if the value does not match the - * row type of this instance. - */ - Object[] calculateIndex(CompositeData val); - - /** - * Removes all {@link CompositeData} values from the table. - */ - void clear(); - - /** - * Returns true iff this instance of the {@link TabularData} class - * contains a {@link CompositeData} value at the specified index. - * In any other circumstance, including if the given key - * is <code>null</code> or of the incorrect type, according to - * the {@link TabularType} of this instance, this method returns - * false. - * - * @param key the key to test for. - * @return true if the key maps to a {@link CompositeData} value. - */ - boolean containsKey(Object[] key); - - /** - * Returns true iff this instance of the {@link TabularData} class - * contains the specified {@link CompositeData} value. - * In any other circumstance, including if the given value - * is <code>null</code> or of the incorrect type, according to - * the {@link TabularType} of this instance, this method returns - * false. - * - * @param val the value to test for. - * @return true if the value exists. - */ - boolean containsValue(CompositeData val); - - /** - * Compares the specified object with this object for equality. - * The object is judged equivalent if it is non-null, and also - * an instance of {@link TabularData} with the same row type, - * and {@link CompositeData} values. The two compared instances may - * be equivalent even if they represent different implementations - * of {@link TabularData}. - * - * @param obj the object to compare for equality. - * @return true if <code>obj</code> is equal to <code>this</code>. - */ - boolean equals(Object obj); - - /** - * Retrieves the {@link CompositeData} value for the specified - * key, or <code>null</code> if no such mapping exists. - * - * @param key the key whose value should be returned. - * @return the matching {@link CompositeData} value, or - * <code>null</code> if one does not exist. - * @throws NullPointerException if the key is <code>null</code>. - * @throws InvalidKeyException if the key does not match - * the {@link TabularType} of this - * instance. - */ - CompositeData get(Object[] key); - - /** - * Returns the tabular type which corresponds to this instance - * of {@link TabularData}. - * - * @return the tabular type for this instance. - */ - TabularType getTabularType(); - - /** - * Returns the hash code of the composite data type. This is - * computed as the sum of the hash codes of each value, together - * with the hash code of the tabular type. 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. - * - * @return the hash code of this instance. - */ - int hashCode(); - - /** - * Returns true if this {@link TabularData} instance - * contains no {@link CompositeData} values. - * - * @return true if the instance is devoid of rows. - */ - boolean isEmpty(); - - /** - * Returns a {@link java.util.Set} view of the keys or - * indices of this {@link TabularData} instance. - * - * @return a set containing the keys of this instance. - */ - Set<?> keySet(); - - /** - * Adds the specified {@link CompositeData} value to the - * table. The value must be non-null, of the same type - * as the row type of this instance, and must not have - * the same index as an existing value. The index is - * calculated using the index names of the - * {@link TabularType} for this instance. - * - * @param val the {@link CompositeData} value to add. - * @throws NullPointerException if <code>val</code> is - * <code>null</code>. - * @throws InvalidOpenTypeException if the type of the - * given value does not - * match the row type. - * @throws KeyAlreadyExistsException if the value has the - * same calculated index - * as an existing value. - */ - void put(CompositeData val); - - /** - * Adds each of the specified {@link CompositeData} values - * to the table. Each element of the array must meet the - * conditions given for the {@link #put(CompositeData)} - * method. In addition, the index of each value in the - * array must be distinct from the index of the other - * values in the array, as well as from the existing values - * in the table. The operation should be atomic; if one - * value can not be added, then none of the values should - * be. If the array is <code>null</code> or empty, the - * method simply returns. - * - * @param vals the {@link CompositeData} values to add. - * @throws NullPointerException if a value from the array is - * <code>null</code>. - * @throws InvalidOpenTypeException if the type of a - * given value does not - * match the row type. - * @throws KeyAlreadyExistsException if a value has the - * same calculated index - * as an existing value or - * of one of the other - * specified values. - */ - void putAll(CompositeData[] vals); - - /** - * Removes the {@link CompositeData} value located at the - * specified index. <code>null</code> is returned if the - * value does not exist. Otherwise, the removed value is - * returned. - * - * @param key the key of the value to remove. - * @return the removed value, or <code>null</code> if - * there is no value for the given key. - * @throws NullPointerException if the key is <code>null</code>. - * @throws InvalidOpenTypeException if the key does not match - * the {@link TabularType} of this - * instance. - */ - CompositeData remove(Object[] key); - - /** - * Returns the number of {@link CompositeData} values or rows - * in the table. - * - * @return the number of rows in the table. - */ - int size(); - - /** - * Returns a textual representation of this instance. The - * exact format is left up to the implementation, but it - * should contain the name of the implementing class and - * the tabular type. - * - * @return a {@link java.lang.String} representation of the - * object. - */ - String toString(); - - /** - * Returns the values associated with this instance. - * - * @return the values of this instance. - */ - Collection<?> values(); - -} diff --git a/libjava/classpath/javax/management/openmbean/TabularDataSupport.java b/libjava/classpath/javax/management/openmbean/TabularDataSupport.java deleted file mode 100644 index e2da1b4..0000000 --- a/libjava/classpath/javax/management/openmbean/TabularDataSupport.java +++ /dev/null @@ -1,648 +0,0 @@ -/* TabularDataSupport.java -- Tables of composite data structures. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. - -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.io.Serializable; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Provides an implementation of the {@link TabularData} - * interface using a {@link java.util.HashMap}. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public class TabularDataSupport - implements TabularData, Serializable, Cloneable, Map<Object,Object> -{ - - /** - * Compatible with JDK 1.5 - */ - private static final long serialVersionUID = 5720150593236309827L; - - /** - * Mapping of rows to column values. - * - * @serial the map of rows to column values. - */ - private HashMap<Object,Object> dataMap; - - /** - * The tabular type which represents this tabular data instance. - * - * @serial the type information for this instance. - */ - private TabularType tabularType; - - /** - * Constructs a new empty {@link TabularDataSupport} with the - * specified type. The type may not be null. This constructor - * simply calls the other, with the default initial capacity of - * <code>101</code> and default load factor of <code>0.75</code>. - * - * @param type the tabular type of this tabular data instance. - * @throws IllegalArgumentException if <code>type</code> is - * <code>null</code>. - */ - public TabularDataSupport(TabularType type) - { - this(type, 101, 0.75f); - } - - /** - * Constructs a new empty {@link TabularDataSupport} with the - * specified type and the supplied initial capacity and load factor - * being used for the underlying {@link java.util.HashMap}. The - * type may not be null and the initial capacity and load factor - * must be positive. - * - * @param type the tabular type of this tabular data instance. - * @param cap the initial capacity of the underlying map. - * @param lf the load factor of the underlying map. - * @throws IllegalArgumentException if <code>type</code> is - * <code>null</code>, or - * <code>cap</code> or - * <code>lf</code> are - * negative. - */ - public TabularDataSupport(TabularType type, int cap, float lf) - { - if (type == null) - throw new IllegalArgumentException("The type may not be null."); - tabularType = type; - dataMap = new HashMap<Object,Object>(cap, lf); - } - - /** - * Calculates the index the specified {@link CompositeData} value - * would have, if it was to be added to this {@link TabularData} - * instance. This method includes a check that the type of the - * given value is the same as the row type of this instance, but not - * a check for existing instances of the given value. The value - * must also not be <code>null</code>. Possible indices are - * selected by the {@link TabularType#getIndexNames()} method of - * this instance's tabular type. The returned indices are the - * values of the fields in the supplied {@link CompositeData} - * instance that match the names given in the {@link TabularType}. - * - * @param val the {@link CompositeData} value whose index should - * be calculated. - * @return the index the value would take on, if it were to be added. - * @throws NullPointerException if the value is <code>null</code>. - * @throws InvalidOpenTypeException if the value does not match the - * row type of this instance. - */ - public Object[] calculateIndex(CompositeData val) - { - if (!(val.getCompositeType().equals(tabularType.getRowType()))) - throw new InvalidOpenTypeException("The type of the given value " + - "does not match the row type " + - "of this instance."); - List<String> indexNames = tabularType.getIndexNames(); - List<String> matchingIndicies = new ArrayList<String>(indexNames.size()); - for (String name : indexNames) - matchingIndicies.add(val.get(name).toString()); - return matchingIndicies.toArray(); - } - - /** - * Removes all {@link CompositeData} values from the table. - */ - public void clear() - { - dataMap.clear(); - } - - /** - * Returns a shallow clone of the information, as obtained by the - * {@link Object} implementation of {@link Object#clone()}. The map - * is also cloned, but it still references the same objects. - * - * @return a shallow clone of this {@link TabularDataSupport}. - */ - @SuppressWarnings("unchecked") - public Object clone() - { - TabularDataSupport clone = null; - try - { - clone = (TabularDataSupport) super.clone(); - clone.setMap((HashMap<Object,Object>) dataMap.clone()); - } - catch (CloneNotSupportedException e) - { - /* This won't happen as we implement Cloneable */ - } - return clone; - } - - /** - * Returns true iff this instance of the {@link TabularData} class - * contains a {@link CompositeData} value at the specified index. - * The method returns <code>false</code> if the given key can - * not be cast to an {@link java.lang.Object} array; otherwise - * it returns the result of {@link #containsKey(java.lang.Object[])}. - * - * - * @param key the key to test for. - * @return true if the key maps to a {@link CompositeData} value. - */ - public boolean containsKey(Object key) - { - if (key instanceof Object[]) - return containsKey((Object[]) key); - else - return false; - } - - /** - * Returns true iff this instance of the {@link TabularData} class - * contains a {@link CompositeData} value at the specified index. - * In any other circumstance, including if the given key - * is <code>null</code> or of the incorrect type, according to - * the {@link TabularType} of this instance, this method returns - * false. - * - * @param key the key to test for. - * @return true if the key maps to a {@link CompositeData} value. - */ - public boolean containsKey(Object[] key) - { - if (key == null) - return false; - if (!(isKeyValid(key))) - return false; - return dataMap.containsKey(key); - } - - /** - * Returns true iff this instance of the {@link TabularData} class - * contains the specified {@link CompositeData} value. If the given - * value is not an instance of {@link CompositeData}, this method - * simply returns false. - * - * @param val the value to test for. - * @return true if the value exists. - */ - public boolean containsValue(Object val) - { - if (val instanceof CompositeData) - return containsValue((CompositeData) val); - else - return false; - } - - /** - * Returns true iff this instance of the {@link TabularData} class - * contains the specified {@link CompositeData} value. - * In any other circumstance, including if the given value - * is <code>null</code> or of the incorrect type, according to - * the {@link TabularType} of this instance, this method returns - * false. - * - * @param val the value to test for. - * @return true if the value exists. - */ - public boolean containsValue(CompositeData val) - { - if (val == null) - return false; - if (!(val.getCompositeType().equals(tabularType.getRowType()))) - return false; - return dataMap.containsValue(val); - } - - /** - * <p> - * Returns a set view of the mappings in this Map. Each element in the - * set is a Map.Entry. The set is backed by the map, so that changes in - * one show up in the other. Modifications made while an iterator is - * in progress cause undefined behavior. If the set supports removal, - * these methods remove the underlying mapping from the map: - * <code>Iterator.remove</code>, <code>Set.remove</code>, - * <code>removeAll</code>, <code>retainAll</code>, and <code>clear</code>. - * Element addition, via <code>add</code> or <code>addAll</code>, is - * not supported via this set. - * </p> - * <p> - * <strong>Note</strong>: using the - * {@link java.util.Map.Entry#setValue(Object) will cause corruption of - * the index to row mappings. - * </p> - * - * @return the set view of all mapping entries - * @see java.util.Map.Entry - */ - public Set<Map.Entry<Object,Object>> entrySet() - { - return dataMap.entrySet(); - } - - /** - * Compares the specified object with this object for equality. - * The object is judged equivalent if it is non-null, and also - * an instance of {@link TabularData} with the same row type, - * and {@link CompositeData} values. The two compared instances may - * be equivalent even if they represent different implementations - * of {@link TabularData}. - * - * @param obj the object to compare for equality. - * @return true if <code>obj</code> is equal to <code>this</code>. - */ - public boolean equals(Object obj) - { - if (!(obj instanceof TabularData)) - return false; - TabularData data = (TabularData) obj; - return tabularType.equals(data.getTabularType()) && - dataMap.values().equals(data.values()); - } - - /** - * Retrieves the value for the specified key by simply - * calling <code>get((Object[]) key)</code>. - * - * @param key the key whose value should be returned. - * @return the matching {@link CompositeData} value, or - * <code>null</code> if one does not exist. - * @throws NullPointerException if the key is <code>null</code>. - * @throws ClassCastException if the key is not an instance - * of <code>Object[]</code>. - * @throws InvalidKeyException if the key does not match - * the {@link TabularType} of this - * instance. - */ - public Object get(Object key) - { - return get((Object[]) key); - } - - /** - * Retrieves the {@link CompositeData} value for the specified - * key, or <code>null</code> if no such mapping exists. - * - * @param key the key whose value should be returned. - * @return the matching {@link CompositeData} value, or - * <code>null</code> if one does not exist. - * @throws NullPointerException if the key is <code>null</code>. - * @throws InvalidKeyException if the key does not match - * the {@link TabularType} of this - * instance. - */ - public CompositeData get(Object[] key) - { - if (!(isKeyValid(key))) - throw new InvalidKeyException("The key does not match the " + - "tabular type of this instance."); - return (CompositeData) dataMap.get(key); - } - - /** - * Returns the tabular type which corresponds to this instance - * of {@link TabularData}. - * - * @return the tabular type for this instance. - */ - public TabularType getTabularType() - { - return tabularType; - } - - /** - * Returns the hash code of the composite data type. This is - * computed as the sum of the hash codes of each value, together - * with the hash code of the tabular type. 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. - * - * @return the hash code of this instance. - */ - public int hashCode() - { - return tabularType.hashCode() + dataMap.values().hashCode(); - } - - /** - * Returns true if this {@link TabularData} instance - * contains no {@link CompositeData} values. - * - * @return true if the instance is devoid of rows. - */ - public boolean isEmpty() - { - return dataMap.isEmpty(); - } - - /** - * Returns true if the given key is valid for the - * @link{TabularType} of this instance. - * - * @return true if the key is valid. - * @throws NullPointerException if <code>key</code> - * is null. - */ - private boolean isKeyValid(Object[] key) - { - Iterator<String> it = tabularType.getIndexNames().iterator(); - CompositeType rowType = tabularType.getRowType(); - for (int a = 0; it.hasNext(); ++a) - { - OpenType<?> type = rowType.getType(it.next()); - if (!(type.isValue(key[a]))) - return false; - } - return true; - } - - /** - * Returns a set view of the keys in this Map. The set is backed by the - * map, so that changes in one show up in the other. Modifications made - * while an iterator is in progress cause undefined behavior. If the set - * supports removal, these methods remove the underlying mapping from - * the map: <code>Iterator.remove</code>, <code>Set.remove</code>, - * <code>removeAll</code>, <code>retainAll</code>, and <code>clear</code>. - * Element addition, via <code>add</code> or <code>addAll</code>, is - * not supported via this set. - * - * @return the set view of all keys - */ - public Set<Object> keySet() - { - return dataMap.keySet(); - } - - /** - * Adds the specified {@link CompositeData} value to the - * table. The value must be non-null, of the same type - * as the row type of this instance, and must not have - * the same index as an existing value. The index is - * calculated using the index names of the - * {@link TabularType} for this instance. - * - * @param val the {@link CompositeData} value to add. - * @throws NullPointerException if <code>val</code> is - * <code>null</code>. - * @throws InvalidOpenTypeException if the type of the - * given value does not - * match the row type. - * @throws KeyAlreadyExistsException if the value has the - * same calculated index - * as an existing value. - */ - public void put(CompositeData val) - { - Object[] key = calculateIndex(val); - if (dataMap.containsKey(key)) - throw new KeyAlreadyExistsException("A value with this index " + - "already exists."); - dataMap.put(key, val); - } - - /** - * Adds the specified {@link CompositeData} value to the - * table, ignoring the supplied key, by simply calling - * <code>put((CompositeData) val)</code>. - * - * @param key ignored. - * @param val the {@link CompositeData} value to add. - * @return the {@link CompositeData} value. - * @throws NullPointerException if <code>val</code> is - * <code>null</code>. - * @throws InvalidOpenTypeException if the type of the - * given value does not - * match the row type. - * @throws KeyAlreadyExistsException if the value has the - * same calculated index - * as an existing value. - */ - public Object put(Object key, Object val) - { - put((CompositeData) val); - return val; - } - - /** - * Adds each of the specified {@link CompositeData} values - * to the table. Each element of the array must meet the - * conditions given for the {@link #put(CompositeData)} - * method. In addition, the index of each value in the - * array must be distinct from the index of the other - * values in the array, as well as from the existing values - * in the table. The operation should be atomic; if one - * value can not be added, then none of the values should - * be. If the array is <code>null</code> or empty, the - * method simply returns. - * - * @param vals the {@link CompositeData} values to add. - * @throws NullPointerException if a value from the array is - * <code>null</code>. - * @throws InvalidOpenTypeException if the type of a - * given value does not - * match the row type. - * @throws KeyAlreadyExistsException if a value has the - * same calculated index - * as an existing value or - * of one of the other - * specified values. - */ - public void putAll(CompositeData[] vals) - { - if (vals == null || vals.length == 0) - return; - Map<Object,Object> mapToAdd = new HashMap<Object,Object>(vals.length); - for (int a = 0; a < vals.length; ++a) - { - Object[] key = calculateIndex(vals[a]); - if (dataMap.containsKey(key)) - throw new KeyAlreadyExistsException("Element " + a + ": A " + - "value with this index " + - "already exists."); - mapToAdd.put(key, vals[a]); - } - dataMap.putAll(mapToAdd); - } - - /** - * Converts each value from the specified map to a member of an - * array of {@link CompositeData} values and adds them using {@link - * #put(CompositeData[])}, if possible. As in {@link - * #put(Object,Object)}, the keys are simply ignored. This method - * is useful for adding the {@link CompositeData} values from a - * different {@link TabularData} instance, which uses the same - * {@link TabularType} but a different selection of index names, to - * this one. If the map is <code>null</code> or empty, the method - * simply returns. - * - * @param m the map to add. Only the values are used and must - * all be instances of {@link CompositeData}. - * @throws NullPointerException if a value from the map is - * <code>null</code>. - * @throws ClassCastException if a value from the map is not - * an instance of {@link CompositeData}. - * @throws InvalidOpenTypeException if the type of the - * given value does not - * match the row type. - * @throws KeyAlreadyExistsException if the value has the - * same calculated index - * as an existing value or - * of one of the other - * specified values. - */ - public void putAll(Map<?,?> m) - { - if (m == null || m.size() == 0) - return; - Collection<?> vals = m.values(); - CompositeData[] data = new CompositeData[vals.size()]; - Iterator<?> it = vals.iterator(); - for (int a = 0; it.hasNext(); ++a) - { - data[a] = (CompositeData) it.next(); - } - putAll(data); - } - - /** - * Removes the value for the specified key by simply - * calling <code>remove((Object[]) key)</code>. - * - * @param key the key whose value should be removed. - * @return the removed value, or <code>null</code> if - * there is no value for the given key. - * @throws NullPointerException if the key is <code>null</code>. - * @throws ClassCastException if the key is not an instance - * of <code>Object[]</code>. - * @throws InvalidOpenTypeException if the key does not match - * the {@link TabularType} of this - * instance. - */ - public Object remove(Object key) - { - return remove((Object[]) key); - } - - /** - * Removes the {@link CompositeData} value located at the - * specified index. <code>null</code> is returned if the - * value does not exist. Otherwise, the removed value is - * returned. - * - * @param key the key of the value to remove. - * @return the removed value, or <code>null</code> if - * there is no value for the given key. - * @throws NullPointerException if the key is <code>null</code>. - * @throws InvalidOpenTypeException if the key does not match - * the {@link TabularType} of this - * instance. - */ - public CompositeData remove(Object[] key) - { - if (!(isKeyValid(key))) - throw new InvalidKeyException("The key does not match the " + - "tabular type of this instance."); - return (CompositeData) dataMap.remove(key); - } - - /** - * Private method to set the internal {@link java.util.Map} - * instance (used in cloning). - * - * @param map the new map used. - */ - private void setMap(HashMap<Object,Object> map) - { - dataMap = map; - } - - /** - * Returns the number of {@link CompositeData} values or rows - * in the table. - * - * @return the number of rows in the table. - */ - public int size() - { - return dataMap.size(); - } - - /** - * Returns a textual representation of this instance. This - * is constructed using the class name - * (<code>javax.management.openmbean.TabularDataSupport</code>) - * and the result of calling <code>toString()</code> on the - * tabular type and underlying hash map instance. - * - * @return a {@link java.lang.String} representation of the - * object. - */ - public String toString() - { - return getClass().getName() - + "[tabularType=" + tabularType - + ",dataMap=" + dataMap - + "]"; - } - - /** - * Returns a collection (or bag) view of the values in this Map. The - * collection is backed by the map, so that changes in one show up in - * the other. Modifications made while an iterator is in progress cause - * undefined behavior. If the collection supports removal, these methods - * remove the underlying mapping from the map: <code>Iterator.remove</code>, - * <code>Collection.remove</code>, <code>removeAll</code>, - * <code>retainAll</code>, and <code>clear</code>. Element addition, via - * <code>add</code> or <code>addAll</code>, is not supported via this - * collection. - * - * @return the collection view of all 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 deleted file mode 100644 index 5ea220701..0000000 --- a/libjava/classpath/javax/management/openmbean/TabularType.java +++ /dev/null @@ -1,268 +0,0 @@ -/* TabularType.java -- Type descriptor for TabularData instances. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. - -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.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -/** - * The open type descriptor for instances of the - * {@link TabularData} class. - * - * @author Andrew John Hughes (gnu_andrew@member.fsf.org) - * @since 1.5 - */ -public class TabularType - extends OpenType<TabularData> -{ - - /** - * Compatible with JDK 1.5 - */ - private static final long serialVersionUID = 6554071860220659261L; - - /** - * The composite type used by the rows of the table. - */ - private CompositeType rowType; - - /** - * The list of index names, which form the columns of the table. - * They are retained in the order given by the user, and is - * unmodifiable. - */ - private List<String> indexNames; - - /** - * The hash code of this instance. - */ - private transient Integer hashCode; - - /** - * The <code>toString()</code> result of this instance. - */ - private transient String string; - - /** - * <p> - * Constructs a new {@link TabularType} instance for the given - * type name, description, row type and index names. All parameters - * (including the individual elements of the array of index names) - * must be non-null and those that are of type {@link java.lang.String} - * must be non-empty. The array of index names must also be non-empty. - * </p> - * <p> - * The result of <code>TabularData.class.getName()</code> is adopted - * as the class name (see {@link OpenType}). The ordering of the array - * elements is relevant in determining the indicies of the values in the - * table, and thus in the use of the - * {@link TabularData#get(java.lang.Object[])} and - * {@link TabularData#remove(java.lang.Object[])} methods of the - * {@link TabularData} class. - * </p> - * - * @param name the name of this tabular type. - * @param desc a description of this tabular type. - * @param rowType the type of the rows of the table. - * @param indexNames the names used to index the rows within the table. - * @throws IllegalArgumentException if any validity constraint listed above - * is broken. - * @throws OpenDataException if an index name does not match a corresponding - * name in the given row type. - */ - public TabularType(String name, String desc, CompositeType rowType, - String[] indexNames) - throws OpenDataException - { - super(TabularData.class.getName(), name, desc); - if (rowType == null) - throw new IllegalArgumentException("A null row type was given."); - for (int a = 0; a < indexNames.length; ++a) - { - if (indexNames[a] == null) - throw new IllegalArgumentException("Name " + a + - " is null."); - if (indexNames[a].length() == 0) - throw new IllegalArgumentException("Name " + a + - " is the empty string."); - if (!(rowType.containsKey(indexNames[a]))) - throw new OpenDataException("No matching key for " + - indexNames[a] + " was found in " + - "the supplied row type."); - } - this.rowType = rowType; - this.indexNames = Collections.unmodifiableList(Arrays.asList(indexNames)); - } - - /** - * <p> - * Compares this tabular data type with another object - * for equality. The objects are judged to be equal if: - * </p> - * <ul> - * <li><code>obj</code> is not null.</li> - * <li><code>obj</code> is an instance of - * {@link TabularType}.</li> - * <li>The type names are equal.</li> - * <li>The row types are equal.</li> - * <li>The index names are equal and in the same order.</li> - * </ul> - * - * @param obj the object to compare with. - * @return true if the conditions above hold. - */ - public boolean equals(Object obj) - { - if (!(obj instanceof TabularType)) - return false; - TabularType ttype = (TabularType) obj; - return (ttype.getTypeName().equals(getTypeName()) - && (ttype.getRowType().equals(getRowType())) - && (ttype.getIndexNames().equals(getIndexNames()))); - } - - /** - * Returns an unmodifiable list containing the index names. - * The ordering of these names is used to determine the indicies - * of the {@link CompositeData} values, and is retained from that - * used in the call to this object's constructor. - * - * @return an unmodifiable list of the index names used by this - * tabular data structure. - */ - public List<String> getIndexNames() - { - return indexNames; - } - - /** - * Returns the type of the rows used by this tabular data structure. - * - * @return the row type. - */ - public CompositeType getRowType() - { - return rowType; - } - - /** - * <p> - * Returns the hash code of the tabular data type. - * This is computed as the sum of the hash codes of the - * index names together with the hash code of the type - * name and row type. 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 - * is computed just once for each instance and reused - * throughout its life. - * </p> - * - * @return the hash code of this instance. - */ - public int hashCode() - { - if (hashCode == null) - { - int elementTotal = 0; - for (String s : indexNames) - elementTotal += s.hashCode(); - hashCode = Integer.valueOf(elementTotal - + getTypeName().hashCode() - + rowType.hashCode()); - } - return hashCode.intValue(); - } - - /** - * Returns true if the specified object is a member of this - * tabular type. The object is judged to be so if it is - * an instance of {@link TabularData} with an equivalent - * type, according to the definition of - * {@link #equals(java.lang.Object)} for {@link TabularType}. - * - * @param obj the object to test for membership. - * @return true if the object is a member of this type. - */ - public boolean isValue(Object obj) - { - if (obj instanceof TabularData) - { - TabularData data = (TabularData) obj; - return equals(data.getTabularType()); - } - return false; - } - - /** - * <p> - * Returns a textual representation of this instance. This - * is constructed using the class name - * (<code>javax.management.openmbean.TabularType</code>) - * and each element of the instance which is relevant to - * the definition of {@link equals(java.lang.Object)} and - * {@link hashCode()} (i.e. the type name, the row type - * and the index names). - * </p> - * <p> - * As instances of this class are immutable, the return value - * is computed just once for each instance and reused - * throughout its life. - * </p> - * - * @return a @link{java.lang.String} instance representing - * the instance in textual form. - */ - public String toString() - { - if (string == null) - string = getClass().getName() - + "[name=" + getTypeName() - + ", rowType=" + rowType - + ", indexNames=" + indexNames - + "]"; - return string; - } - -} diff --git a/libjava/classpath/javax/management/openmbean/package.html b/libjava/classpath/javax/management/openmbean/package.html deleted file mode 100644 index d915007..0000000 --- a/libjava/classpath/javax/management/openmbean/package.html +++ /dev/null @@ -1,64 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<!-- package.html - describes classes in java.lang.management package. - Copyright (C) 2006 Free Software Foundation, Inc. - -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. --> - -<html> -<head><title>GNU Classpath - javax.management.openmbean</title></head> - -<body> - -<p> -Provides the data types and descriptor classes for the -<emph>Open MBean</emph>s. Open MBeans are provided in -order to aid interoperability with non-Java management -systems. Unlike normal MBeans, which make use of any -Java data type, Open MBeans use a restricted set of types -which can then be mapped over remote connections, including -to non-Java systems. -</p> -<p> -Normal MBeans are described using an instance of -{@link javax.management.MBeanInfo} with appropriate representations -of the attributes, constructors and operators associated with -the bean. Open MBeans are described in the same way, but by -using subtypes of these entities, which type the bean data using -instances of {@link javax.management.openmbean.OpenType}. Open -types differ from Java types, and are explicitly specified in order -to obtain interoperability with other systems. -</p> -</body> -</html> |