This patch adds the CompositeData interfaces along
with its dependencies (a class representing its type,
and the tabular data stuff too, as it gets used by
the super type of CompositeType, OpenType).  This
will allow the missing from(CompositeData) methods
to be implemented.

Changelog:

2006-07-09  Andrew John Hughes  <[EMAIL PROTECTED]>

        * javax/management/openmbean/CompositeData.java,
        * javax/management/openmbean/CompositeType.java,
        * javax/management/openmbean/OpenDataException.java,
        * javax/management/openmbean/OpenType.java,
        * javax/management/openmbean/TabularData.java,
        * javax/management/openmbean/TabularType.java,
        * javax/management/openmbean/package.html:
        New files.

-- 
Andrew :-)

Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html
public class gcj extends Freedom implements Java { ... }
Index: javax/management/openmbean/CompositeData.java
===================================================================
RCS file: javax/management/openmbean/CompositeData.java
diff -N javax/management/openmbean/CompositeData.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ javax/management/openmbean/CompositeData.java       9 Jul 2006 13:52:17 
-0000
@@ -0,0 +1,154 @@
+/* CompositeData.java -- A composite data structure.
+   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.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 ([EMAIL PROTECTED])
+ * @since 1.5
+ */
+public interface CompositeData
+{
+
+  /**
+   * Returns true if this [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] CompositeData} with the same values
+   * and types.  The two compared instances may be equivalent even
+   * if they represent different implementations of
+   * [EMAIL PROTECTED] 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[] key);
+
+  /**
+   * Returns the composite type which corresponds to this instance
+   * of [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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();
+
+}
+
Index: javax/management/openmbean/CompositeType.java
===================================================================
RCS file: javax/management/openmbean/CompositeType.java
diff -N javax/management/openmbean/CompositeType.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ javax/management/openmbean/CompositeType.java       9 Jul 2006 13:52:17 
-0000
@@ -0,0 +1,324 @@
+/* CompositeType.java -- Type descriptor for CompositeData instances.
+   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.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
+ * [EMAIL PROTECTED] CompositeData} class.
+ * 
+ * @author Andrew John Hughes ([EMAIL PROTECTED])
+ * @since 1.5
+ */
+public class CompositeType
+  extends OpenType
+{
+
+  /**
+   * Compatible with JDK 1.5
+   */
+  private static final long serialVersionUID = -5366242454346948798L;
+
+  /**
+   * A map of item names to their descriptions.
+   */
+  private TreeMap nameToDescription;
+
+  /**
+   * A map of item names to their types.
+   */
+  private TreeMap nameToType;
+
+  /**
+   * The hash code of this instance.
+   */
+  private volatile Integer hashCode;
+
+  /**
+   * The <code>toString()</code> result of this instance.
+   */
+  private volatile String string;
+
+  /**
+   * <p>
+   * Constructs a new [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] OpenType}) and changes to the 
array
+   * elements following construction of the [EMAIL PROTECTED] 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();
+    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();
+    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
+   * [EMAIL PROTECTED] 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 keys = keySet();
+    if (!(ctype.keySet().equals(keys)))
+      return false;
+    Iterator it = keys.iterator();
+    while (it.hasNext())
+      {
+       String key = (String) it.next();
+       if (!(ctype.getType(key).equals(getType(key))))
+         return false;
+      }
+    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 (String) 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 (OpenType) 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
+   * [EMAIL PROTECTED] #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;
+       Iterator it = nameToType.entrySet().iterator();
+       while (it.hasNext())
+         {
+           Map.Entry entry = (Map.Entry) it.next();
+           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 [EMAIL PROTECTED] CompositeData} with an equivalent
+   * type, according to the definition of
+   * [EMAIL PROTECTED] #equals(java.lang.Object)} for [EMAIL PROTECTED] 
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 [EMAIL PROTECTED] java.util.Set}-based
+   * view of the field names that form part of this 
+   * [EMAIL PROTECTED] CompositeType} instance.  The names are stored
+   * in ascending alphanumeric order.
+   *
+   * @return a unmodifiable set containing the field
+   *         name [EMAIL PROTECTED] java.lang.String}s.
+   */
+  public Set 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 [EMAIL PROTECTED] equals(java.lang.Object)} and
+   * [EMAIL PROTECTED] 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;
+  }
+
+}
Index: javax/management/openmbean/OpenDataException.java
===================================================================
RCS file: javax/management/openmbean/OpenDataException.java
diff -N javax/management/openmbean/OpenDataException.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ javax/management/openmbean/OpenDataException.java   9 Jul 2006 13:52:17 
-0000
@@ -0,0 +1,74 @@
+/* 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 ([EMAIL PROTECTED])
+ * @since 1.5
+ */
+public class OpenDataException
+  extends JMException
+{
+
+  /**
+   * 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);
+  }
+
+}
+
Index: javax/management/openmbean/OpenType.java
===================================================================
RCS file: javax/management/openmbean/OpenType.java
diff -N javax/management/openmbean/OpenType.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ javax/management/openmbean/OpenType.java    9 Jul 2006 13:52:17 -0000
@@ -0,0 +1,230 @@
+/* OpenType.java -- Superclass of all open types.
+   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.io.Serializable;
+
+/**
+ * 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 ([EMAIL PROTECTED])
+ * @since 1.5
+ */
+public abstract class OpenType
+  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.
+   */
+  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() 
+  };
+
+  /**
+   * Constructs a new [EMAIL PROTECTED] OpenType} for the specified class
+   * with the given name and description.  The name of the class
+   * must be taken from the list of [EMAIL PROTECTED] ALLOWED_CLASSNAMES}.
+   * Arrays are implictly included in this, and follow the usual
+   * syntax of [EMAIL PROTECTED] 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.");
+    String testString;
+    if (className.startsWith("["))
+      testString = className.substring(className.indexOf("L") + 1);
+    else
+      testString = className;
+    boolean openTypeFound = false;
+    for (int a = 0; a < ALLOWED_CLASSNAMES.length; ++a)
+      if (ALLOWED_CLASSNAMES[a].equals(className))
+       openTypeFound = true;
+    if (!openTypeFound)
+      throw new OpenDataException("The class name 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 [EMAIL PROTECTED] ALLOWED_CLASSNAMES} or an array of one of 
them.
+   * The specification of arrays follows the standard set by 
+   * [EMAIL PROTECTED] 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 [EMAIL PROTECTED] equals()} method.
+   * Thus, it should continue to return the same value while
+   * the values used by the [EMAIL PROTECTED] equals()} method remain
+   * the same, and should return different hash codes for
+   * objects which are judged to be different using the
+   * [EMAIL PROTECTED] 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 [EMAIL PROTECTED] java.lang.String} representation of this
+   *         type.
+   */
+  public abstract String toString();
+
+}
Index: javax/management/openmbean/TabularData.java
===================================================================
RCS file: javax/management/openmbean/TabularData.java
diff -N javax/management/openmbean/TabularData.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ javax/management/openmbean/TabularData.java 9 Jul 2006 13:52:17 -0000
@@ -0,0 +1,258 @@
+/* TabularData.java -- Tables of composite data structures.
+   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.Collection;
+import java.util.Set;
+
+/**
+ * Provides an interface to a specific type of composite
+ * data structure, where keys (the columns) map to the
+ * [EMAIL PROTECTED] CompositeData} objects that form the rows of
+ * the table.
+ *
+ * @author Andrew John Hughes ([EMAIL PROTECTED])
+ * @since 1.5
+ */
+public interface TabularData
+{
+
+  /**
+   * Calculates the index the specified [EMAIL PROTECTED] CompositeData} value
+   * would have, if it was to be added to this [EMAIL PROTECTED] 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 [EMAIL PROTECTED] TabularType#getIndexNames()} method
+   * of this instance's tabular type.
+   * 
+   * @param val the [EMAIL PROTECTED] 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 [EMAIL PROTECTED] CompositeData} values from the table.
+   */
+  void clear();
+
+  /**
+   * Returns true iff this instance of the [EMAIL PROTECTED] TabularData} class
+   * contains a [EMAIL PROTECTED] 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 [EMAIL PROTECTED] TabularType} of this instance, this method returns
+   * false.
+   *
+   * @param key the key to test for.
+   * @return true if the key maps to a [EMAIL PROTECTED] CompositeData} value.
+   */
+  boolean containsKey(Object[] key);
+
+  /**
+   * Returns true iff this instance of the [EMAIL PROTECTED] TabularData} class
+   * contains the specified [EMAIL PROTECTED] CompositeData} value.
+   * In any other circumstance, including if the given value
+   * is <code>null</code> or of the incorrect type, according to
+   * the [EMAIL PROTECTED] 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 [EMAIL PROTECTED] TabularData} with the same row type,
+   * and index to value mappings.  The two compared instances may
+   * be equivalent even if they represent different implementations
+   * of [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] CompositeData} value, or
+   *         <code>null</code> if one does not exist.
+   * @throws NullPointerException if the key is <code>null</code>.
+   * @throws InvalidOpenTypeException if the key does not match
+   *                                  the [EMAIL PROTECTED] TabularType} of 
this
+   *                                  instance.
+   */
+  CompositeData get(Object[] key);
+
+  /**
+   * Returns the tabular type which corresponds to this instance
+   * of [EMAIL PROTECTED] 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 the
+   * each index and its 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
+   * [EMAIL PROTECTED] #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 [EMAIL PROTECTED] TabularData} instance
+   * contains no [EMAIL PROTECTED] CompositeData} values.
+   * 
+   * @return true if the instance is devoid of rows.
+   */
+  boolean isEmpty();
+
+  /**
+   * Returns a [EMAIL PROTECTED] java.util.Set} view of the keys or
+   * indices of this [EMAIL PROTECTED] TabularData} instance. 
+   *
+   * @return a set containing the keys of this instance.
+   */
+  Set keySet();
+
+  /**
+   * Adds the specified [EMAIL PROTECTED] 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
+   * [EMAIL PROTECTED] TabularType} for this instance.
+   * 
+   * @param val the [EMAIL PROTECTED] 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 [EMAIL PROTECTED] CompositeData} values
+   * to the table.  Each element of the array must meet the
+   * conditions given for the [EMAIL PROTECTED] #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.
+   * 
+   * @param vals the [EMAIL PROTECTED] CompositeData} values 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 or
+   *                                   of one of the other
+   *                                   specified values.
+   */
+  void putAll(CompositeData[] vals);
+
+  /**
+   * Removes the [EMAIL PROTECTED] 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 [EMAIL PROTECTED] TabularType} of 
this
+   *                                  instance.
+   */
+  CompositeData remove(Object[] key);
+
+  /**
+   * Returns the number of [EMAIL PROTECTED] 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 [EMAIL PROTECTED] java.lang.String} representation of the
+   *         object.
+   */
+  String toString();
+ 
+  /**
+   * Returns the values associated with this instance.
+   *
+   * @return the values of this instance.
+   */
+  Collection values();
+
+}
+
Index: javax/management/openmbean/TabularType.java
===================================================================
RCS file: javax/management/openmbean/TabularType.java
diff -N javax/management/openmbean/TabularType.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ javax/management/openmbean/TabularType.java 9 Jul 2006 13:52:17 -0000
@@ -0,0 +1,269 @@
+/* TabularType.java -- Type descriptor for TabularData instances.
+   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.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * The open type descriptor for instances of the
+ * [EMAIL PROTECTED] TabularData} class.
+ * 
+ * @author Andrew John Hughes ([EMAIL PROTECTED])
+ * @since 1.5
+ */
+public class TabularType
+  extends OpenType
+{
+
+  /**
+   * 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 indexNames;
+
+  /**
+   * The hash code of this instance.
+   */
+  private volatile Integer hashCode;
+
+  /**
+   * The <code>toString()</code> result of this instance.
+   */
+  private volatile String string;
+
+  /**
+   * <p>
+   * Constructs a new [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 
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 [EMAIL PROTECTED] 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 
+   * [EMAIL PROTECTED] TabularData#get(java.lang.Object[])} and
+   * [EMAIL PROTECTED] TabularData#remove(java.lang.Object[])} methods of the
+   * [EMAIL PROTECTED] 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
+   * [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 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
+   * [EMAIL PROTECTED] #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;
+       Iterator it = indexNames.iterator();
+       while (it.hasNext())
+         elementTotal += it.next().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 [EMAIL PROTECTED] TabularData} with an equivalent
+   * type, according to the definition of
+   * [EMAIL PROTECTED] #equals(java.lang.Object)} for [EMAIL PROTECTED] 
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 [EMAIL PROTECTED] equals(java.lang.Object)} and
+   * [EMAIL PROTECTED] 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;
+  }
+
+}
Index: javax/management/openmbean/package.html
===================================================================
RCS file: javax/management/openmbean/package.html
diff -N javax/management/openmbean/package.html
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ javax/management/openmbean/package.html     9 Jul 2006 13:52:17 -0000
@@ -0,0 +1,64 @@
+<!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
[EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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>

Attachment: signature.asc
Description: Digital signature

Reply via email to