javax.management.openmbean

Class CompositeType

Implemented Interfaces:
Serializable

public class CompositeType
extends OpenType<T>

The open type descriptor for instances of the CompositeData class.
Since:
1.5
See Also:
Serialized Form

Field Summary

Fields inherited from class javax.management.openmbean.OpenType<T>

ALLOWED_CLASSNAMES_LIST, String[]ALLOWED_CLASSNAMES

Constructor Summary

CompositeType(String name, String desc, String[] names, String[] descs, OpenType[] types)
Constructs a new CompositeType instance for the given type name with the specified field names, descriptions and types.

Method Summary

boolean
containsKey(String name)
Returns true if this composite data type has a field with the given name.
boolean
equals(Object obj)
Compares this composite data type with another object for equality.
String
getDescription(String name)
Returns the description for the given field name, or null if the field name does not exist within this composite data type.
OpenType
getType(String name)
Returns the type for the given field name, or null if the field name does not exist within this composite data type.
int
hashCode()
Returns the hash code of the composite data type.
boolean
isValue(Object obj)
Returns true if the specified object is a member of this composite type.
Set
keySet()
Returns an unmodifiable Set-based view of the field names that form part of this CompositeType instance.
String
toString()
Returns a textual representation of this instance.

Methods inherited from class javax.management.openmbean.OpenType<T>

equals, getClassName, getDescription, getTypeName, hashCode, isArray, isValue, toString

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

CompositeType

public CompositeType(String name,
                     String desc,
                     String[] names,
                     String[] descs,
                     OpenType[] types)
            throws OpenDataException
Constructs a new 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 String values must be something other than the empty string. The arrays must be non-empty, and be of equal size.

The result of CompositeData.class.getName() is adopted as the class name (see OpenType) and changes to the array elements following construction of the CompositeType instance will not 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.

Parameters:
name - the name of this composite type.
desc - a description of this composite type.
names - the names of each field within the composite type.
descs - the descriptions of each field within the composite type.
types - the types of each field within the composite type.
Throws:
IllegalArgumentException - if any validity constraint listed above is broken.
OpenDataException - if duplicate item names are provided. Item names are case-sensitive, but whitespace is removed before comparison.

Method Details

containsKey

public boolean containsKey(String name)
Returns true if this composite data type has a field with the given name.
Parameters:
name - the name of the field to check for.
Returns:
true if a field of that name exists.

equals

public boolean equals(Object obj)
Compares this composite data type with another object for equality. The objects are judged to be equal if:
  • obj is not null.
  • obj is an instance of CompositeType.
  • The type names are equal.
  • The fields and their types match.
Overrides:
equals in interface OpenType<T>
Parameters:
obj - the object to compare with.
Returns:
true if the conditions above hold.

getDescription

public String getDescription(String name)
Returns the description for the given field name, or null if the field name does not exist within this composite data type.
Parameters:
name - the name of the field whose description should be returned.
Returns:
the description, or null if the field doesn't exist.

getType

public OpenType getType(String name)
Returns the type for the given field name, or null if the field name does not exist within this composite data type.
Parameters:
name - the name of the field whose type should be returned.
Returns:
the type, or null if the field doesn't exist.

hashCode

public int hashCode()
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 equals(Object) method, thus ensuring that the hashcode is compatible with the equality test.

As instances of this class are immutable, the hash code is computed just once for each instance and reused throughout its life.

Overrides:
hashCode in interface OpenType<T>
Returns:
the hash code of this instance.

isValue

public boolean isValue(Object obj)
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 CompositeData with an equivalent type, according to the definition of equals(Object) for CompositeType.
Overrides:
isValue in interface OpenType<T>
Parameters:
obj - the object to test for membership.
Returns:
true if the object is a member of this type.

keySet

public Set keySet()
Returns an unmodifiable Set-based view of the field names that form part of this CompositeType instance. The names are stored in ascending alphanumeric order.
Returns:
a unmodifiable set containing the field name Strings.

toString

public String toString()
Returns a textual representation of this instance. This is constructed using the class name (javax.management.openmbean.CompositeType) and each element of the instance which is relevant to the definition of equals(java.lang.Object) and hashCode() (i.e. the type name, and the name and type of each field).

As instances of this class are immutable, the return value is computed just once for each instance and reused throughout its life.

Overrides:
toString in interface OpenType<T>
Returns:
a @link{java.lang.String} instance representing the instance in textual form.

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.