1. /*
  2. * @(#)file Descriptor.java
  3. * @(#)author IBM Corp.
  4. * @(#)version 1.23
  5. * @(#)lastedit 04/02/10
  6. */
  7. /*
  8. * Copyright IBM Corp. 1999-2000. All rights reserved.
  9. *
  10. * The program is provided "as is" without any warranty express or implied,
  11. * including the warranty of non-infringement and the implied warranties of
  12. * merchantibility and fitness for a particular purpose. IBM will not be
  13. * liable for any damages suffered by you or any third party claim against
  14. * you regarding the Program.
  15. *
  16. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  17. * This software is the proprietary information of Sun Microsystems, Inc.
  18. * Use is subject to license terms.
  19. *
  20. * Copyright 2004 Sun Microsystems, Inc. Tous droits reserves.
  21. * Ce logiciel est propriete de Sun Microsystems, Inc.
  22. * Distribue par des licences qui en restreignent l'utilisation.
  23. *
  24. */
  25. package javax.management;
  26. import javax.management.RuntimeOperationsException;
  27. import javax.management.MBeanException;
  28. import com.sun.jmx.trace.Trace;
  29. /**
  30. * This interface represents the behavioral metadata set for a JMX Element.
  31. * For examples, a descriptor is part of the ModelMBeanInfo, ModelMBeanNotificationInfo, ModelMBeanAttributeInfo,
  32. * ModelMBeanConstructorInfo, and ModelMBeanParameterInfo.
  33. * <P>
  34. * A descriptor consists of a collection of fields. Each field is in fieldname=fieldvalue format.
  35. * <P>
  36. * All field names and values are not predefined. New fields can be defined and added by any program.
  37. * In the case of ModelMBean some fields have been predefined for consistency of implementation and support by the ModelMBeanInfo
  38. * ModelMBean*Info, and ModelMBean classes.
  39. *<P>
  40. *
  41. * @since 1.5
  42. */
  43. public interface Descriptor extends java.io.Serializable, Cloneable
  44. {
  45. /**
  46. * Returns the value for a specific fieldname.
  47. *
  48. * @param fieldName The field name in question; if not found, null is returned.
  49. *
  50. * @return Object Field value.
  51. *
  52. * @exception RuntimeOperationsException for illegal value for field name.
  53. *
  54. */
  55. public Object getFieldValue(String fieldName)
  56. throws RuntimeOperationsException;
  57. /**
  58. * Sets the value for a specific fieldname. The field value will be validated before
  59. * it is set. If it is not valid, then an exception will be thrown. This will modify
  60. * an existing field or add a new field.
  61. *
  62. * @param fieldName The field name to be set. Cannot be null or empty.
  63. * @param fieldValue The field value to be set for the field
  64. * name. Can be null.
  65. *
  66. * @exception RuntimeOperationsException for illegal value for field name or field value.
  67. *
  68. */
  69. public void setField(String fieldName, Object fieldValue)
  70. throws RuntimeOperationsException;
  71. /**
  72. * Returns all of the fields contained in this descriptor as a string array.
  73. *
  74. * @return String array of fields in the format <i>fieldName=fieldValue</i>
  75. * If the value of a field is not a String, then the toString() method
  76. * will be called on it and the returned value used as the value for
  77. * the field in the returned array. Object values which are not Strings
  78. * will be enclosed in parentheses. If the descriptor is empty, you will get
  79. * an empty array.
  80. *
  81. * @see #setFields
  82. */
  83. public String[] getFields() ;
  84. /**
  85. * Returns all the fields names in the descriptor.
  86. *
  87. * @return String array of fields names. If the descriptor is empty, you will get
  88. * an empty array.
  89. *
  90. */
  91. public String[] getFieldNames() ;
  92. /**
  93. * Returns all the field values in the descriptor as an array of Objects. The
  94. * returned values are in the same order as the fieldNames String array parameter.
  95. *
  96. * @param fieldNames String array of the names of the fields that the values
  97. * should be returned for. If the array is empty then an empty array will be
  98. * returned. If the array is 'null' then all values will be returned. If a field
  99. * name in the array does not exist, then null is returned for the matching array
  100. * element being returned.
  101. *
  102. * @return Object array of field values. If the descriptor is empty, you will get
  103. * an empty array.
  104. *
  105. */
  106. public Object[] getFieldValues(String[] fieldNames) ;
  107. /**
  108. * Removes a field from the descriptor.
  109. *
  110. * @param fieldName String name of the field to be removed.
  111. * If the field is not found no exception is thrown.
  112. */
  113. public void removeField(String fieldName) ;
  114. /**
  115. * Sets all Fields in the list to the new value in with the same index
  116. * in the fieldValue array. Array sizes must match.
  117. * The field value will be validated before it is set.
  118. * If it is not valid, then an exception will be thrown.
  119. * If the arrays are empty, then no change will take effect.
  120. *
  121. * @param fieldNames String array of field names. The array and array elements cannot be null.
  122. * @param fieldValues Object array of the corresponding field values. The array cannot be null.
  123. * Elements of the array can be null.
  124. *
  125. * @exception RuntimeOperationsException for illegal value for field Names or field Values.
  126. * Neither can be null. The array lengths must be equal.
  127. * If the descriptor construction fails for any reason, this exception will be thrown.
  128. *
  129. * @see #getFields
  130. */
  131. public void setFields(String[] fieldNames, Object[] fieldValues)
  132. throws RuntimeOperationsException;
  133. /**
  134. * Returns a new Descriptor which is a duplicate of the Descriptor.
  135. *
  136. * @exception RuntimeOperationsException for illegal value for field Names or field Values.
  137. * If the descriptor construction fails for any reason, this exception will be thrown.
  138. */
  139. public Object clone() throws RuntimeOperationsException;
  140. /**
  141. * Returns true if all of the fields have legal values given their
  142. * names.
  143. *
  144. * @return true if the values are legal.
  145. *
  146. * @exception RuntimeOperationsException If the validity checking fails for any reason, this exception will be thrown.
  147. */
  148. public boolean isValid() throws RuntimeOperationsException;
  149. }