roles
Class RoleType

java.lang.Object
  |
  +--roles.RoleType
Direct Known Subclasses:
QualifiedRoleType

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

This class is the root for any class representing a particular (unqualified) role type. An instance of this class r1 can be the role of a role playing object o, if there exists no other instance of this class r2, whose role player is o too. If this constraint is violated, a DuplicateRoleException is thrown by the constructor. Multiple occurrences of the same role type for a particular role player must be defined using QualifiedRoleType as the superclass.


Field Summary
protected  RoleProtocol roleOf
          References the role player.
protected  ObjectWithRoles root
          References the root of the role hierarchy.
protected  java.util.Vector subroles
          Represents all role objects that refer to this object by their roleOf instance variable.
 
Constructor Summary
protected RoleType()
           
  RoleType(RoleProtocol ancestor)
          This constructor establishes the roleOf relationship between the newly created role object and the role player.
 
Method Summary
 void abandon()
          Abandons the roleOf relationship between the receiver and its role player.
 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.
 void cancelRole(RoleType role)
          Removes a role from the receiver's subroles and informs the root to cancel that role.
 boolean existsAs(java.lang.String roleTypeName)
          Examines whether an instance of the role type with name roleTypeName has been registered by the receiver.
 boolean existsAs(java.lang.String qualifiedRoleTypeName, java.lang.Object qualifyingObj)
          Examines whether an instance of a particular qualified role type has been registered by the receiver using a particular qualifier
protected static boolean existsInheritance(java.lang.String className1, java.lang.String className2)
          Examines whether there exists any kind of inheritance relationship between two classes with names className1 and className2.
protected static boolean existsSubclassInheritance(java.lang.String superClassName, java.lang.String subClassName)
          Examines whether class with name superClassName is a superclass of class with name subClassName.
 RoleProtocol getRoleOf()
          Returns the ancestor of this role object (may be an ObjectWithRoles or another RoleType).
 java.lang.String getRoleTypeName()
          Returns the fully qualified Java class name as the role type name.
 ObjectWithRoles getRoot()
          Returns the root of the role hierarchy (must be an ObjectWithRoles).
 boolean isEntityEquivalentWith(RoleProtocol anotherObject)
          Examines whether the receiver and anotherObject represent the same role player.
protected  void nullify()
          Unsets the references to the root, the ancestor, and all subroles.
protected  void recordNewQualifiedRole(QualifiedRoleType role)
          Adds a newly created qualified role object to the vector representing the receiver's subroles.
protected  void recordNewRole(RoleType role)
          Adds a newly created role object to the vector representing the receiver's subroles.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

roleOf

protected RoleProtocol roleOf
References the role player.

subroles

protected java.util.Vector subroles
Represents all role objects that refer to this object by their roleOf instance variable.

root

protected ObjectWithRoles root
References the root of the role hierarchy.
Constructor Detail

RoleType

protected RoleType()
            throws DuplicateRoleException

RoleType

public RoleType(RoleProtocol ancestor)
         throws DuplicateRoleException
This constructor establishes the roleOf relationship between the newly created role object and the role player. Throws a DuplicateRoleException if a role object of this role type already exists for the ancestor.
Parameters:
ancestor - represents the role player, this parameter may be either an instance of a subclass of ObjectWithRoles or an instance of a subclass of RoleType (both classes implement RoleProtocol)
Method Detail

recordNewQualifiedRole

protected void recordNewQualifiedRole(QualifiedRoleType role)
                               throws DuplicateRoleException
Adds a newly created qualified role object to the vector representing the receiver's subroles.

recordNewRole

protected void recordNewRole(RoleType role)
                      throws DuplicateRoleException
Adds a newly created role object to the vector representing the receiver's subroles.
Parameters:
role - represents the newly created role to be recorded

getRoleTypeName

public java.lang.String getRoleTypeName()
Returns the fully qualified Java class name as the role type name.

cancelRole

public void cancelRole(RoleType role)
Removes a role from the receiver's subroles and informs the root to cancel that role.
Parameters:
role - represents the role object to be canceled

nullify

protected void nullify()
Unsets the references to the root, the ancestor, and all subroles.

existsSubclassInheritance

protected static boolean existsSubclassInheritance(java.lang.String superClassName,
                                                   java.lang.String subClassName)
Examines whether class with name superClassName is a superclass of class with name subClassName. The class names must be qualified with the package name, e.g., if class Person belongs to package persons then "persons.Person" would be the correct class name.
Parameters:
superClassName - fully qualified class name of assumed superclass
subClassName - fully qualified class name of assumed subclass

existsInheritance

protected static boolean existsInheritance(java.lang.String className1,
                                           java.lang.String className2)
Examines whether there exists any kind of inheritance relationship between two classes with names className1 and className2. Returns true if the class with name className1 is a superclass or a subclass of class with name className2. The class names must be qualified by the package name, e.g., if class Person belongs to package persons then "persons.Person" would be the correct class name.
Parameters:
className1 - fully qualified class name of first class
className2 - fully qualified class name of second class

abandon

public void abandon()
Abandons the roleOf relationship between the receiver and its role player.

getRoot

public ObjectWithRoles getRoot()
Returns the root of the role hierarchy (must be an ObjectWithRoles).
Specified by:
getRoot in interface RoleProtocol

getRoleOf

public RoleProtocol getRoleOf()
Returns the ancestor of this role object (may be an ObjectWithRoles or another RoleType).

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 the role type with name roleTypeName has been registered by the receiver.
Specified by:
existsAs in interface RoleProtocol

existsAs

public boolean existsAs(java.lang.String qualifiedRoleTypeName,
                        java.lang.Object qualifyingObj)
Examines whether an instance of a particular qualified role type has been registered by the receiver using a particular qualifier
Specified by:
existsAs in interface RoleProtocol
Parameters:
qualifiedRoleTypeName - represent the class name of the qualified 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.
qualifyingObj - represents the qualifier.

isEntityEquivalentWith

public boolean isEntityEquivalentWith(RoleProtocol anotherObject)
Examines whether the receiver and anotherObject represent the same role player.
Specified by:
isEntityEquivalentWith in interface RoleProtocol