javax.management
Interface Descriptor

All Superinterfaces:
java.lang.Cloneable, java.io.Serializable
All Known Implementing Classes:
DescriptorSupport (src)

public interface Descriptor
extends java.io.Serializable, java.lang.Cloneable

This interface defines behavioral and runtime metadata for ModelMBeans. A descriptor is a set of name-value pairs.

The DescriptorAccess (src) interface defines how to get and set Descriptors for a ModelMBean's metadata classes.

The implementation must implement the following constructors.

Descriptor() returns an empty descriptor.

Descriptor(Descriptor) returns a copy of the decriptor.

Descriptor(String[], Object[]) a constructor that verifies the field names include a descriptorType and that predefined fields contain valid values.

See Also:
DescriptorAccess (src) , ModelMBean (src)

Method Summary
 java.lang.Object clone()
          Returns a descriptor that is a duplicate of this one.
 java.lang.String[] getFieldNames()
          Retrieves all the field names in this descriptor.
 java.lang.String[] getFields()
          Retrieves all the fields in this descriptor.
 java.lang.Object getFieldValue(java.lang.String fieldName)
          Retrieves the value of a field.
 java.lang.Object[] getFieldValues(java.lang.String[] fieldNames)
          Retrieves all the field values for the passed field names.
 boolean isValid()
          Checks to see that this descriptor is valid.
 void removeField(java.lang.String fieldName)
          Remove a field from the descriptor.
 void setField(java.lang.String fieldName, java.lang.Object fieldValue)
          Sets the value of a field.
 void setFields(java.lang.String[] fieldNames, java.lang.Object[] fieldValues)
          Set multiple fields in this descriptor.
 

Method Detail

getFieldValue

public java.lang.Object getFieldValue(java.lang.String fieldName)
                               throws RuntimeOperationsException (src) 
Retrieves the value of a field.

Parameters:
fieldName - the name of the field.
Returns:
the value of the field.
Throws:
RuntimeOperationsException (src) - when the field name is not valid.

setField

public void setField(java.lang.String fieldName,
                     java.lang.Object fieldValue)
              throws RuntimeOperationsException (src) 
Sets the value of a field.

Parameters:
fieldName - the name of the field.
fieldValue - the value of the field.
Throws:
RuntimeOperationsException (src) - when the field name or value is not valid.

getFields

public java.lang.String[] getFields()
Retrieves all the fields in this descriptor. The format is fieldName=fieldValue for String values and fieldName=(fieldValue.toString()) for other value types.

Returns:
an array of fieldName=fieldValue strings.

getFieldNames

public java.lang.String[] getFieldNames()
Retrieves all the field names in this descriptor.

Returns:
an array of field name strings.

getFieldValues

public java.lang.Object[] getFieldValues(java.lang.String[] fieldNames)
Retrieves all the field values for the passed field names. The array of object values returned is in the same order as the field names passed to the method.

When a fieldName does not exist, the corresponding element of the returned array is null.

Parameters:
fieldNames - the array of field names to retrieve. Pass null to retrieve all fields.
Returns:
an array of field values.

removeField

public void removeField(java.lang.String fieldName)
Remove a field from the descriptor.

Parameters:
fieldName - the field to remove. No exception is thrown when the field is not in the descriptor.

setFields

public void setFields(java.lang.String[] fieldNames,
                      java.lang.Object[] fieldValues)
               throws RuntimeOperationsException (src) 
Set multiple fields in this descriptor. The field in the fieldNames array is set to the value of the corresponding fieldValues array. The two arrays must be the same size.

Parameters:
fieldNames - an array of fieldNames to set. Neither the array or array elements can be null. The fieldName must exist.
fieldValues - an array of fieldValues to set. Neither the array or array elements can be null. The fieldValue must be valid for the corresponding fieldName.
Throws:
RuntimeOperationsException (src) - for not existent or fieldNames, invalid or null fieldValues, the two arrays are different sizes or the contructor fails for any reason.

clone

public java.lang.Object clone()
                       throws RuntimeOperationsException (src) 
Returns a descriptor that is a duplicate of this one.

Throws:
RuntimeOperationsException (src) - for invalid fieldNames, fieldValues or the contructor fails for any reason.

isValid

public boolean isValid()
                throws RuntimeOperationsException (src) 
Checks to see that this descriptor is valid.

Returns:
true when the fieldValues are legal for the fieldNames, false otherwise.
Throws:
RuntimeOperationsException (src) - for any error performing the validation.