roles
Class ObjectWithRoles

java.lang.Object
  |
  +--roles.ObjectWithRoles
Direct Known Subclasses:
ProxyObjectWithRoles

public abstract class ObjectWithRoles
extends java.lang.Object
implements RoleProtocol

This class is the root for entity classes, which should have the ability to play different independent roles.


Field Summary
protected  java.util.Hashtable qualifiedRoles
          Contains collections of qualified role objects identified by their role type name.
protected  java.util.Hashtable roles
          Contains (unqualified) role objects indentified by their role type name.
 
Constructor Summary
ObjectWithRoles()
           
 
Method Summary
 java.util.Enumeration allAs(java.lang.String qualifiedRoleTypeName)
          Returns an enumeration of qualified role objects whose class is the qualified role type with name qualifiedRoleTypeName.
 RoleType as(java.lang.String roleTypeName)
          Returns an (unqualified) role object whose class is the role type with name roleTypeName.
 QualifiedRoleType as(java.lang.String qualifiedRoleTypeName, java.lang.Object qualifyingObject)
          Returns an instance of the qualified role type with name qualifiedRoleTypeName whose qualifier is identical with qualifyingObject.
protected  void cancelQualifiedRole(QualifiedRoleType role)
          Deregisters a qualified role that the receiver is currently playing.
protected  void cancelRole(RoleType role)
          Deregisters an (unqualified) role that the receiver is currently playing.
 boolean existsAs(java.lang.String roleTypeName)
          Examines whether an instance of a particular role type has been registered as a role of the receiver.
 boolean existsAs(java.lang.String qualifiedRoleTypeName, java.lang.Object qualifyingObj)
          Examines whether an instance of the qualified role type with name qualifiedRoleTypeName has been registered by the receiver using qualifier qualifyingObj.
protected  java.util.Enumeration getRegisteredQualifiedRoleTypeNames()
          Returns an enumeration of qualified role type names, of which instances are currently registered with the receiver.
protected  java.util.Enumeration getRegisteredRoleTypeNames()
          Returns an enumeration of (unqualified) role type names, of which instances are currently registered with the receiver.
 ObjectWithRoles getRoot()
          Returns the root (=this) of the role hierarchy.
 boolean isEntityEquivalentWith(RoleProtocol anotherObject)
          Examines whether the receiver represents the same role player as another object.
protected  void recordNewQualifiedRole(QualifiedRoleType role)
          Registers a new qualified role that the receiver should play.
protected  void recordNewRole(RoleType role)
          Registers a new (unqualified) role that the receiver's should play.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

roles

protected java.util.Hashtable roles
Contains (unqualified) role objects indentified by their role type name.

qualifiedRoles

protected java.util.Hashtable qualifiedRoles
Contains collections of qualified role objects identified by their role type name.
Constructor Detail

ObjectWithRoles

public ObjectWithRoles()
Method Detail

getRoot

public ObjectWithRoles getRoot()
Returns the root (=this) of the role hierarchy.
Specified by:
getRoot in interface RoleProtocol

getRegisteredRoleTypeNames

protected java.util.Enumeration getRegisteredRoleTypeNames()
Returns an enumeration of (unqualified) role type names, of which instances are currently registered with the receiver.

getRegisteredQualifiedRoleTypeNames

protected java.util.Enumeration getRegisteredQualifiedRoleTypeNames()
Returns an enumeration of qualified role type names, of which instances are currently registered with the receiver.

as

public RoleType as(java.lang.String roleTypeName)
            throws NoSuchRoleException
Returns an (unqualified) role object whose class is the role type with name roleTypeName. Throws a NoSuchRoleException if such a role object does not exist.
Specified by:
as in interface RoleProtocol
Parameters:
roleTypeName - fully qualified class name of the intended role type. The class name must be qualified by the package name, e.g., if class Employee belongs to package persons then "persons.Employee" would be the correct class name of that role type.

allAs

public java.util.Enumeration allAs(java.lang.String qualifiedRoleTypeName)
                            throws NoSuchRoleException
Returns an enumeration of qualified role objects whose class is the qualified role type with name qualifiedRoleTypeName.
Specified by:
allAs in interface RoleProtocol
Parameters:
qualifiedRoleTypeName - fully qualified class name of the intended qualified role type. The class name must be qualified by the package name, e.g., if class Customer belongs to package persons then "persons.Customer" would be the correct class name of that qualified role type.

as

public QualifiedRoleType as(java.lang.String qualifiedRoleTypeName,
                            java.lang.Object qualifyingObject)
                     throws NoSuchRoleException
Returns an instance of the qualified role type with name qualifiedRoleTypeName whose qualifier is identical with qualifyingObject. Throws a NoSuchRoleException if no such qualifying role object exists for the receiver.
Specified by:
as in interface RoleProtocol
Parameters:
qualifiedRoleTypeName - fully qualified class name of the intended qualified role type. The class name must be qualified by the package name, e.g., if class Customer belongs to package persons then "persons.Customer" would be the correct class name of that qualified role type.
qualifyingObject - represents the qualifier

existsAs

public boolean existsAs(java.lang.String roleTypeName)
Examines whether an instance of a particular role type has been registered as a role of the receiver.
Specified by:
existsAs in interface RoleProtocol
Parameters:
roleTypeName - Represents the Java class name of the role type. The class name must be fully qualified with the package name, e.g., if class Person belongs to package persons then "persons.Person" would be the correct class name.

existsAs

public boolean existsAs(java.lang.String qualifiedRoleTypeName,
                        java.lang.Object qualifyingObj)
Examines whether an instance of the qualified role type with name qualifiedRoleTypeName has been registered by the receiver using qualifier qualifyingObj.
Specified by:
existsAs in interface RoleProtocol

isEntityEquivalentWith

public boolean isEntityEquivalentWith(RoleProtocol anotherObject)
Examines whether the receiver represents the same role player as another object.
Specified by:
isEntityEquivalentWith in interface RoleProtocol
Parameters:
anotherObject - represent the object to be compared with

cancelQualifiedRole

protected void cancelQualifiedRole(QualifiedRoleType role)
Deregisters a qualified role that the receiver is currently playing.
Parameters:
role - represents the role object to cancel

cancelRole

protected void cancelRole(RoleType role)
Deregisters an (unqualified) role that the receiver is currently playing.
Parameters:
role - represents the role object to cancel

recordNewQualifiedRole

protected void recordNewQualifiedRole(QualifiedRoleType role)
                               throws DuplicateRoleException
Registers a new qualified role that the receiver should play.
Parameters:
role - represents the new qualified role object

recordNewRole

protected void recordNewRole(RoleType role)
                      throws DuplicateRoleException
Registers a new (unqualified) role that the receiver's should play.
Parameters:
role - represents the new role object