FileDocCategorySizeDatePackage
MBeanFeatureInfo.javaAPI DocJava SE 6 API8664Tue Jun 10 00:26:12 BST 2008javax.management

MBeanFeatureInfo

public class MBeanFeatureInfo extends Object implements Serializable, DescriptorRead

Provides general information for an MBean descriptor object. The feature described can be an attribute, an operation, a parameter, or a notification. Instances of this class are immutable. Subclasses may be mutable but this is not recommended.

since
1.5

Fields Summary
static final long
serialVersionUID
protected String
name
The name of the feature. It is recommended that subclasses call {@link #getName} rather than reading this field, and that they not change it.
protected String
description
The human-readable description of the feature. It is recommended that subclasses call {@link #getDescription} rather than reading this field, and that they not change it.
private transient Descriptor
descriptor
Constructors Summary
public MBeanFeatureInfo(String name, String description)
Constructs an MBeanFeatureInfo object. This constructor is equivalent to {@code MBeanFeatureInfo(name, description, (Descriptor) null}.

param
name The name of the feature.
param
description A human readable description of the feature.

    

                                             
         
        this(name, description, null);
    
public MBeanFeatureInfo(String name, String description, Descriptor descriptor)
Constructs an MBeanFeatureInfo object.

param
name The name of the feature.
param
description A human readable description of the feature.
param
descriptor The descriptor for the feature. This may be null which is equivalent to an empty descriptor.
since
1.6

        this.name = name;
        this.description = description;
        this.descriptor = descriptor;
    
Methods Summary
public booleanequals(java.lang.Object o)
Compare this MBeanFeatureInfo to another.

param
o the object to compare to.
return
true if and only if o is an MBeanFeatureInfo such that its {@link #getName()}, {@link #getDescription()}, and {@link #getDescriptor()} values are equal (not necessarily identical) to those of this MBeanFeatureInfo.

	if (o == this)
	    return true;
	if (!(o instanceof MBeanFeatureInfo))
	    return false;
	MBeanFeatureInfo p = (MBeanFeatureInfo) o;
	return (p.getName().equals(getName()) &&
		p.getDescription().equals(getDescription()) &&
                p.getDescriptor().equals(getDescriptor()));
    
public java.lang.StringgetDescription()
Returns the human-readable description of the feature.

return
the human-readable description of the feature.

	return description;
    
public javax.management.DescriptorgetDescriptor()
Returns the descriptor for the feature. Changing the returned value will have no affect on the original descriptor.

return
a descriptor that is either immutable or a copy of the original.
since
1.6

        return (Descriptor) ImmutableDescriptor.nonNullDescriptor(descriptor).clone();
    
public java.lang.StringgetName()
Returns the name of the feature.

return
the name of the feature.

	return name;
    
public inthashCode()

	return getName().hashCode() ^ getDescription().hashCode() ^
               getDescriptor().hashCode();
    
private voidreadObject(java.io.ObjectInputStream in)
Deserializes an {@link MBeanFeatureInfo} from an {@link ObjectInputStream}.

serialData
For compatibility reasons, an object of this class is deserialized as follows.
    The method {@link ObjectInputStream#defaultReadObject defaultReadObject()} is called first to deserialize the object except the field {@code descriptor}, which is not serialized in the default way. Then the method {@link ObjectInputStream#read read()} is called to read a byte, the field {@code descriptor} is deserialized according to the value of the byte value:
    • 1. The method {@link ObjectInputStream#readObject readObject()} is called twice to obtain the field names (a {@code String[]}) and the field values (a {@code Object[]}) of the {@code descriptor}. The two obtained values then are used to construct an {@link ImmutableDescriptor} instance for the field {@code descriptor};
    • 0. The value for the field {@code descriptor} is obtained directly by calling the method {@link ObjectInputStream#readObject readObject()}. If the obtained value is null, the field {@code descriptor} is set to {@link ImmutableDescriptor#EMPTY_DESCRIPTOR EMPTY_DESCRIPTOR};
    • -1. This means that there is no byte to read and that the object is from an earlier version of the JMX API. The field {@code descriptor} is set to {@link ImmutableDescriptor#EMPTY_DESCRIPTOR EMPTY_DESCRIPTOR}
    • Any other value. A {@link StreamCorruptedException} is thrown.
since
1.6


	in.defaultReadObject();

	switch (in.read()) {
	case 1:
	    final String[] names = (String[])in.readObject();

	    if (names.length == 0) {
		descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
	    } else {
		final Object[] values = (Object[])in.readObject();
		descriptor = new ImmutableDescriptor(names, values);
	    }

	    break;
	case 0:
	    descriptor = (Descriptor)in.readObject();

	    if (descriptor == null) {
		descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
	    }

	    break;
	case -1: // from an earlier version of the JMX API
	    descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;

	    break;
	default:
	    throw new StreamCorruptedException("Got unexpected byte.");
	}
    
private voidwriteObject(java.io.ObjectOutputStream out)
Serializes an {@link MBeanFeatureInfo} to an {@link ObjectOutputStream}.

serialData
For compatibility reasons, an object of this class is serialized as follows.
    The method {@link ObjectOutputStream#defaultWriteObject defaultWriteObject()} is called first to serialize the object except the field {@code descriptor} which is declared as transient. The field {@code descriptor} is serialized as follows:
    • If {@code descriptor} is an instance of the class {@link ImmutableDescriptor}, the method {@link ObjectOutputStream#write write(int val)} is called to write a byte with the value {@code 1}, then the method {@link ObjectOutputStream#writeObject writeObject(Object obj)} is called twice to serialize the field names and the field values of the {@code descriptor}, respectively as a {@code String[]} and an {@code Object[]};
    • Otherwise, the method {@link ObjectOutputStream#write write(int val)} is called to write a byte with the value {@code 0}, then the method {@link ObjectOutputStream#writeObject writeObject(Object obj)} is called to serialize directly the field {@code descriptor}.
since
1.6

        out.defaultWriteObject();

	if (descriptor != null &&
	    descriptor.getClass() == ImmutableDescriptor.class) {
	    
	    out.write(1);

	    final String[] names = descriptor.getFieldNames();

	    out.writeObject(names);
	    out.writeObject(descriptor.getFieldValues(names));
	} else {
	    out.write(0);

	    out.writeObject(descriptor);
	}