This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.management
class ImmutableDescriptor

java.lang.Object extended by javax.management.ImmutableDescriptor
All Implemented Interfaces:
Descriptor

public class ImmutableDescriptor
extends Object
implements Descriptor

An immutable descriptor.


Field Summary
static ImmutableDescriptor EMPTY_DESCRIPTOR
          An empty descriptor.
 
Constructor Summary

          Construct a descriptor where the names and values of the fields are the keys and values of the given Map.

          Construct a descriptor containing the given fields.
ImmutableDescriptor(String[] fieldNames, Object[] fieldValues)

          Construct a descriptor containing the given fields and values.
 
Method Summary
 Descriptor

          Returns a descriptor which is equal to this descriptor.
 boolean

          Compares this descriptor to the given object.
 String[]

          
 String[]

          
 Object
getFieldValue(String fieldName)

          
 Object[]
getFieldValues(String[] fieldNames)

          
 int

          Returns the hash code value for this descriptor.
 boolean

          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 fieldName, Object fieldValue)

          This operation is unsupported since this class is immutable.
 void
setFields(String[] fieldNames, Object[] fieldValues)

          This operation is unsupported since this class is immutable.
 String

          Returns a string representation of the object.
static ImmutableDescriptor
union(Descriptor[] descriptors)

          Return an whose contents are the union of the given descriptors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_DESCRIPTOR

public static final ImmutableDescriptor EMPTY_DESCRIPTOR
An empty descriptor.
Constructor Detail

ImmutableDescriptor

public ImmutableDescriptor(Map fields)

Construct a descriptor where the names and values of the fields are the keys and values of the given Map.

Parameters:
fields

ImmutableDescriptor

public ImmutableDescriptor(String[] fields)
Construct a descriptor containing the given fields. Each String must be of the form {@code 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}.

Parameters:
fields

ImmutableDescriptor

public ImmutableDescriptor(String[] fieldNames,
                           Object[] fieldValues)
Construct a descriptor containing the given fields and values.

Parameters:
fieldNames
fieldValues
Method Detail

clone

public Descriptor clone()

Returns a descriptor which is equal to this descriptor. Changes to the returned descriptor will have no effect on this descriptor, and vice versa.

This method returns the object on which it is called. A subclass can override it to return another object provided the contract is respected.

Overrides:
clone in class Object

equals

public boolean equals(Object o)
Compares this descriptor to the given object. The objects are equal if the given object is also a Descriptor, and if the two Descriptors have the same field names (possibly differing in case) and the same associated values. The respective values for a field in the two Descriptors are equal if the following conditions hold:

Overrides:
equals in class Object
Parameters:
o - the object to compare with.
Returns:
{@code true} if the objects are the same; {@code false} otherwise.

getFieldNames

public final String[] getFieldNames()

getFields

public final String[] getFields()

getFieldValue

public final Object getFieldValue(String fieldName)
Parameters:
fieldName

getFieldValues

public final Object[] getFieldValues(String[] fieldNames)
Parameters:
fieldNames

hashCode

public 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:

Overrides:
hashCode in class Object
Returns:
A hash code value for this object.

isValid

public boolean isValid()
Returns true if all of the fields have legal values given their names. This method always returns true, but a subclass can override it to return false when appropriate.

Returns:
true if the values are legal.

removeField

public final void removeField(String fieldName)
Removes a field from the descriptor.

Parameters:
fieldName - String name of the field to be removed. If the field name is illegal or the field is not found, no exception is thrown.

setField

public final void setField(String fieldName,
                           Object fieldValue)
                    throws RuntimeOperationsException
This operation is unsupported since this class is immutable. If this call would change a mutable descriptor with the same contents, then a {@link RuntimeOperationsException} wrapping an {@link UnsupportedOperationException} is thrown. Otherwise, the behavior is the same as it would be for a mutable descriptor: either an exception is thrown because of illegal parameters, or there is no effect.

Parameters:
fieldName
fieldValue
Throws:
RuntimeOperationsException

setFields

public final void setFields(String[] fieldNames,
                            Object[] fieldValues)
                     throws RuntimeOperationsException
This operation is unsupported since this class is immutable. If this call would change a mutable descriptor with the same contents, then a {@link RuntimeOperationsException} wrapping an {@link UnsupportedOperationException} is thrown. Otherwise, the behavior is the same as it would be for a mutable descriptor: either an exception is thrown because of illegal parameters, or there is no effect.

Parameters:
fieldNames
fieldValues
Throws:
RuntimeOperationsException

toString

public String toString()
Overrides:
toString in class Object

union

public static ImmutableDescriptor union(Descriptor[] descriptors)

Return an {@code ImmutableDescriptor} whose contents are the union of the given descriptors. Every field name that appears in any of the descriptors will appear in the result with the value that it has when the method is called. Subsequent changes to any of the descriptors do not affect the ImmutableDescriptor returned here.

In the simplest case, there is only one descriptor and the returned {@code ImmutableDescriptor} is a copy of its fields at the time this method is called:

 Descriptor d = something();
 ImmutableDescriptor copy = ImmutableDescriptor.union(d);
 

Parameters:
descriptors - the descriptors to be combined. Any of the descriptors can be null, in which case it is skipped.
Returns:
an {@code ImmutableDescriptor} that is the union of the given descriptors. The returned object may be identical to one of the input descriptors if it is an ImmutableDescriptor that contains all of the required fields.


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.