|
JavaTM 2 Platform Ent. Ed. v1.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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.
Constructor Summary | |
DescriptorSupport()
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. |
String[] |
getFieldNames()
Returns all the fields names in the descriptor. |
String[] |
getFields()
Returns all the fields in the descriptor. |
Object |
getFieldValue(String inFieldName)
Returns the value for a specific fieldname. |
Object[] |
getFieldValues(String[] fieldNames)
Returns all the field values in the descriptor as an array of Objects. |
boolean |
isValid()
Returns true if all of the fields have legal values given their names. |
void |
removeField(String fieldName)
Removes a field from the descriptor. |
void |
setField(String inFieldName,
Object fieldValue)
Sets the string value for a specific fieldname. |
void |
setFields(String[] fieldNames,
Object[] fieldValues)
Sets all Fields in the list to the new value in with the same index in the fieldValue array. |
String |
toString()
Returns |
String |
toXMLString()
Returns an XML String representing the descriptor. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public DescriptorSupport()
isValid
returns false
)
public DescriptorSupport(int initNumFields) throws MBeanException, RuntimeOperationsException
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.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(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
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.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 isValid
)
Note: array sizes of parameters should match. If both arrays are null or 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.public DescriptorSupport(String[] fields)
fields
- String array of 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 fields 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.
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 |
public Object getFieldValue(String inFieldName) throws RuntimeOperationsException
getFieldValue
in interface Descriptor
inFieldName
- The field name in question; if not found,
null is returned.
RuntimeOperationsException
- for illegal value (null
or empty string) for field Names.public void setField(String inFieldName, Object fieldValue) throws RuntimeOperationsException
isValid
). If the field does not exist, it is
added at the end of the Descriptor. If it does exist, the
value is replaced.
setField
in interface Descriptor
inFieldName
- The field name to be set. Must
not be null or empty string.fieldValue
- The field value to be set for the field
name. Can be null.
RuntimeOperationsException
- for illegal value for
field Names.public String[] getFields()
getFields
in interface Descriptor
setFields(java.lang.String[], java.lang.Object[])
public String[] getFieldNames()
getFieldNames
in interface Descriptor
public Object[] getFieldValues(String[] fieldNames)
getFieldValues
in interface Descriptor
fieldNames
- String array of the names of the fields that the values
should be returned for.public void setFields(String[] fieldNames, Object[] fieldValues) throws RuntimeOperationsException
isValid
)
If it is not valid, then an exception will be thrown.
If the arrays are empty, then no change will take effect.
setFields
in interface Descriptor
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
- for illegal value for field Names or field Values.
Neither can be null. The array lengths must be equal.getFields()
public Object clone() throws RuntimeOperationsException
clone
in interface Descriptor
RuntimeOperationsException
- for illegal value for field Names or field Values.
If the descriptor construction fails for any reason, this exception will be thrown.public void removeField(String fieldName)
removeField
in interface Descriptor
fieldName
- String name of the field to be removed.
If the field is not found no exception is thrown.public boolean isValid() throws RuntimeOperationsException
This implementation does not support interopreating 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:
isValid
in interface Descriptor
RuntimeOperationsException
- If the validity checking fails for any reason, this exception will be thrown.public 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 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 formated string
construction fails for any reason, this exception will be
thrown.public String toString()
RuntimeOperationsException
- for illegal value for field Names or field Values.
If the descriptor string fails for any reason, this exception will be thrown.
|
JavaTM 2 Platform Ent. Ed. v1.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 2003 Sun Microsystems, Inc. All rights reserved.