FileDocCategorySizeDatePackage
Role.javaAPI DocJava SE 6 API8282Tue Jun 10 00:26:18 BST 2008javax.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.

The serialVersionUID of this class is -279985518429862552L.

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 roleName, List roleValue)

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
roleName role name
param
roleValue role value (List of ObjectName objects)
exception
IllegalArgumentException if null parameter


    //
    // Constructors
    //

                                                                
      
		 
	  

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

	setRoleName(roleName);
	setRoleValue(roleValue);

	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<ObjectName>) 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 roleValue)
Returns a string for the given role value.

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


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

	StringBuilder result = new StringBuilder();
	for (ObjectName currObjName : roleValue) {
	    if (result.length() > 0)
		result.append("\n");
	    result.append(currObjName.toString());
	}
	return result.toString();
    
public voidsetRoleName(java.lang.String roleName)
Sets role name.

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


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

	name = roleName;
	return;
    
public voidsetRoleValue(java.util.List roleValue)
Sets role value.

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


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

	objectNameList = new ArrayList<ObjectName>(roleValue);
	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();
      }