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

public Class DescriptorSupport

extends Object
implements Descriptor
Class Inheritance
All Implemented Interfaces
javax.management.Descriptor, java.lang.Cloneable, java.io.Serializable
Static Imports
com.sun.jmx.defaults.JmxProperties.MODELMBEAN_LOGGER, com.sun.jmx.mbeanserver.Util.cast

This class represents the metadata set for a ModelMBean element. A descriptor is part of the ModelMBeanInfo, ModelMBeanNotificationInfo, ModelMBeanAttributeInfo, ModelMBeanConstructorInfo, and ModelMBeanParameterInfo.

A descriptor consists of a collection of fields. Each field is in fieldname=fieldvalue format. Field names are not case sensitive, case will be preserved on field values.

All field names and values are not predefined. New fields can be defined and added by any program. Some fields have been predefined for consistency of implementation and support by the ModelMBeanInfo, ModelMBeanAttributeInfo, ModelMBeanConstructorInfo, ModelMBeanNotificationInfo, ModelMBeanOperationInfo and ModelMBean classes.

The serialVersionUID of this class is -6292969195866300415L.

Since
1.5

Field Summary

Modifier and TypeField and Description
private static final String
private transient SortedMap<String, Object>
private static final ObjectStreamField[]
private static final long

Constructor Summary

AccessConstructor and Description
public
DescriptorSupport()

Descriptor default constructor.

public
DescriptorSupport(int
The initial capacity of the Map that stores the descriptor fields.
initNumFields
)

Descriptor constructor.

public
DescriptorSupport(DescriptorSupport
the descriptor to be used to initialize the constructed descriptor. If it is null or contains no descriptor fields, an empty Descriptor will be created.
inDescr
)

Descriptor constructor taking a Descriptor as parameter.

public
DescriptorSupport(String[]
String array of field names. No elements of this array can be null.
fieldNames
,
Object[]
Object array of the corresponding field values. Elements of the array can be null. The fieldValue must be valid for the fieldName (as defined in method isValid)

Note

array sizes of parameters should match. If both arrays are empty, then an empty descriptor is created.

fieldValues
)

Constructor taking field names and field values.

public
DescriptorSupport(String...
String array with each element containing a field name and value. If this array is null or empty, then the default constructor will be executed. Null strings or empty strings will be ignored.

All field values should be Strings. If the field values are not Strings, the programmer will have to reset or convert these fields correctly.

Note

Each string should be of the form fieldName=fieldValue. The field name ends at the first = character; for example if the String is a=b=c then the field name is a and its value is b=c.

fields
)

Constructor taking fields in the fieldName=fieldValue format.

Method Summary

Modifier and TypeMethod and Description
public synchronized Object
clone()

Overrides java.lang.Object.clone.

Implements javax.management.Descriptor.clone.

Returns a new Descriptor which is a duplicate of the Descriptor.

public synchronized boolean
equals(Object o)

Overrides java.lang.Object.equals.

Implements javax.management.Descriptor.equals.

Compares this descriptor to the given object.

public synchronized String[]
getFieldNames()

Implements javax.management.Descriptor.getFieldNames.

Returns all the field names in the descriptor.

public synchronized String[]
getFields()

Implements javax.management.Descriptor.getFields.

Returns all of the fields contained in this descriptor as a string array.

public synchronized Object
getFieldValue(String fieldName)

Implements javax.management.Descriptor.getFieldValue.

Returns the value for a specific field name, or null if no value is present for that name.

public synchronized Object[]
getFieldValues(String... fieldNames)

Implements javax.management.Descriptor.getFieldValues.

Returns all the field values in the descriptor as an array of Objects.

public synchronized int
hashCode()

Overrides java.lang.Object.hashCode.

Implements javax.management.Descriptor.hashCode.

Returns the hash code value for this descriptor.

private void
init(Map<String, ?> initMap)

public synchronized boolean
isValid()

Implements javax.management.Descriptor.isValid.

Returns true if all of the fields have legal values given their names.

private void
public synchronized void
removeField(String fieldName)

Implements javax.management.Descriptor.removeField.

Removes a field from the descriptor.

public synchronized void
setField(String fieldName, Object fieldValue)

Implements javax.management.Descriptor.setField.

Sets the value for a specific field name.

public synchronized void
setFields(String[] fieldNames, Object[] fieldValues)

Implements javax.management.Descriptor.setFields.

Sets all fields in the field names array to the new value with the same index in the field values array.

private long
public synchronized String
toString()

Overrides java.lang.Object.toString.

Returns a human readable string representing the descriptor.

private boolean
validateField(String fldName, Object fldValue)

private void
Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

currClassback to summary
private static final String currClass
descriptorMapback to summary
private transient SortedMap<String, Object> descriptorMap
serialPersistentFieldsback to summary
private static final ObjectStreamField[] serialPersistentFields
Serial Fields:
descriptor:HashMap
The collection of fields representing this descriptor
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

