FileDocCategorySizeDatePackage
RoleInfo.javaAPI DocJava SE 6 API17790Tue Jun 10 00:26:18 BST 2008javax.management.relation

RoleInfo

public class RoleInfo extends Object implements Serializable
A RoleInfo object summarises a role in a relation type.

The serialVersionUID of this class is 2504952983494636987L.

since
1.5

Fields Summary
private static final long
oldSerialVersionUID
private static final long
newSerialVersionUID
private static final ObjectStreamField[]
oldSerialPersistentFields
private static final ObjectStreamField[]
newSerialPersistentFields
private static final long
serialVersionUID
private static final ObjectStreamField[]
serialPersistentFields
private static boolean
compat
public static final int
ROLE_CARDINALITY_INFINITY
To specify an unlimited cardinality.
private String
name
private boolean
isReadable
private boolean
isWritable
private String
description
private int
minDegree
private int
maxDegree
private String
referencedMBeanClassName
Constructors Summary
public RoleInfo(String roleName, String mbeanClassName, boolean read, boolean write, int min, int max, String descr)
Constructor.

param
roleName name of the role.
param
mbeanClassName name of the class of MBean(s) expected to be referenced in corresponding role. If an MBean M is in this role, then the MBean server must return true for {@link MBeanServer#isInstanceOf isInstanceOf(M, mbeanClassName)}.
param
read flag to indicate if the corresponding role can be read
param
write flag to indicate if the corresponding role can be set
param
min minimum degree for role, i.e. minimum number of MBeans to provide in corresponding role Must be less than or equal to max. (ROLE_CARDINALITY_INFINITY for unlimited)
param
max maximum degree for role, i.e. maximum number of MBeans to provide in corresponding role Must be greater than or equal to min (ROLE_CARDINALITY_INFINITY for unlimited)
param
descr description of the role (can be null)
exception
IllegalArgumentException if null parameter
exception
InvalidRoleInfoException if the minimum degree is greater than the maximum degree.
exception
ClassNotFoundException As of JMX 1.2, this exception can no longer be thrown. It is retained in the declaration of this class for compatibility with existing code.
exception
NotCompliantMBeanException if the class mbeanClassName is not a MBean class.


    //
    // Constructors
    //

                                                                                                                                                                                                             
      
		     
		     
		     
		     
		     
		     
     
	   
           
            

	init(roleName,
	     mbeanClassName,
	     read,
	     write,
	     min,
	     max,
	     descr);
	return;
    
public RoleInfo(String roleName, String mbeanClassName, boolean read, boolean write)
Constructor.

param
roleName name of the role
param
mbeanClassName name of the class of MBean(s) expected to be referenced in corresponding role. If an MBean M is in this role, then the MBean server must return true for {@link MBeanServer#isInstanceOf isInstanceOf(M, mbeanClassName)}.
param
read flag to indicate if the corresponding role can be read
param
write flag to indicate if the corresponding role can be set

Minimum and maximum degrees defaulted to 1.

Description of role defaulted to null.

exception
IllegalArgumentException if null parameter
exception
ClassNotFoundException As of JMX 1.2, this exception can no longer be thrown. It is retained in the declaration of this class for compatibility with existing code.
exception
NotCompliantMBeanException As of JMX 1.2, this exception can no longer be thrown. It is retained in the declaration of this class for compatibility with existing code.


	try {
	    init(roleName,
		 mbeanClassName,
		 read,
		 write,
		 1,
		 1,
		 null);
	} catch (InvalidRoleInfoException exc) {
	    // OK : Can never happen as the minimum
	    //      degree equals the maximum degree.
	}

	return;
    
public RoleInfo(String roleName, String mbeanClassName)
Constructor.

param
roleName name of the role
param
mbeanClassName name of the class of MBean(s) expected to be referenced in corresponding role. If an MBean M is in this role, then the MBean server must return true for {@link MBeanServer#isInstanceOf isInstanceOf(M, mbeanClassName)}.

IsReadable and IsWritable defaulted to true.

Minimum and maximum degrees defaulted to 1.

Description of role defaulted to null.

exception
IllegalArgumentException if null parameter
exception
ClassNotFoundException As of JMX 1.2, this exception can no longer be thrown. It is retained in the declaration of this class for compatibility with existing code.
exception
NotCompliantMBeanException As of JMX 1.2, this exception can no longer be thrown. It is retained in the declaration of this class for compatibility with existing code.


	try {
	    init(roleName,
		 mbeanClassName,
		 true,
		 true,
		 1,
		 1,
		 null);
	} catch (InvalidRoleInfoException exc) {
	    // OK : Can never happen as the minimum
	    //      degree equals the maximum degree.
	}

	return;
    
public RoleInfo(RoleInfo roleInfo)
Copy constructor.

param
roleInfo the RoleInfo instance to be copied.
exception
IllegalArgumentException if null parameter


	if (roleInfo == null) {
	    // Revisit [cebro] Localize message
	    String excMsg = "Invalid parameter.";
	    throw new IllegalArgumentException(excMsg);
	}

	try {
	    init(roleInfo.getName(),
		 roleInfo.getRefMBeanClassName(),
		 roleInfo.isReadable(),
		 roleInfo.isWritable(),
		 roleInfo.getMinDegree(),
		 roleInfo.getMaxDegree(),
		 roleInfo.getDescription());
	} catch (InvalidRoleInfoException exc3) {
	    // OK : Can never happen as the minimum degree and the maximum
	    //      degree were already checked at the time the roleInfo
	    //      instance was created.
	}
    
Methods Summary
public booleancheckMaxDegree(int value)
Returns true if the value parameter is lower than or equal to the expected maximum degree, false otherwise.

param
value the value to be checked
return
true if lower than or equal to maximum degree, false otherwise.

	if (value >= ROLE_CARDINALITY_INFINITY &&
	    (maxDegree == ROLE_CARDINALITY_INFINITY ||
	     (value != ROLE_CARDINALITY_INFINITY &&
	      value <= maxDegree))) {
	    return true;
	} else {
	    return false;
	}
    
public booleancheckMinDegree(int value)
Returns true if the value parameter is greater than or equal to the expected minimum degree, false otherwise.

param
value the value to be checked
return
true if greater than or equal to minimum degree, false otherwise.

	if (value >= ROLE_CARDINALITY_INFINITY &&
	    (minDegree == ROLE_CARDINALITY_INFINITY
	     || value >= minDegree)) {
	    return true;
	} else {
	    return false;
	}
    
public java.lang.StringgetDescription()
Returns description text for the role.

return
the description of the role.

	return description;
    
public intgetMaxDegree()
Returns maximum degree for corresponding role reference.

return
the maximum degree.

	return maxDegree;
    
public intgetMinDegree()
Returns minimum degree for corresponding role reference.

return
the minimum degree.

	return minDegree;
    
public java.lang.StringgetName()
Returns the name of the role.

return
the name of the role.

	return name;
    
public java.lang.StringgetRefMBeanClassName()

Returns name of type of MBean expected to be referenced in corresponding role.

return
the name of the referenced type.

	return referencedMBeanClassName;
    
private voidinit(java.lang.String roleName, java.lang.String mbeanClassName, boolean read, boolean write, int min, int max, java.lang.String descr)


	if (roleName == null ||
	    mbeanClassName == null) {
	    // Revisit [cebro] Localize message
	    String excMsg = "Invalid parameter.";
	    throw new IllegalArgumentException(excMsg);
	}

	name = roleName;
	isReadable = read;
	isWritable = write;
	if (descr != null) {
	    description = descr;
	}

	boolean invalidRoleInfoFlg = false;
	StringBuffer excMsgStrB = new StringBuffer();
	if (max != ROLE_CARDINALITY_INFINITY &&
	    (min == ROLE_CARDINALITY_INFINITY ||
	     min > max)) {
	    // Revisit [cebro] Localize message
	    excMsgStrB.append("Minimum degree ");
	    excMsgStrB.append(min);
	    excMsgStrB.append(" is greater than maximum degree ");
	    excMsgStrB.append(max);
	    invalidRoleInfoFlg = true;

	} else if (min < ROLE_CARDINALITY_INFINITY ||
		   max < ROLE_CARDINALITY_INFINITY) {
	    // Revisit [cebro] Localize message
	    excMsgStrB.append("Minimum or maximum degree has an illegal value, must be [0, ROLE_CARDINALITY_INFINITY].");
	    invalidRoleInfoFlg = true;
	}
	if (invalidRoleInfoFlg) {
	    throw new InvalidRoleInfoException(excMsgStrB.toString());
	}
	minDegree = min;
	maxDegree = max;

        referencedMBeanClassName = mbeanClassName;

	return;
    
public booleanisReadable()
Returns read access mode for the role (true if it is readable).

return
true if the role is readable.

	return isReadable;
    
public booleanisWritable()
Returns write access mode for the role (true if it is writable).

return
true if the role is writable.

	return isWritable;
    
private voidreadObject(java.io.ObjectInputStream in)
Deserializes a {@link RoleInfo} from an {@link ObjectInputStream}.

      if (compat)
      {
        // Read an object serialized in the old serial form
        //
        ObjectInputStream.GetField fields = in.readFields();
	name = (String) fields.get("myName", null);
	if (fields.defaulted("myName"))
        {
          throw new NullPointerException("myName");
        }
	isReadable = fields.get("myIsReadableFlg", false);
	if (fields.defaulted("myIsReadableFlg"))
        {
          throw new NullPointerException("myIsReadableFlg");
        }
	isWritable = fields.get("myIsWritableFlg", false);
	if (fields.defaulted("myIsWritableFlg"))
        {
          throw new NullPointerException("myIsWritableFlg");
        }
	description = (String) fields.get("myDescription", null);
	if (fields.defaulted("myDescription"))
        {
          throw new NullPointerException("myDescription");
        }
	minDegree = fields.get("myMinDegree", (int)0);
	if (fields.defaulted("myMinDegree"))
        {
          throw new NullPointerException("myMinDegree");
        }
	maxDegree = fields.get("myMaxDegree", (int)0);
	if (fields.defaulted("myMaxDegree"))
        {
          throw new NullPointerException("myMaxDegree");
        }
	referencedMBeanClassName = (String) fields.get("myRefMBeanClassName", null);
	if (fields.defaulted("myRefMBeanClassName"))
        {
          throw new NullPointerException("myRefMBeanClassName");
        }
      }
      else
      {
        // Read an object serialized in the new serial form
        //
        in.defaultReadObject();
      }
    
public java.lang.StringtoString()
Returns a string describing the role info.

return
a description of the role info.

	StringBuffer result = new StringBuffer();
	result.append("role info name: " + name);
	result.append("; isReadable: " + isReadable);
	result.append("; isWritable: " + isWritable);
	result.append("; description: " + description);
	result.append("; minimum degree: " + minDegree);
	result.append("; maximum degree: " + maxDegree);
	result.append("; MBean class: " + referencedMBeanClassName);
	return result.toString();
    
private voidwriteObject(java.io.ObjectOutputStream out)
Serializes a {@link RoleInfo} to an {@link ObjectOutputStream}.

      if (compat)
      {
        // Serializes this instance in the old serial form
        //
        ObjectOutputStream.PutField fields = out.putFields();
	fields.put("myName", name);
	fields.put("myIsReadableFlg", isReadable);
	fields.put("myIsWritableFlg", isWritable);
	fields.put("myDescription", description);
	fields.put("myMinDegree", minDegree);
	fields.put("myMaxDegree", maxDegree);
	fields.put("myRefMBeanClassName", referencedMBeanClassName);
	out.writeFields();
      }
      else
      {
        // Serializes this instance in the new serial form
        //
        out.defaultWriteObject();
      }