FileDocCategorySizeDatePackage
RoleInfo.javaAPI DocJava SE 5 API18108Fri Aug 26 14:57:36 BST 2005javax.management.relation

RoleInfo

public class RoleInfo extends Object implements Serializable
A RoleInfo object summarises a role in a relation type.
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 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 theName, String theRefMBeanClassName, boolean theIsReadable, boolean theIsWritable, int theMinDegree, int theMaxDegree, String theDescription)
Constructor.

param
theName name of the role.
param
theRefMBeanClassName 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, theRefMBeanClassName)}.
param
theIsReadable flag to indicate if the corresponding role can be read
param
theIsWritable flag to indicate if the corresponding role can be set
param
theMinDegree minimum degree for role, i.e. minimum number of MBeans to provide in corresponding role Must be less or equal than theMaxDegree. (ROLE_CARDINALITY_INFINITY for unlimited)
param
theMaxDegree maximum degree for role, i.e. maximum number of MBeans to provide in corresponding role Must be greater or equal than theMinDegree (ROLE_CARDINALITY_INFINITY for unlimited)
param
theDescription 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 theRefMBeanClassName is not a MBean class.


    //
    // Constructors
    //

                                                                                                                                                                                                           
      
		     
		     
		     
		     
		     
		     
     
	   
           
            

	init(theName,
	     theRefMBeanClassName,
	     theIsReadable,
	     theIsWritable,
	     theMinDegree,
	     theMaxDegree,
	     theDescription);
	return;
    
public RoleInfo(String theName, String theRefMBeanClassName, boolean theIsReadable, boolean theIsWritable)
Constructor.

param
theName name of the role
param
theRefMBeanClassName 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, theRefMBeanClassName)}.
param
theIsReadable flag to indicate if the corresponding role can be read
param
theIsWritable 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(theName,
		 theRefMBeanClassName,
		 theIsReadable,
		 theIsWritable,
		 1,
		 1,
		 null);
	} catch (InvalidRoleInfoException exc) {
	    // OK : Can never happen as the minimum
	    //      degree equals the maximum degree.
	}

	return;
    
public RoleInfo(String theName, String theRefMBeanClassName)
Constructor.

param
theName name of the role
param
theRefMBeanClassName 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, theRefMBeanClassName)}.

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(theName,
		 theRefMBeanClassName,
		 true,
		 true,
		 1,
		 1,
		 null);
	} catch (InvalidRoleInfoException exc) {
	    // OK : Can never happen as the minimum
	    //      degree equals the maximum degree.
	}

	return;
    
public RoleInfo(RoleInfo theRoleInfo)
Copy constructor.

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


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

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

param
theValue value
return
true if less or equal than maximum degree, false otherwise.

	if (theValue >= ROLE_CARDINALITY_INFINITY &&
	    (maxDegree == ROLE_CARDINALITY_INFINITY ||
	     (theValue != ROLE_CARDINALITY_INFINITY &&
	      theValue <= maxDegree))) {
	    return true;
	} else {
	    return false;
	}
    
public booleancheckMinDegree(int theValue)
Returns a boolean to specify if given value is greater or equal than expected minimum degree (true if yes).

param
theValue value
return
true if greater or equal than minimum degree, false otherwise.

	if (theValue >= ROLE_CARDINALITY_INFINITY &&
	    (minDegree == ROLE_CARDINALITY_INFINITY
	     || theValue >= 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 theName, java.lang.String theRefMBeanClassName, boolean theIsReadable, boolean theIsWritable, int theMinDegree, int theMaxDegree, java.lang.String theDescription)


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

	name = theName;
	isReadable = theIsReadable;
	isWritable = theIsWritable;
	if (theDescription != null) {
	    description = theDescription;
	}

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

	} else if (theMinDegree < ROLE_CARDINALITY_INFINITY ||
		   theMaxDegree < 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 = theMinDegree;
	maxDegree = theMaxDegree;

        referencedMBeanClassName = theRefMBeanClassName;

	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();
      }