APIdia Launch Partner
Top Description Fields Constructors Methods
javax.management.openmbean

public Class CompositeType

extends OpenType<CompositeData>
Class Inheritance
Imports
java.util.Set, .TreeMap, .Collections, .Iterator

The CompositeType class is the open type class whose instances describe the types of CompositeData values.
Since
1.5

Field Summary

Modifier and TypeField and Description
private transient Integer
private transient Set<String>
private transient String
private TreeMap<String, String>
private TreeMap<String, OpenType<?>>
pack-priv static final long
Inherited from javax.management.openmbean.OpenType:
ALLOWED_CLASSNAMESALLOWED_CLASSNAMES_LIST

Constructor Summary

AccessConstructor and Description
public
CompositeType(String
The name given to the composite type this instance represents; cannot be a null or empty string.
typeName
,
String
The human readable description of the composite type this instance represents; cannot be a null or empty string.
description
,
String[]
The names of the items contained in the composite data values described by this CompositeType instance; cannot be null and should contain at least one element; no element can be a null or empty string. Note that the order in which the item names are given is not important to differentiate a CompositeType instance from another; the item names are internally stored sorted in ascending alphanumeric order.
itemNames
,
String[]
The descriptions, in the same order as itemNames, of the items contained in the composite data values described by this CompositeType instance; should be of the same size as itemNames; no element can be null or an empty string.
itemDescriptions
,
OpenType<?>[]
The open type instances, in the same order as itemNames, describing the items contained in the composite data values described by this CompositeType instance; should be of the same size as itemNames; no element can be null.
itemTypes
)

Constructs a CompositeType instance, checking for the validity of the given parameters.

Method Summary

Modifier and TypeMethod and Description
private static void
private static void
public boolean

Returns:

true if an item of this name is present.
containsKey
(String
the name of the item.
itemName
)

Returns true if this CompositeType instance defines an item whose name is itemName.

public boolean

Returns:

true if the specified object is equal to this CompositeType instance.
equals
(Object
the object to be compared for equality with this CompositeType instance; if obj is null, equals returns false.
obj
)

Implements abstract javax.management.openmbean.OpenType.equals.

Compares the specified obj parameter with this CompositeType instance for equality.

public String

Returns:

the description.
getDescription
(String
the name of the item.
itemName
)

Returns the description of the item whose name is itemName, or null if this CompositeType instance does not define any item whose name is itemName.

public OpenType<?>

Returns:

the type.
getType
(String
the name of the time.
itemName
)

Returns the open type of the item whose name is itemName, or null if this CompositeType instance does not define any item whose name is itemName.

public int

Returns:

the hash code value for this CompositeType instance
hashCode
()

Implements abstract javax.management.openmbean.OpenType.hashCode.

Returns the hash code value for this CompositeType instance.

pack-priv boolean

Returns:

true if ot is assignable to this open type.
isAssignableFrom
(OpenType<?>
the type to be tested.
ot
)

Overrides javax.management.openmbean.OpenType.isAssignableFrom.

Tests whether values of the given type can be assigned to this open type.

public boolean

Returns:

true if obj is a value for this composite type, false otherwise.
isValue
(Object
the value whose open type is to be tested for compatibility with this CompositeType instance.
obj
)

Implements abstract javax.management.openmbean.OpenType.isValue.

Tests whether obj is a value which could be described by this CompositeType instance.

public Set<String>

Returns:

a Set of String.
keySet
()

Returns an unmodifiable Set view of all the item names defined by this CompositeType instance.

public String

Returns:

a string representation of this CompositeType instance
toString
()

Implements abstract javax.management.openmbean.OpenType.toString.

Returns a string representation of this CompositeType instance.

Inherited from javax.management.openmbean.OpenType:
getClassNamegetDescriptiongetDescriptorgetTypeNameisArraysafeGetClassName

Field Detail

myHashCodeback to summary
private transient Integer myHashCode
myNamesSetback to summary
private transient Set<String> myNamesSet
myToStringback to summary
private transient String myToString
nameToDescriptionback to summary
private TreeMap<String, String> nameToDescription
nameToTypeback to summary
private TreeMap<String, OpenType<?>> nameToType
serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides javax.management.openmbean.OpenType.serialVersionUID.

Constructor Detail

CompositeTypeback to summary
public CompositeType(String typeName, String description, String[] itemNames, String[] itemDescriptions, OpenType<?>[] itemTypes) throws OpenDataException

Constructs a CompositeType instance, checking for the validity of the given parameters. The validity constraints are described below for each parameter.

Note that the contents of the three array parameters itemNames, itemDescriptions and itemTypes are internally copied so that any subsequent modification of these arrays by the caller of this constructor has no impact on the constructed CompositeType instance.

The Java class name of composite data values this composite type represents (ie the class name returned by the getClassName method) is set to the string value returned by CompositeData.class.getName().

Parameters
typeName:String

The name given to the composite type this instance represents; cannot be a null or empty string.

description:String

The human readable description of the composite type this instance represents; cannot be a null or empty string.

itemNames:String[]

The names of the items contained in the composite data values described by this CompositeType instance; cannot be null and should contain at least one element; no element can be a null or empty string. Note that the order in which the item names are given is not important to differentiate a CompositeType instance from another; the item names are internally stored sorted in ascending alphanumeric order.