DescriptorSupportback to summary
public DescriptorSupport()

Descriptor default constructor. Default initial descriptor size is 20. It will grow as needed.
Note that the created empty descriptor is not a valid descriptor (the method isValid returns false)

DescriptorSupportback to summary
public DescriptorSupport(int initNumFields) throws MBeanException, RuntimeOperationsException

Descriptor constructor. Takes as parameter the initial capacity of the Map that stores the descriptor fields. Capacity will grow as needed.
Note that the created empty descriptor is not a valid descriptor (the method isValid returns false).

Parameters
initNumFields:int

The initial capacity of the Map that stores the descriptor fields.

Exceptions
MBeanException:
Wraps a distributed communication Exception.
RuntimeOperationsException:
for illegal value for initNumFields (<= 0)
DescriptorSupportback to summary
public DescriptorSupport(DescriptorSupport inDescr)

Descriptor constructor taking a Descriptor as parameter. Creates a new descriptor initialized to the values of the descriptor passed in parameter.

Parameters
inDescr:DescriptorSupport

the descriptor to be used to initialize the constructed descriptor. If it is null or contains no descriptor fields, an empty Descriptor will be created.

DescriptorSupportback to summary
public DescriptorSupport(String[] fieldNames, Object[] fieldValues) throws RuntimeOperationsException

Constructor taking field names and field values. Neither array can be null.

Parameters
fieldNames:String[]

String array of field names. No elements of this array can be null.

fieldValues:Object[]

Object array of the corresponding field values. Elements of the array can be null. The fieldValue must be valid for the fieldName (as defined in method isValid)

Note

array sizes of parameters should match. If both arrays are empty, then an empty descriptor is created.

Exceptions
RuntimeOperationsException:
for illegal value for field Names or field Values. The array lengths must be equal. If the descriptor construction fails for any reason, this exception will be thrown.
DescriptorSupportback to summary
public DescriptorSupport(String... fields)

Constructor taking fields in the fieldName=fieldValue format.

Parameters
fields:String[]

String array with each element containing a field name and value. If this array is null or empty, then the default constructor will be executed. Null strings or empty strings will be ignored.

All field values should be Strings. If the field values are not Strings, the programmer will have to reset or convert these fields correctly.

Note

Each string should be of the form fieldName=fieldValue. The field name ends at the first = character; for example if the String is a=b=c then the field name is a and its value is b=c.

Exceptions
RuntimeOperationsException:
for illegal value for field Names or field Values. The field must contain an "=". "=fieldValue", "fieldName", and "fieldValue" are illegal. FieldName cannot be null. "fieldName=" will cause the value to be null. If the descriptor construction fails for any reason, this exception will be thrown.

Method Detail

cloneback to summary
public synchronized Object clone() throws RuntimeOperationsException

Overrides java.lang.Object.clone.

Implements javax.management.Descriptor.clone.

Returns a new Descriptor which is a duplicate of the Descriptor.

Annotations
@Override
Exceptions
RuntimeOperationsException:
for illegal value for field Names or field Values. If the descriptor construction fails for any reason, this exception will be thrown.
equalsback to summary
public synchronized boolean equals(Object o)

Overrides java.lang.Object.equals.

Implements javax.management.Descriptor.equals.

Doc from javax.management.Descriptor.equals.

Compares this descriptor to the given object. The objects are equal if the given object is also a Descriptor, and if the two Descriptors have the same field names (possibly differing in case) and the same associated values. The respective values for a field in the two Descriptors are equal if the following conditions hold:

  • If one value is null then the other must be too.
  • If one value is a primitive array then the other must be a primitive array of the same type with the same elements.
  • If one value is an object array then the other must be too and Arrays#deepEquals(Object[], Object[]) must return true.
  • Otherwise Object#equals(Object) must return true.
Annotations
@Override
getFieldNamesback to summary
public synchronized String[] getFieldNames()

Implements javax.management.Descriptor.getFieldNames.

Doc from javax.management.Descriptor.getFieldNames.

Returns all the field names in the descriptor.

getFieldsback to summary
public synchronized String[] getFields()

Implements javax.management.Descriptor.getFields.

Doc from javax.management.Descriptor.getFields.

Returns all of the fields contained in this descriptor as a string array.

getFieldValueback to summary
public synchronized Object getFieldValue(String fieldName) throws RuntimeOperationsException

Implements javax.management.Descriptor.getFieldValue.

Doc from javax.management.Descriptor.getFieldValue.

Returns the value for a specific field name, or null if no value is present for that name.

Exceptions
RuntimeOperationsException:
if the field name is illegal.
getFieldValuesback to summary
public synchronized Object[] getFieldValues(String... fieldNames)

