FileDocCategorySizeDatePackage
MBeanConstructorInfo.javaAPI DocJava SE 5 API5533Fri Aug 26 14:57:32 BST 2005javax.management

MBeanConstructorInfo

public class MBeanConstructorInfo extends MBeanFeatureInfo implements Cloneable, Serializable
Describes a constructor exposed by an MBean. Instances of this class are immutable. Subclasses may be mutable but this is not recommended.
since
1.5

Fields Summary
static final long
serialVersionUID
static final MBeanConstructorInfo[]
NO_CONSTRUCTORS
private final transient boolean
immutable
private final MBeanParameterInfo[]
signature
Constructors Summary
public MBeanConstructorInfo(String description, Constructor constructor)
Constructs an MBeanConstructorInfo object.

param
description A human readable description of the operation.
param
constructor The java.lang.reflect.Constructor object describing the MBean constructor.


                               
         
	this(constructor.getName(), description,
	     constructorSignature(constructor));
    
public MBeanConstructorInfo(String name, String description, MBeanParameterInfo[] signature)
Constructs an MBeanConstructorInfo object.

param
name The name of the constructor.
param
signature MBeanParameterInfo objects describing the parameters(arguments) of the constructor. This may be null with the same effect as a zero-length array.
param
description A human readable description of the constructor.

	super(name, description);


	if (signature == null || signature.length == 0)
	    signature = MBeanParameterInfo.NO_PARAMS;
	else
	    signature = (MBeanParameterInfo[]) signature.clone();
	this.signature = signature;
	this.immutable =
	    MBeanInfo.isImmutableClass(this.getClass(),
				       MBeanConstructorInfo.class);
    
Methods Summary
public java.lang.Objectclone()

Returns a shallow clone of this instance. The clone is obtained by simply calling super.clone(), thus calling the default native shallow cloning mechanism implemented by Object.clone(). No deeper cloning of any internal field is made.

Since this class is immutable, cloning is chiefly of interest to subclasses.

	 try {
	     return  super.clone() ;
	 } catch (CloneNotSupportedException e) {
	     // should not happen as this class is cloneable
	     return null;
	 }
     
private static javax.management.MBeanParameterInfo[]constructorSignature(java.lang.reflect.Constructor cn)

	final Class[] classes = cn.getParameterTypes();
	final MBeanParameterInfo[] params =
	    new MBeanParameterInfo[classes.length];

	for (int i = 0; i < classes.length; i++) {
	    final String pn = "p" + (i + 1);
	    params[i] = new MBeanParameterInfo(pn, classes[i].getName(), "");
	}

	return params;
    
public booleanequals(java.lang.Object o)
Compare this MBeanConstructorInfo to another.

param
o the object to compare to.
return
true iff o is an MBeanConstructorInfo such that its {@link #getName()}, {@link #getDescription()}, and {@link #getSignature()} values are equal (not necessarily identical) to those of this MBeanConstructorInfo. Two signature arrays are equal if their elements are pairwise equal.

	if (o == this)
	    return true;
	if (!(o instanceof MBeanConstructorInfo))
	    return false;
	MBeanConstructorInfo p = (MBeanConstructorInfo) o;
	return (p.getName().equals(getName()) &&
		p.getDescription().equals(getDescription()) &&
		Arrays.equals(p.fastGetSignature(), fastGetSignature()));
    
private javax.management.MBeanParameterInfo[]fastGetSignature()

	if (immutable)
	    return signature;
	else
	    return getSignature();
    
public javax.management.MBeanParameterInfo[]getSignature()

Returns the list of parameters for this constructor. Each parameter is described by an MBeanParameterInfo object.

The returned array is a shallow copy of the internal array, which means that it is a copy of the internal array of references to the MBeanParameterInfo objects but that each referenced MBeanParameterInfo object is not copied.

return
An array of MBeanParameterInfo objects.

	if (signature.length == 0)
            return signature;
	else
	    return (MBeanParameterInfo[]) signature.clone();
    
public inthashCode()

	int hash = getName().hashCode();
	MBeanParameterInfo[] sig = fastGetSignature();
	for (int i = 0; i < sig.length; i++)
	    hash ^= sig[i].hashCode();
	return hash;