itemDescriptions:String[]

The descriptions, in the same order as itemNames, of the items contained in the composite data values described by this CompositeType instance; should be of the same size as itemNames; no element can be null or an empty string.

itemTypes:OpenType<?>[]

The open type instances, in the same order as itemNames, describing the items contained in the composite data values described by this CompositeType instance; should be of the same size as itemNames; no element can be null.

Exceptions
OpenDataException:
If itemNames contains duplicate item names (case sensitive, but leading and trailing whitespaces removed).
IllegalArgumentException:
If typeName or description is a null or empty string, or itemNames or itemDescriptions or itemTypes is null, or any element of itemNames or itemDescriptions is a null or empty string, or any element of itemTypes is null, or itemNames or itemDescriptions or itemTypes are not of the same size.

Method Detail

checkForEmptyStringback to summary
private static void checkForEmptyString(String[] arg, String argName)
checkForNullElementback to summary
private static void checkForNullElement(Object[] arg, String argName)
containsKeyback to summary
public boolean containsKey(String itemName)

Returns true if this CompositeType instance defines an item whose name is itemName.

Parameters
itemName:String

the name of the item.

Returns:boolean

true if an item of this name is present.

equalsback to summary
public boolean equals(Object obj)

Implements abstract javax.management.openmbean.OpenType.equals.

Compares the specified obj parameter with this CompositeType instance for equality.

Two CompositeType instances are equal if and only if all of the following statements are true:

  • their type names are equal
  • their items' names and types are equal
Parameters
obj:Object

the object to be compared for equality with this CompositeType instance; if obj is null, equals returns false.

Returns:boolean

true if the specified object is equal to this CompositeType instance.

getDescriptionback to summary
public String getDescription(String itemName)

Returns the description of the item whose name is itemName, or null if this CompositeType instance does not define any item whose name is itemName.

Parameters
itemName:String

the name of the item.

Returns:String

the description.

getTypeback to summary
public OpenType<?> getType(String itemName)

Returns the open type of the item whose name is itemName, or null if this CompositeType instance does not define any item whose name is itemName.

Parameters
itemName:String

the name of the time.

Returns:OpenType<?>

the type.

hashCodeback to summary
public int hashCode()

Implements abstract javax.management.openmbean.OpenType.hashCode.

Returns the hash code value for this CompositeType instance.

The hash code of a CompositeType instance is the sum of the hash codes of all elements of information used in equals comparisons (ie: name, items names, items types). This ensures that t1.equals(t2) implies that t1.hashCode()==t2.hashCode() for any two CompositeType instances t1 and t2, as required by the general contract of the method Object.hashCode().

As CompositeType instances are immutable, the hash code for this instance is calculated once, on the first call to hashCode, and then the same value is returned for subsequent calls.

Returns:int

the hash code value for this CompositeType instance

isAssignableFromback to summary
pack-priv boolean isAssignableFrom(OpenType<?> ot)

Overrides javax.management.openmbean.OpenType.isAssignableFrom.

Tests whether values of the given type can be assigned to this open type. The result is true if the given type is also a CompositeType with the same name (getTypeName()), and every item in this type is also present in the given type with the same name and assignable type. There can be additional items in the given type, which are ignored.

Parameters
ot:OpenType<?>

the type to be tested.

Returns:boolean

true if ot is assignable to this open type.

Annotations
@Override
isValueback to summary
public boolean isValue(Object obj)

Implements abstract javax.management.openmbean.OpenType.isValue.

Tests whether obj is a value which could be described by this CompositeType instance.

If obj is null or is not an instance of javax.management.openmbean.CompositeData, isValue returns false.

If obj is an instance of javax.management.openmbean.CompositeData, then let ct be its CompositeType as returned by CompositeData#getCompositeType(). The result is true if this is assignable from ct. This means that:

  • this.getTypeName() equals ct.getTypeName(), and
  • there are no item names present in this that are not also present in ct, and
  • for every item in this, its type is assignable from the type of the corresponding item in ct.

A TabularType is assignable from another TabularType if they have the same typeName and index name list, and the row type of the first is assignable from the row type of the second.

An ArrayType is assignable from another ArrayType if they have the same dimension; and both are primitive arrays or neither is; and the element type of the first is assignable from the element type of the second.

In every other case, an OpenType is assignable from another OpenType only if they are equal.

These rules mean that extra items can be added to a CompositeData without making it invalid for a CompositeType that does not have those items.

Parameters
obj:Object

the value whose open type is to be tested for compatibility with this CompositeType instance.

Returns:boolean

true if obj is a value for this composite type, false otherwise.

keySetback to summary
public Set<String> keySet()

Returns an unmodifiable Set view of all the item names defined by this CompositeType instance. The set's iterator will return the item names in ascending order.

Returns:Set<String>

a Set of String.

toStringback to summary
public String toString()

Implements abstract javax.management.openmbean.OpenType.toString.

Returns a string representation of this CompositeType instance.

The string representation consists of the name of this class (ie javax.management.openmbean.CompositeType), the type name for this instance, and the list of the items names and types string representation of this instance.

As CompositeType instances are immutable, the string representation for this instance is calculated once, on the first call to toString, and then the same value is returned for subsequent calls.

Returns:String

a string representation of this CompositeType instance