| java.lang.Object javax.management.modelmbean.DescriptorSupport
DescriptorSupport | public class DescriptorSupport implements Descriptor(Code) | | 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 implmentation and support by the ModelMBeanInfo
ModelMBean*Info, and ModelMBean classes.
author: Young Yang |
Constructor Summary | |
public | DescriptorSupport() | public | DescriptorSupport(int initNumFields) Descriptor constructor. | public | DescriptorSupport(DescriptorSupport initDescriptor) Descriptor constructor taking a Descriptor as parameter.
Creates a new descriptor initialized to the values of the descriptor passed in parameter.
Parameters: initDescriptor - the descriptor to be used to initialize the constructed descriptor. | public | DescriptorSupport(String xmlString) Descriptor constructor taking an XML String. | public | DescriptorSupport(String fieldNames, Object fieldValues) Constructor taking field names and field values. | public | DescriptorSupport(String fields) Constructor taking fields in the fieldName=fieldValue format.
Parameters: 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. |
Method Summary | |
public Object | clone() Returns a new Descriptor which is a duplicate of the Descriptor. | public String[] | getFieldNames() Returns all the fields names in the descriptor.
String array of fields names. | public Object | getFieldValue(String fieldName) returns the string value for a specific fieldname
Parameters: fieldName - The field name in question; if not found, null is returned. | public Object[] | getFieldValues(String[] fieldNames) Returns all the field values in the descriptor as an array of Objects. | public String[] | getFields() Returns all the fields in the descriptor
String array of fields in the format fieldName=fieldValue. | public boolean | isValid() Returns true if fieldValues are checked to be sure they are legal for the fieldNames. | public static void | main(String[] args) | public void | removeField(String fieldName) | public void | setField(String fieldName, Object fieldValue) Sets the string value for a specific fieldname. | public 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. | public String | toString() | public String | toXMLString() |
DescriptorSupport | public DescriptorSupport()(Code) | | |
DescriptorSupport | public DescriptorSupport(int initNumFields) throws MBeanException, RuntimeOperationsException(Code) | | Descriptor constructor.
Takes as parameter the initial capacity of the Map that stores the descriptor fields.
Capacity will grow as needed.
Parameters: initNumFields - The initial capacity of the Map that stores the descriptor fields. exception: RuntimeOperationsException - for illegal value for maxNumFields ( <= 0) |
DescriptorSupport | public DescriptorSupport(DescriptorSupport initDescriptor)(Code) | | Descriptor constructor taking a Descriptor as parameter.
Creates a new descriptor initialized to the values of the descriptor passed in parameter.
Parameters: initDescriptor - the descriptor to be used to initialize the constructed descriptor. If it isnull or contains no descriptor fields, an empty Descriptor will be created. exception: RuntimeOperationsException - for illegal value for inDescr. inDescr cannot benull. If the descriptor fails for any reason, this exception will be thrown. |
DescriptorSupport | public DescriptorSupport(String xmlString) throws MBeanException, RuntimeOperationsException, XMLParseException(Code) | | Descriptor constructor taking an XML String. This method is part of this implementation
and not required by the JMX Specification
Parameters: xmlString - An XML-formatted string used to populate this Descriptor.The format will be:...All fields values will be created as Strings. If the field values are not Strings,the programmer will have to reset or convert these fields correctly. Fields which are notString objects will have toString() called on them to doCreate the value.You will not be able to reconstruct these objects unless they have been specifically setupto support toString() into a meaningfull format and have a matching constructor thataccepts a String in the same format. throws: MBeanException - throws: RuntimeOperationsException - throws: XMLParseException - |
DescriptorSupport | public DescriptorSupport(String fieldNames, Object fieldValues) throws RuntimeOperationsException(Code) | | Constructor taking field names and field values. The array and array elements cannot be null.
Parameters: fieldNames - String array of field names. No elements of this array can be null. Parameters: fieldValues - Object array of the corresponding field values.Elements of the array can be null. The fieldValue must be valid for the fieldName.Note: array sizes of parameters should match. If both arrays are null or empty, thenan empty descriptor is created. No exception is thrown. exception: RuntimeOperationsException - for illegal value for field URLName or field Values.The array lengths must be equal.If the descriptor construction fails for any reason, this exception will be thrown. |
DescriptorSupport | public DescriptorSupport(String fields)(Code) | | Constructor taking fields in the fieldName=fieldValue format.
Parameters: 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 stringsor empty strings will be ignored.Note: each string should be of the form fieldName=fieldValue,with no imbedded blanks or other punctuation. exception: RuntimeOperationsException - for illegal value for field URLName 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. |
getFieldNames | public String[] getFieldNames()(Code) | | Returns all the fields names in the descriptor.
String array of fields names. If the descriptor is empty, you will getan empty array. |
getFieldValue | public Object getFieldValue(String fieldName) throws RuntimeOperationsException(Code) | | returns the string value for a specific fieldname
Parameters: fieldName - The field name in question; if not found, null is returned. String Field value exception: RuntimeOperationsException - for illegal value (null or empty string) for field URLName. |
getFieldValues | public Object[] getFieldValues(String[] fieldNames)(Code) | | Returns all the field values in the descriptor as an array of Objects. The
retuned values are in the same order as the fieldNames String array parameter.
Parameters: fieldNames - String array of the names of the fields that the valuesshould be returned for. If the array is empty then an empty array will bereturned. If the array is 'null' then all values will be returned. If a fieldname in the array does not exist, then null is returned for the matching arrayelement being returned. Object array of field values. If the descriptor is empty, you will getan empty array. |
getFields | public String[] getFields()(Code) | | Returns all the fields in the descriptor
String array of fields in the format fieldName=fieldValue. If thereare no fields in the descriptor, then String[0] is returned. If a fieldValue is anobject then the toString() method is called on it and its returned value is usedas the value for the field enclosed in parens. exception: RuntimeOperationsException - for illegal value for field URLName or Values. |
isValid | public boolean isValid() throws RuntimeOperationsException(Code) | | Returns true if fieldValues are checked to be sure they are legal for the fieldNames.
This implementation returns false if:
name or descriptorType fields are null
class, role, getMethod and setMethod, if defined, must not be null
persistPeriod, currencyTimeLimit, lastUpdatedTimeStamp, lastReturnedTimeStamp
must numerics greater than -1.
iterable, log, export must be t, f, true, or false
visibility must be between 1 and 4
severity must be betwen 0 and 5
persistPolicy must be OnUpdate,OnTimer,NoMoreOftenThan,Always,or Never is must not
be case sensitive.
exception: RuntimeOperationsException - If the validity checking fails for any reason, this exception will be thrown. |
removeField | public void removeField(String fieldName)(Code) | | Removes a field from the descriptor
Parameters: fieldName - String name of the field to be removed.If the field is not found no exception is thrown. |
setField | public void setField(String fieldName, Object fieldValue) throws RuntimeOperationsException(Code) | | Sets the string value for a specific fieldname. The value must be valid for the field.
If the field does not exist, it is added. if it does exist, the value is replaced.
fieldName: 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. exception: RuntimeOperationsException - for illegal value for field URLName. |
setFields | public void setFields(String[] fieldNames, Object[] fieldValues) throws RuntimeOperationsException(Code) | | Sets all Fields in the list to the new value in with the same index
in the fieldValue 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.
Parameters: fieldNames - String array of field names. The array and array elements cannot be null. Parameters: fieldValues - Object array of the corresponding field values. The array cannot be null.Elements of the array can be null. exception: RuntimeOperationsException - for illegal value for field URLName or field Values.Niether can be null. The array lengths must be equal.If the descriptor construction fails for any reason, this exception will be thrown. |
|
|