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

Role

public class Role extends Object implements Serializable
Represents a role: includes a role name and referenced MBeans (via their ObjectNames). The role value is always represented as an ArrayList collection (of ObjectNames) to homogenize the access.
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
private String
name
private List
objectNameList
Constructors Summary
public Role(String theRoleName, List theRoleValue)

Make a new Role object. No check is made that the ObjectNames in the role value exist in an MBean server. That check will be made when the role is set in a relation.

param
theRoleName role name
param
theRoleValue role value (List of ObjectName objects)
exception
IllegalArgumentException if null parameter


    //
    // Constructors
    //

                                                                
      
		 
	  

	if (theRoleName == null || theRoleValue == null) {
	    String excMsg = "Invalid parameter";
	    throw new IllegalArgumentException(excMsg);
	}

	setRoleName(theRoleName);
	setRoleValue(theRoleValue);

	return;
    
Methods Summary
public java.lang.Objectclone()
Clone the role object.

return
a Role that is an independent copy of the current Role object.


	try {
	    return new Role(name, objectNameList);
	} catch (IllegalArgumentException exc) {
	    return null; // can't happen
	}
    
public java.lang.StringgetRoleName()
Retrieves role name.

return
the role name.
see
#setRoleName

	return name;
    
public java.util.ListgetRoleValue()
Retrieves role value.

return
ArrayList of ObjectName objects for referenced MBeans.
see
#setRoleValue

	return objectNameList;
    
private voidreadObject(java.io.ObjectInputStream in)
Deserializes a {@link Role} 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");
        }
	objectNameList = (List) fields.get("myObjNameList", null);
	if (fields.defaulted("myObjNameList"))
        {
          throw new NullPointerException("myObjNameList");
        }
      }
      else
      {
        // Read an object serialized in the new serial form
        //
        in.defaultReadObject();
      }
    
public static java.lang.StringroleValueToString(java.util.List theRoleValue)
Returns a string for the given role value.

param
theRoleValue List of ObjectName objects
return
A String consisting of the ObjectNames separated by newlines (\n).
exception
IllegalArgumentException if null parameter


	if (theRoleValue == null) {
	    String excMsg = "Invalid parameter";
	    throw new IllegalArgumentException(excMsg);
	}

	StringBuffer result = new StringBuffer();
	for (Iterator objNameIter = theRoleValue.iterator();
	     objNameIter.hasNext();) {
	    ObjectName currObjName = (ObjectName)(objNameIter.next());
	    result.append(currObjName.toString());
	    if (objNameIter.hasNext()) {
		result.append("\n");
	    }
	}
	return result.toString();
    
public voidsetRoleName(java.lang.String theRoleName)
Sets role name.

param
theRoleName role name
exception
IllegalArgumentException if null parameter
see
#getRoleName


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

	name = theRoleName;
	return;
    
public voidsetRoleValue(java.util.List theRoleValue)
Sets role value.

param
theRoleValue List of ObjectName objects for referenced MBeans.
exception
IllegalArgumentException if null parameter
see
#getRoleValue


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

	objectNameList = new ArrayList(theRoleValue);
	return;
    
public java.lang.StringtoString()
Returns a string describing the role.

return
the description of the role.

	StringBuffer result = new StringBuffer();
	result.append("role name: " + name + "; role value: ");
	for (Iterator objNameIter = objectNameList.iterator();
	     objNameIter.hasNext();) {
	    ObjectName currObjName = (ObjectName)(objNameIter.next());
	    result.append(currObjName.toString());
	    if (objNameIter.hasNext()) {
		result.append(", ");
	    }
	}
	return result.toString();
    
private voidwriteObject(java.io.ObjectOutputStream out)
Serializes a {@link Role} 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("myObjNameList", (ArrayList)objectNameList);
	out.writeFields();
      }
      else
      {
        // Serializes this instance in the new serial form
        //
        out.defaultWriteObject();
      }