java.lang.Object | |
↳ | javax.management.modelmbean.DescriptorSupport |
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
.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Descriptor default constructor.
| |||||||||||
Descriptor constructor.
| |||||||||||
Descriptor constructor taking a Descriptor as parameter.
| |||||||||||
Descriptor constructor taking an XML String. | |||||||||||
Constructor taking field names and field values.
| |||||||||||
Constructor taking fields in the fieldName=fieldValue
format.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns a new Descriptor which is a duplicate of the Descriptor.
| |||||||||||
Compares this descriptor to the given object.
| |||||||||||
Returns all the field names in the descriptor.
| |||||||||||
Returns the value for a specific field name, or null if no value
is present for that name.
| |||||||||||
Returns all the field values in the descriptor as an array of Objects.
| |||||||||||
Returns all of the fields contained in this descriptor as a string array.
| |||||||||||
Returns the hash code value for this descriptor. | |||||||||||
Returns true if all of the fields have legal values given their
names.
| |||||||||||
Removes a field from the descriptor.
| |||||||||||
Sets the value for a specific field name. | |||||||||||
Sets all fields in the field names array to the new value with the same index in the field values array. | |||||||||||
Returns
| |||||||||||
Returns an XML String representing the descriptor. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
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
)
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
).
initNumFields | The initial capacity of the Map that stores the descriptor fields. |
---|
RuntimeOperationsException | for illegal value for initNumFields (<= 0) |
---|---|
MBeanException | Wraps a distributed communication Exception. |
Descriptor constructor taking a Descriptor as parameter. Creates a new descriptor initialized to the values of the descriptor passed in parameter.
inDescr | 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. |
---|
Descriptor constructor taking an XML String.
The format of the XML string is not defined, but an
implementation must ensure that the string returned by
toXMLString()
on an existing
descriptor can be used to instantiate an equivalent
descriptor using this constructor.
In this implementation, all field values will be created as Strings. If the field values are not Strings, the programmer will have to reset or convert these fields correctly.
inStr | An XML-formatted string used to populate this
Descriptor. The format is not defined, but any
implementation must ensure that the string returned by
method toXMLString on an existing
descriptor can be used to instantiate an equivalent
descriptor when instantiated using this constructor. |
---|
RuntimeOperationsException | If the String inStr passed in parameter is null |
---|---|
XMLParseException | XML parsing problem while parsing the input String |
MBeanException | Wraps a distributed communication Exception. |
Constructor taking field names and field values. Neither array can be null.
fieldNames | String array of field names. No elements of this array can be null. |
---|---|
fieldValues | 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. |
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. |
---|
Constructor taking fields in the fieldName=fieldValue format.
fields | 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 |
---|
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. |
---|
Returns a new Descriptor which is a duplicate of the Descriptor.
RuntimeOperationsException | for illegal value for field Names or field Values. If the descriptor construction fails for any reason, this exception will be thrown. |
---|
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:
Arrays.deepEquals
must return true.equals(Object)
must return true.o | the object to compare with. |
---|
true
if the objects are the same; false
otherwise.
Returns all the field names in the descriptor.
Returns the value for a specific field name, or null if no value is present for that name.
fieldName | the field name. |
---|
RuntimeOperationsException |
---|
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.
fieldNames | String array of the names of the fields that
the values should be returned for. If the array is empty then
an empty array will be returned. If the array is null then all
values will be returned, as if the parameter were the array
returned by getFieldNames() . If a field name in the
array does not exist, including the case where it is null or
the empty string, then null is returned for the matching array
element being returned. |
---|
fieldNames
is empty, you will get an empty array.
Returns all of the fields contained in this descriptor as a string array.
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:
v
is null then h
is 0.v
is a primitive array then h
is computed using
the appropriate overloading of java.util.Arrays.hashCode
.v
is an object array then h
is computed using
Arrays.deepHashCode
.h
is v.hashCode()
.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:
RuntimeOperationsException | If the validity checking fails for any reason, this exception will be thrown. |
---|
Removes a field from the descriptor.
fieldName | String name of the field to be removed. If the field name is illegal or the field is not found, no exception is thrown. |
---|
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.
fieldName | The field name to be set. Cannot be null or empty. |
---|---|
fieldValue | The field value to be set for the field name. Can be null if that is a valid value for the field. |
RuntimeOperationsException |
---|
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.
fieldNames | String array of field names. The array and array elements cannot be null. |
---|---|
fieldValues | Object array of the corresponding field values. The array cannot be null. Elements of the array can be null. |
RuntimeOperationsException |
---|
Returns
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.
RuntimeOperationsException | for illegal value for field Names or field Values. If the descriptor string fails for any reason, this exception will be thrown. |
---|
Returns an XML String representing the descriptor.
The format is not defined, but an implementation must
ensure that the string returned by this method can be
used to build an equivalent descriptor when instantiated
using the constructor DescriptorSupport(String inStr)
.
Fields which are not String objects will have toString() called on them to create the value. The value will be enclosed in parentheses. It is not guaranteed that you can reconstruct these objects unless they have been specifically set up to support toString() in a meaningful format and have a matching constructor that accepts a String in the same format.
If the descriptor is empty the following String is returned: <Descriptor></Descriptor>
RuntimeOperationsException | for illegal value for field Names or field Values. If the XML formatted string construction fails for any reason, this exception will be thrown. |
---|