Implements javax.management.Descriptor.getFieldValues.

Doc from javax.management.Descriptor.getFieldValues.

Returns all the field values in the descriptor as an array of Objects. The returned values are in the same order as the fieldNames String array parameter.

hashCodeback to summary
public synchronized int hashCode()

Overrides java.lang.Object.hashCode.

Implements javax.management.Descriptor.hashCode.

Doc from javax.management.Descriptor.hashCode.

Returns the hash code value for this descriptor. The hash code is computed as the sum of the hash codes for each field in the descriptor. The hash code of a field with name n and value v is n.toLowerCase().hashCode() ^ h. Here h is the hash code of v, computed as follows:

  • If v is null then h is 0.
  • If v is a primitive array then h is computed using the appropriate overloading of java.util.Arrays.hashCode.
  • If v is an object array then h is computed using Arrays#deepHashCode(Object[]).
  • Otherwise h is v.hashCode().
Annotations
@Override
initback to summary
private void init(Map<String, ?> initMap)
isValidback to summary
public synchronized boolean isValid() throws RuntimeOperationsException

Implements javax.management.Descriptor.isValid.

Returns true if all of the fields have legal values given their names.

This implementation does not support interoperating with a directory or lookup service. Thus, conforming to the specification, no checking is done on the "export" field.

Otherwise this implementation returns false if:

  • name and descriptorType fieldNames are not defined, or null, or empty, or not String
  • class, role, getMethod, setMethod fieldNames, if defined, are null or not String
  • persistPeriod, currencyTimeLimit, lastUpdatedTimeStamp, lastReturnedTimeStamp if defined, are null, or not a Numeric String or not a Numeric Value >= -1
  • log fieldName, if defined, is null, or not a Boolean or not a String with value "t", "f", "true", "false". These String values must not be case sensitive.
  • visibility fieldName, if defined, is null, or not a Numeric String or a not Numeric Value >= 1 and <= 4
  • severity fieldName, if defined, is null, or not a Numeric String or not a Numeric Value >= 0 and <= 6
  • persistPolicy fieldName, if defined, is null, or not one of the following strings:
    "OnUpdate", "OnTimer", "NoMoreOftenThan", "OnUnregister", "Always", "Never". These String values must not be case sensitive.
Exceptions
RuntimeOperationsException:
If the validity checking fails for any reason, this exception will be thrown.
readObjectback to summary
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException

Deserializes a DescriptorSupport from an ObjectInputStream.

removeFieldback to summary
public synchronized void removeField(String fieldName)

Implements javax.management.Descriptor.removeField.

Doc from javax.management.Descriptor.removeField.

Removes a field from the descriptor.

setFieldback to summary
public synchronized void setField(String fieldName, Object fieldValue) throws RuntimeOperationsException

Implements javax.management.Descriptor.setField.

Doc from javax.management.Descriptor.setField.

Sets the value for a specific field name. This will modify an existing field or add a new field.

The field value will be validated before it is set. If it is not valid, then an exception will be thrown. The meaning of validity is dependent on the descriptor implementation.

Exceptions
RuntimeOperationsException:
if the field name or field value is illegal (wrapped exception is IllegalArgumentException); or if the descriptor is immutable (wrapped exception is UnsupportedOperationException).
setFieldsback to summary
public synchronized void setFields(String[] fieldNames, Object[] fieldValues) throws RuntimeOperationsException

Implements javax.management.Descriptor.setFields.

Doc from javax.management.Descriptor.setFields.

Sets all fields in the field names array to the new value with the same index in the field values array. Array sizes must match.

The field value will be validated before it is set. If it is not valid, then an exception will be thrown. If the arrays are empty, then no change will take effect.

Exceptions
RuntimeOperationsException:
if the change fails for any reason. Wrapped exception is IllegalArgumentException if fieldNames or fieldValues is null, or if the arrays are of different lengths, or if there is an illegal value in one of them. Wrapped exception is UnsupportedOperationException if the descriptor is immutable, and the call would change its contents.
toNumericback to summary
private long toNumeric(String inStr)
toStringback to summary
public synchronized String toString()

Overrides java.lang.Object.toString.

Returns a human readable string representing the descriptor. The string will be in the format of "fieldName=fieldValue,fieldName2=fieldValue2,..."
If there are no fields in the descriptor, then an empty String is returned.
If a fieldValue is an object then the toString() method is called on it and its returned value is used as the value for the field enclosed in parenthesis.

Annotations
@Override
Exceptions
RuntimeOperationsException:
for illegal value for field Names or field Values. If the descriptor string fails for any reason, this exception will be thrown.
validateFieldback to summary
private boolean validateField(String fldName, Object fldValue)
writeObjectback to summary
private void writeObject(ObjectOutputStream out) throws IOException

Serializes a DescriptorSupport to an ObjectOutputStream.