| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
DescriptorSupport descr = new DescriptorSupport();
Based on 17 examples
public class DescriptorSupport extends Object implements Descriptor
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
.
Constructor Summary | |
---|---|
Descriptor default constructor. |
|
DescriptorSupport(DescriptorSupport inDescr) Descriptor constructor taking a Descriptor as parameter. |
|
DescriptorSupport(int initNumFields) Descriptor constructor. |
|
DescriptorSupport(String inStr) Descriptor constructor taking an XML String. |
|
DescriptorSupport(String[] fields) Constructor taking fields in the fieldName=fieldValue format. |
|
DescriptorSupport(String[] fieldNames, Object[] fieldValues) Constructor taking field names and field values. |
Method Summary | |
---|---|
Object |
clone() Returns a new Descriptor which is a duplicate of the Descriptor. |
boolean |
Compares this descriptor to the given object. |
String[] |
|
String[] |
|
Object |
getFieldValue(String fieldName) |
Object[] |
getFieldValues(String[] fieldNames) |
int |
hashCode() Returns the hash code value for this descriptor. |
boolean |
isValid() Returns true if all of the fields have legal values given their names. |
void |
removeField(String fieldName) |
void |
|
void |
|
String |
toString() Returns |
String |
Returns an XML String representing the descriptor. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DescriptorSupport()
false
)
public DescriptorSupport(DescriptorSupport inDescr)
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.public DescriptorSupport(int initNumFields) throws MBeanException, RuntimeOperationsException
false
).
initNumFields
- The initial capacity of the Map that
stores the descriptor fields.MBeanException
- Wraps a distributed communication Exception.RuntimeOperationsException
- for illegal value for
initNumFields (<= 0)public DescriptorSupport(String inStr) throws MBeanException, RuntimeOperationsException, XMLParseException
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 {@link #toXMLString() 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 {@link #toXMLString toXMLString} on an existing
descriptor can be used to instantiate an equivalent
descriptor when instantiated using this constructor.MBeanException
- Wraps a distributed communication Exception.RuntimeOperationsException
- If the String inStr
passed in parameter is nullXMLParseException
- XML parsing problem while parsing
the input Stringpublic DescriptorSupport(String[] fields)
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 {@code =} character; for example if the String is {@code a=b=c} then the field name is {@code a} and its value is {@code b=c}.
public DescriptorSupport(String[] fieldNames, Object[] fieldValues) throws RuntimeOperationsException
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 {@link #isValid
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.Method Detail |
---|
public synchronized Object clone() throws RuntimeOperationsException
clone
in class Object
RuntimeOperationsException
- for illegal value for
field Names or field Values. If the descriptor construction
fails for any reason, this exception will be thrown.public synchronized boolean equals(Object o)
equals
in class Object
o
- the object to compare with.public synchronized String[] getFieldNames()
public synchronized String[] getFields()
public synchronized Object getFieldValue(String fieldName) throws RuntimeOperationsException
fieldName
RuntimeOperationsException
public synchronized Object[] getFieldValues(String[] fieldNames)
fieldNames
public synchronized int 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 {@code n} and value {@code v} is {@code n.toLowerCase().hashCode() ^ h}. Here {@code h} is the hash code of {@code v}, computed as follows:
hashCode
in class Object
public synchronized boolean isValid() throws RuntimeOperationsException
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.public synchronized void removeField(String fieldName)
fieldName
public synchronized void setField(String fieldName, Object fieldValue) throws RuntimeOperationsException
fieldName
fieldValue
RuntimeOperationsException
public synchronized void setFields(String[] fieldNames, Object[] fieldValues) throws RuntimeOperationsException
fieldNames
fieldValues
RuntimeOperationsException
public synchronized String toString()
toString
in class Object
public synchronized String toXMLString()
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 {@link #DescriptorSupport(String) 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>
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |