Path: blob/master/src/java.management/share/classes/javax/management/Descriptor.java
41155 views
/*1* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24/*25* @author IBM Corp.26*27* Copyright IBM Corp. 1999-2000. All rights reserved.28*/2930package javax.management;3132import java.io.Serializable;3334// Javadoc imports:35import java.lang.management.MemoryUsage;36import java.util.Arrays;37import java.util.Locale;38import java.util.ResourceBundle;39import javax.management.openmbean.CompositeData;40import javax.management.openmbean.OpenMBeanAttributeInfoSupport;41import javax.management.openmbean.OpenMBeanOperationInfoSupport;42import javax.management.openmbean.OpenMBeanParameterInfoSupport;43import javax.management.openmbean.OpenType;4445/**46* <p>Additional metadata for a JMX element. A {@code Descriptor}47* is associated with a {@link MBeanInfo}, {@link MBeanAttributeInfo}, etc.48* It consists of a collection of fields. A field is a name and an49* associated value.</p>50*51* <p>Field names are not case-sensitive. The names {@code descriptorType},52* {@code descriptortype}, and {@code DESCRIPTORTYPE} are all equivalent.53* However, the case that was used when the field was first set is preserved54* in the result of the {@link #getFields} and {@link #getFieldNames}55* methods.</p>56*57* <p>Not all field names and values are predefined.58* New fields can be defined and added by any program.</p>59*60* <p>A descriptor can be mutable or immutable.61* An immutable descriptor, once created, never changes.62* The <code>Descriptor</code> methods that could modify the contents63* of the descriptor will throw an exception64* for an immutable descriptor. Immutable descriptors are usually65* instances of {@link ImmutableDescriptor} or a subclass. Mutable66* descriptors are usually instances of67* {@link javax.management.modelmbean.DescriptorSupport} or a subclass.68*69* <p>Certain fields are used by the JMX implementation. This means70* either that the presence of the field may change the behavior of71* the JMX API or that the field may be set in descriptors returned by72* the JMX API. These fields appear in <i>italics</i> in the table73* below, and each one has a corresponding constant in the {@link JMX}74* class. For example, the field {@code defaultValue} is represented75* by the constant {@link JMX#DEFAULT_VALUE_FIELD}.</p>76*77* <p>Certain other fields have conventional meanings described in the78* table below but they are not required to be understood or set by79* the JMX implementation.</p>80*81* <p>Field names defined by the JMX specification in this and all82* future versions will never contain a period (.). Users can safely83* create their own fields by including a period in the name and be84* sure that these names will not collide with any future version of85* the JMX API. It is recommended to follow the Java package naming86* convention to avoid collisions between field names from different87* origins. For example, a field created by {@code example.com} might88* have the name {@code com.example.interestLevel}.</p>89*90* <p>Note that the values in the {@code defaultValue}, {@code91* legalValues}, {@code maxValue}, and {@code minValue} fields should92* be consistent with the type returned by the {@code getType()}93* method for the associated {@code MBeanAttributeInfo} or {@code94* MBeanParameterInfo}. For MXBeans, this means that they should be95* of the mapped Java type, called <em>opendata</em>(J) in the <a96* href="MXBean.html#mapping-rules">MXBean type mapping rules</a>.</p>97*98* <table class="striped">99* <caption style="display:none">Descriptor Fields</caption>100* <thead>101* <tr><th scope="col">Name</th>102* <th scope="col">Type</th>103* <th scope="col">Used in</th>104* <th scope="col">Meaning</th></tr>105* </thead>106*107* <tbody style="text-align:left">108* <tr id="defaultValue"><th scope="row"><i>defaultValue</i><td>Object</td>109* <td>MBeanAttributeInfo<br>MBeanParameterInfo</td>110*111* <td>Default value for an attribute or parameter. See112* {@link javax.management.openmbean}.</td>113*114* <tr><th scope="row">deprecated</th><td>String</td><td>Any</td>115*116* <td>An indication that this element of the information model is no117* longer recommended for use. A set of MBeans defined by an118* application is collectively called an <em>information model</em>.119* The convention is for the value of this field to contain a string120* that is the version of the model in which the element was first121* deprecated, followed by a space, followed by an explanation of the122* deprecation, for example {@code "1.3 Replaced by the Capacity123* attribute"}.</td>124*125* <tr><th scope="row" id="descriptionResourceBundleBaseName">descriptionResource<br>126* BundleBaseName</th><td>String</td><td>Any</td>127*128* <td>The base name for the {@link ResourceBundle} in which the key given in129* the {@code descriptionResourceKey} field can be found, for example130* {@code "com.example.myapp.MBeanResources"}. The meaning of this131* field is defined by this specification but the field is not set or132* used by the JMX API itself.</td>133*134* <tr><th scope="row" id="descriptionResourceKey">descriptionResourceKey</th>135* <td>String</td><td>Any</td>136*137* <td>A resource key for the description of this element. In138* conjunction with the {@code descriptionResourceBundleBaseName},139* this can be used to find a localized version of the description.140* The meaning of this field is defined by this specification but the141* field is not set or used by the JMX API itself.</td>142*143* <tr><th scope="row">enabled</th><td>String</td>144* <td>MBeanAttributeInfo<br>MBeanNotificationInfo<br>MBeanOperationInfo</td>145*146* <td>The string {@code "true"} or {@code "false"} according as this147* item is enabled. When an attribute or operation is not enabled, it148* exists but cannot currently be accessed. A user interface might149* present it as a greyed-out item. For example, an attribute might150* only be meaningful after the {@code start()} method of an MBean has151* been called, and is otherwise disabled. Likewise, a notification152* might be disabled if it cannot currently be emitted but could be in153* other circumstances.</td>154*155* <tr id="exceptions"><th scope="row">exceptions<td>String[]</td>156* <td>MBeanAttributeInfo, MBeanConstructorInfo, MBeanOperationInfo</td>157*158* <td>The class names of the exceptions that can be thrown when invoking a159* constructor or operation, or getting an attribute. The meaning of this field160* is defined by this specification but the field is not set or used by the161* JMX API itself. Exceptions thrown when162* setting an attribute are specified by the field163* <a href="#setExceptions">{@code setExceptions}</a>.164*165* <tr id="immutableInfo"><th scope="row"><i>immutableInfo</i><td>String</td>166* <td>MBeanInfo</td>167*168* <td>The string {@code "true"} or {@code "false"} according as this169* MBean's MBeanInfo is <em>immutable</em>. When this field is true,170* the MBeanInfo for the given MBean is guaranteed not to change over171* the lifetime of the MBean. Hence, a client can read it once and172* cache the read value. When this field is false or absent, there is173* no such guarantee, although that does not mean that the MBeanInfo174* will necessarily change. See also the <a175* href="MBeanInfo.html#info-changed">{@code "jmx.mbean.info.changed"}</a>176* notification.</td>177*178* <tr id="infoTimeout"><th scope="row">infoTimeout</th><td>String<br>Long</td><td>MBeanInfo</td>179*180* <td>The time in milli-seconds that the MBeanInfo can reasonably be181* expected to be unchanged. The value can be a {@code Long} or a182* decimal string. This provides a hint from a DynamicMBean or any183* MBean that does not define {@code immutableInfo} as {@code true}184* that the MBeanInfo is not likely to change within this period and185* therefore can be cached. When this field is missing or has the186* value zero, it is not recommended to cache the MBeanInfo unless it187* has the {@code immutableInfo} set to {@code true} or it has <a188* href="MBeanInfo.html#info-changed">{@code "jmx.mbean.info.changed"}</a> in189* its {@link MBeanNotificationInfo} array.</td></tr>190*191* <tr id="interfaceClassName"><th scope="row"><i>interfaceClassName</i></th>192* <td>String</td><td>MBeanInfo</td>193*194* <td>The Java interface name for a Standard MBean or MXBean, as195* returned by {@link Class#getName()}. A Standard MBean or MXBean196* registered directly in the MBean Server or created using the {@link197* StandardMBean} class will have this field in its MBeanInfo198* Descriptor.</td>199*200* <tr id="legalValues"><th scope="row"><i>legalValues</i></th>201* <td>{@literal Set<?>}</td><td>MBeanAttributeInfo<br>MBeanParameterInfo</td>202*203* <td>Legal values for an attribute or parameter. See204* {@link javax.management.openmbean}.</td>205*206* <tr id="locale"><th scope="row">locale</th>207* <td>String</td><td>Any</td>208*209* <td>The {@linkplain Locale locale} of the description in this210* {@code MBeanInfo}, {@code MBeanAttributeInfo}, etc, as returned211* by {@link Locale#toString()}.</td>212*213* <tr id="maxValue"><th scope="row"><i>maxValue</i><td>Object</td>214* <td>MBeanAttributeInfo<br>MBeanParameterInfo</td>215*216* <td>Maximum legal value for an attribute or parameter. See217* {@link javax.management.openmbean}.</td>218*219* <tr id="metricType"><th scope="row">metricType</th><td>String</td>220* <td>MBeanAttributeInfo<br>MBeanOperationInfo</td>221*222* <td>The type of a metric, one of the strings "counter" or "gauge".223* A metric is a measurement exported by an MBean, usually an224* attribute but sometimes the result of an operation. A metric that225* is a <em>counter</em> has a value that never decreases except by226* being reset to a starting value. Counter metrics are almost always227* non-negative integers. An example might be the number of requests228* received. A metric that is a <em>gauge</em> has a numeric value229* that can increase or decrease. Examples might be the number of230* open connections or a cache hit rate or a temperature reading.231*232* <tr id="minValue"><th scope="row"><i>minValue</i><td>Object</td>233* <td>MBeanAttributeInfo<br>MBeanParameterInfo</td>234*235* <td>Minimum legal value for an attribute or parameter. See236* {@link javax.management.openmbean}.</td>237*238* <tr id="mxbean"><th scope="row"><i>mxbean</i><td>String</td>239* <td>MBeanInfo</td>240*241* <td>The string {@code "true"} or {@code "false"} according as this242* MBean is an {@link MXBean}. A Standard MBean or MXBean registered243* directly with the MBean Server or created using the {@link244* StandardMBean} class will have this field in its MBeanInfo245* Descriptor.</td>246*247* <tr id="openType"><th scope="row"><i>openType</i><td>{@link OpenType}</td>248* <td>MBeanAttributeInfo<br>MBeanOperationInfo<br>MBeanParameterInfo</td>249*250* <td><p>The Open Type of this element. In the case of {@code251* MBeanAttributeInfo} and {@code MBeanParameterInfo}, this is the252* Open Type of the attribute or parameter. In the case of {@code253* MBeanOperationInfo}, it is the Open Type of the return value. This254* field is set in the Descriptor for all instances of {@link255* OpenMBeanAttributeInfoSupport}, {@link256* OpenMBeanOperationInfoSupport}, and {@link257* OpenMBeanParameterInfoSupport}. It is also set for attributes,258* operations, and parameters of MXBeans.</p>259*260* <p>This field can be set for an {@code MBeanNotificationInfo}, in261* which case it indicates the Open Type that the {@link262* Notification#getUserData() user data} will have.</td>263*264* <tr id="originalType"><th scope="row"><i>originalType</i><td>String</td>265* <td>MBeanAttributeInfo<br>MBeanOperationInfo<br>MBeanParameterInfo</td>266*267* <td><p>The original Java type of this element as it appeared in the268* {@link MXBean} interface method that produced this {@code269* MBeanAttributeInfo} (etc). For example, a method<br> <code>public270* </code> {@link MemoryUsage}<code> getHeapMemoryUsage();</code><br>271* in an MXBean interface defines an attribute called {@code272* HeapMemoryUsage} of type {@link CompositeData}. The {@code273* originalType} field in the Descriptor for this attribute will have274* the value {@code "java.lang.management.MemoryUsage"}.275*276* <p>The format of this string is described in the section <a277* href="MXBean.html#type-names">Type Names</a> of the MXBean278* specification.</p>279*280* <tr id="setExceptions"><th scope="row"><i>setExceptions</i><td>String[]</td>281* <td>MBeanAttributeInfo</td>282*283* <td>The class names of the exceptions that can be thrown when setting284* an attribute. The meaning of this field285* is defined by this specification but the field is not set or used by the286* JMX API itself. Exceptions thrown when getting an attribute are specified287* by the field <a href="#exceptions">{@code exceptions}</a>.288*289* <tr><th scope="row">severity</th><td>String<br>Integer</td>290* <td>MBeanNotificationInfo</td>291*292* <td>The severity of this notification. It can be 0 to mean293* unknown severity or a value from 1 to 6 representing decreasing294* levels of severity. It can be represented as a decimal string or295* an {@code Integer}.</td>296*297* <tr><th scope="row">since</th><td>String</td><td>Any</td>298*299* <td>The version of the information model in which this element300* was introduced. A set of MBeans defined by an application is301* collectively called an <em>information model</em>. The302* application may also define versions of this model, and use the303* {@code "since"} field to record the version in which an element304* first appeared.</td>305*306* <tr><th scope="row">units</th><td>String</td>307* <td>MBeanAttributeInfo<br>MBeanParameterInfo<br>MBeanOperationInfo</td>308*309* <td>The units in which an attribute, parameter, or operation return310* value is measured, for example {@code "bytes"} or {@code311* "seconds"}.</td>312*313* </tbody>314* </table>315*316* <p>Some additional fields are defined by Model MBeans. See the317* information for <a href="modelmbean/ModelMBeanInfo.html#descriptor"><!--318* -->{@code ModelMBeanInfo}</a>,319* <a href="modelmbean/ModelMBeanAttributeInfo.html#descriptor"><!--320* -->{@code ModelMBeanAttributeInfo}</a>,321* <a href="modelmbean/ModelMBeanConstructorInfo.html#descriptor"><!--322* -->{@code ModelMBeanConstructorInfo}</a>,323* <a href="modelmbean/ModelMBeanNotificationInfo.html#descriptor"><!--324* -->{@code ModelMBeanNotificationInfo}</a>, and325* <a href="modelmbean/ModelMBeanOperationInfo.html#descriptor"><!--326* -->{@code ModelMBeanOperationInfo}</a>, as327* well as the chapter "Model MBeans" of the <a328* href="http://www.oracle.com/technetwork/java/javase/tech/javamanagement-140525.html">JMX329* Specification</a>. The following table summarizes these fields. Note330* that when the Type in this table is Number, a String that is the decimal331* representation of a Long can also be used.</p>332*333* <p>Nothing prevents the use of these fields in MBeans that are not Model334* MBeans. The <a href="#displayName">displayName</a>, <a href="#severity"><!--335* -->severity</a>, and <a href="#visibility">visibility</a> fields are of336* interest outside Model MBeans, for example. But only Model MBeans have337* a predefined behavior for these fields.</p>338*339* <table class="striped">340* <caption style="display:none">ModelMBean Fields</caption>341*342* <thead>343* <tr><th scope="col">Name</th>344* <th scope="col">Type</th>345* <th scope="col">Used in</th>346* <th scope="col">Meaning</th></tr>347* </thead>348*349* <tbody style="text-align:left">350* <tr><th scope="row">class</th><td>String</td><td>ModelMBeanOperationInfo</td>351* <td>Class where method is defined (fully qualified).</td></tr>352*353* <tr><th scope="row">currencyTimeLimit</th><td>Number</td>354* <td>ModelMBeanInfo<br>ModelMBeanAttributeInfo<br>ModelMBeanOperationInfo</td>355* <td>How long cached value is valid: <0 never, =0 always,356* >0 seconds.</td></tr>357*358* <tr><th scope="row">default</th><td>Object</td><td>ModelMBeanAttributeInfo</td>359* <td>Default value for attribute.</td></tr>360*361* <tr><th scope="row">descriptorType</th><td>String</td><td>Any</td>362* <td>Type of descriptor, "mbean", "attribute", "constructor", "operation",363* or "notification".</td></tr>364*365* <tr id="displayName"><th scope="row">displayName</th><td>String</td><td>Any</td>366* <td>Human readable name of this item.</td></tr>367*368* <tr><th scope="row">export</th><td>String</td><td>ModelMBeanInfo</td>369* <td>Name to be used to export/expose this MBean so that it is370* findable by other JMX Agents.</td></tr>371*372* <tr><th scope="row">getMethod</th><td>String</td><td>ModelMBeanAttributeInfo</td>373* <td>Name of operation descriptor for get method.</td></tr>374*375* <tr><th scope="row">lastUpdatedTimeStamp</th><td>Number</td>376* <td>ModelMBeanAttributeInfo<br>ModelMBeanOperationInfo</td>377* <td>When <a href="#value-field">value</a> was set.</td></tr>378*379* <tr><th scope="row">log</th><td>String</td><td>ModelMBeanInfo<br>ModelMBeanNotificationInfo</td>380* <td>t or T: log all notifications, f or F: log no notifications.</td></tr>381*382* <tr><th scope="row">logFile</th><td>String</td><td>ModelMBeanInfo<br>ModelMBeanNotificationInfo</td>383* <td>Fully qualified filename to log events to.</td></tr>384*385* <tr><th scope="row">messageID</th><td>String</td><td>ModelMBeanNotificationInfo</td>386* <td>Unique key for message text (to allow translation, analysis).</td></tr>387*388* <tr><th scope="row">messageText</th><td>String</td><td>ModelMBeanNotificationInfo</td>389* <td>Text of notification.</td></tr>390*391* <tr><th scope="row">name</th><td>String</td><td>Any</td>392* <td>Name of this item.</td></tr>393*394* <tr><th scope="row">persistFile</th><td>String</td><td>ModelMBeanInfo</td>395* <td>File name into which the MBean should be persisted.</td></tr>396*397* <tr><th scope="row">persistLocation</th><td>String</td><td>ModelMBeanInfo</td>398* <td>The fully qualified directory name where the MBean should be399* persisted (if appropriate).</td></tr>400*401* <tr><th scope="row">persistPeriod</th><td>Number</td>402* <td>ModelMBeanInfo<br>ModelMBeanAttributeInfo</td>403* <td>Frequency of persist cycle in seconds. Used when persistPolicy is404* "OnTimer" or "NoMoreOftenThan".</td></tr>405*406* <tr><th scope="row">persistPolicy</th><td>String</td>407* <td>ModelMBeanInfo<br>ModelMBeanAttributeInfo</td>408* <td>One of: OnUpdate|OnTimer|NoMoreOftenThan|OnUnregister|Always|Never.409* See the section "MBean Descriptor Fields" in the JMX specification410* document.</td></tr>411*412* <tr><th scope="row">presentationString</th><td>String</td><td>Any</td>413* <td>XML formatted string to allow presentation of data.</td></tr>414*415* <tr><th scope="row">protocolMap</th><td>Descriptor</td><td>ModelMBeanAttributeInfo</td>416* <td>See the section "Protocol Map Support" in the JMX specification417* document. Mappings must be appropriate for the attribute and entries418* can be updated or augmented at runtime.</td></tr>419*420* <tr><th scope="row">role</th><td>String</td>421* <td>ModelMBeanConstructorInfo<br>ModelMBeanOperationInfo</td>422* <td>One of "constructor", "operation", "getter", or "setter".</td></tr>423*424* <tr><th scope="row">setMethod</th><td>String</td><td>ModelMBeanAttributeInfo</td>425* <td>Name of operation descriptor for set method.</td></tr>426*427* <tr id="severity"><th scope="row">severity</th><td>Number</td>428* <td>ModelMBeanNotificationInfo</td>429* <td>0-6 where 0: unknown; 1: non-recoverable;430* 2: critical, failure; 3: major, severe;431* 4: minor, marginal, error; 5: warning;432* 6: normal, cleared, informative</td></tr>433*434* <tr><th scope="row">targetObject</th><td>Object</td><td>ModelMBeanOperationInfo</td>435* <td>Object on which to execute this method.</td></tr>436*437* <tr><th scope="row">targetType</th><td>String</td><td>ModelMBeanOperationInfo</td>438* <td>type of object reference for targetObject. Can be:439* ObjectReference | Handle | EJBHandle | IOR | RMIReference.</td></tr>440*441* <tr id="value-field"><th scope="row">value</th><td>Object</td>442* <td>ModelMBeanAttributeInfo<br>ModelMBeanOperationInfo</td>443* <td>Current (cached) value for attribute or operation.</td></tr>444*445* <tr id="visibility"><th scope="row">visibility</th><td>Number</td><td>Any</td>446* <td>1-4 where 1: always visible, 4: rarely visible.</td></tr>447*448* </tbody>449* </table>450*451* @since 1.5452*/453public interface Descriptor extends Serializable, Cloneable454{455456/**457* Returns the value for a specific field name, or null if no value458* is present for that name.459*460* @param fieldName the field name.461*462* @return the corresponding value, or null if the field is not present.463*464* @exception RuntimeOperationsException if the field name is illegal.465*/466public Object getFieldValue(String fieldName)467throws RuntimeOperationsException;468469/**470* <p>Sets the value for a specific field name. This will471* modify an existing field or add a new field.</p>472*473* <p>The field value will be validated before it is set.474* If it is not valid, then an exception will be thrown.475* The meaning of validity is dependent on the descriptor476* implementation.</p>477*478* @param fieldName The field name to be set. Cannot be null or empty.479* @param fieldValue The field value to be set for the field480* name. Can be null if that is a valid value for the field.481*482* @exception RuntimeOperationsException if the field name or field value483* is illegal (wrapped exception is {@link IllegalArgumentException}); or484* if the descriptor is immutable (wrapped exception is485* {@link UnsupportedOperationException}).486*/487public void setField(String fieldName, Object fieldValue)488throws RuntimeOperationsException;489490491/**492* Returns all of the fields contained in this descriptor as a string array.493*494* @return String array of fields in the format <i>fieldName=fieldValue</i>495* <br>If the value of a field is not a String, then the toString() method496* will be called on it and the returned value, enclosed in parentheses,497* used as the value for the field in the returned array. If the value498* of a field is null, then the value of the field in the returned array499* will be empty. If the descriptor is empty, you will get500* an empty array.501*502* @see #setFields503*/504public String[] getFields();505506507/**508* Returns all the field names in the descriptor.509*510* @return String array of field names. If the descriptor is empty,511* you will get an empty array.512*/513public String[] getFieldNames();514515/**516* Returns all the field values in the descriptor as an array of Objects. The517* returned values are in the same order as the {@code fieldNames} String array parameter.518*519* @param fieldNames String array of the names of the fields that520* the values should be returned for. If the array is empty then521* an empty array will be returned. If the array is null then all522* values will be returned, as if the parameter were the array523* returned by {@link #getFieldNames()}. If a field name in the524* array does not exist, including the case where it is null or525* the empty string, then null is returned for the matching array526* element being returned.527*528* @return Object array of field values. If the list of {@code fieldNames}529* is empty, you will get an empty array.530*/531public Object[] getFieldValues(String... fieldNames);532533/**534* Removes a field from the descriptor.535*536* @param fieldName String name of the field to be removed.537* If the field name is illegal or the field is not found,538* no exception is thrown.539*540* @exception RuntimeOperationsException if a field of the given name541* exists and the descriptor is immutable. The wrapped exception will542* be an {@link UnsupportedOperationException}.543*/544public void removeField(String fieldName);545546/**547* <p>Sets all fields in the field names array to the new value with548* the same index in the field values array. Array sizes must match.</p>549*550* <p>The field value will be validated before it is set.551* If it is not valid, then an exception will be thrown.552* If the arrays are empty, then no change will take effect.</p>553*554* @param fieldNames String array of field names. The array and array555* elements cannot be null.556* @param fieldValues Object array of the corresponding field values.557* The array cannot be null. Elements of the array can be null.558*559* @throws RuntimeOperationsException if the change fails for any reason.560* Wrapped exception is {@link IllegalArgumentException} if561* {@code fieldNames} or {@code fieldValues} is null, or if562* the arrays are of different lengths, or if there is an563* illegal value in one of them.564* Wrapped exception is {@link UnsupportedOperationException}565* if the descriptor is immutable, and the call would change566* its contents.567*568* @see #getFields569*/570public void setFields(String[] fieldNames, Object[] fieldValues)571throws RuntimeOperationsException;572573574/**575* <p>Returns a descriptor which is equal to this descriptor.576* Changes to the returned descriptor will have no effect on this577* descriptor, and vice versa. If this descriptor is immutable,578* it may fulfill this condition by returning itself.</p>579* @exception RuntimeOperationsException for illegal value for field names580* or field values.581* If the descriptor construction fails for any reason, this exception will582* be thrown.583* @return A descriptor which is equal to this descriptor.584*/585public Object clone() throws RuntimeOperationsException;586587588/**589* Returns true if all of the fields have legal values given their590* names.591*592* @return true if the values are legal.593*594* @exception RuntimeOperationsException If the validity checking fails for595* any reason, this exception will be thrown.596* The method returns false if the descriptor is not valid, but throws597* this exception if the attempt to determine validity fails.598*/599public boolean isValid() throws RuntimeOperationsException;600601/**602* <p>Compares this descriptor to the given object. The objects are equal if603* the given object is also a Descriptor, and if the two Descriptors have604* the same field names (possibly differing in case) and the same605* associated values. The respective values for a field in the two606* Descriptors are equal if the following conditions hold:</p>607*608* <ul>609* <li>If one value is null then the other must be too.</li>610* <li>If one value is a primitive array then the other must be a primitive611* array of the same type with the same elements.</li>612* <li>If one value is an object array then the other must be too and613* {@link Arrays#deepEquals(Object[],Object[])} must return true.</li>614* <li>Otherwise {@link Object#equals(Object)} must return true.</li>615* </ul>616*617* @param obj the object to compare with.618*619* @return {@code true} if the objects are the same; {@code false}620* otherwise.621*622* @since 1.6623*/624public boolean equals(Object obj);625626/**627* <p>Returns the hash code value for this descriptor. The hash628* code is computed as the sum of the hash codes for each field in629* the descriptor. The hash code of a field with name {@code n}630* and value {@code v} is {@code n.toLowerCase().hashCode() ^ h}.631* Here {@code h} is the hash code of {@code v}, computed as632* follows:</p>633*634* <ul>635* <li>If {@code v} is null then {@code h} is 0.</li>636* <li>If {@code v} is a primitive array then {@code h} is computed using637* the appropriate overloading of {@code java.util.Arrays.hashCode}.</li>638* <li>If {@code v} is an object array then {@code h} is computed using639* {@link Arrays#deepHashCode(Object[])}.</li>640* <li>Otherwise {@code h} is {@code v.hashCode()}.</li>641* </ul>642*643* @return A hash code value for this object.644*645* @since 1.6646*/647public int hashCode();648}649650651