com.yosokumo.core
Class Roster

java.lang.Object
  extended by com.yosokumo.core.Roster

public class Roster
extends java.lang.Object

For each study, a list of users that have a role on the study. A roster has these attributes:


Field Summary
private  java.util.Map<java.lang.String,Role> roleCollection
           
private  java.lang.String rosterLocation
           
private  java.lang.String studyIdentifier
           
private  java.lang.String studyName
           
 
Constructor Summary
Roster()
          Initializes a newly created Roster object with default attributes.
Roster(java.lang.String studyIdentifier, java.lang.String studyName)
          Initializes a newly created Roster object with attributes specified by the input parameters.
 
Method Summary
(package private)  Role addRole(Role role)
          Add a role to the roster.
(package private)  void clearRoles()
          Remove all roles from the roster.
 boolean containsRole(java.lang.String userIdentifier)
          Test if a role is in the roster.
 Role getRole(java.lang.String userIdentifier)
          Return a role from the roster.
 java.util.Collection<Role> getRoleCollection()
          Return all roles in the roster as a Collection<Role>.
(package private)  java.lang.String getRosterLocation()
          Return the roster location.
 java.lang.String getStudyIdentifier()
          Return the study identifier.
 java.lang.String getStudyName()
          Return the study name.
 java.util.Set<java.lang.String> getUserIdentifiersSet()
          Return the user identifiers of all the roles in the roster as a Set<String>.
 boolean isEmpty()
          Return true if the roster contains no roles.
(package private)  Role removeRole(java.lang.String userIdentifier)
          Remove a role from the roster.
(package private)  void setRosterLocation(java.lang.String loc)
          Set the roster location.
(package private)  void setStudyIdentifier(java.lang.String id)
          Set the study identifier.
(package private)  void setStudyName(java.lang.String name)
          Set the study name.
 int size()
          Return the number of roles in the roster.
 java.lang.String toString()
          Return a string representation of this Roster.
(package private)  java.lang.String toStringInternal(boolean showAll)
          Return a string representation of this Roster.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

studyIdentifier

private java.lang.String studyIdentifier

studyName

private java.lang.String studyName

rosterLocation

private java.lang.String rosterLocation

roleCollection

private java.util.Map<java.lang.String,Role> roleCollection
Constructor Detail

Roster

Roster()
Initializes a newly created Roster object with default attributes.


Roster

Roster(java.lang.String studyIdentifier,
       java.lang.String studyName)
Initializes a newly created Roster object with attributes specified by the input parameters.

Parameters:
studyIdentifier - the identifier of the study the roster is for.
studyName - the name of the study the roster is for.
Method Detail

setStudyIdentifier

void setStudyIdentifier(java.lang.String id)
Set the study identifier.

Parameters:
id - the identifier of the study to which the roster belongs. May be null.

getStudyIdentifier

public java.lang.String getStudyIdentifier()
Return the study identifier.

Returns:
the identifier of the study to which the roster belongs. May be null.

setStudyName

void setStudyName(java.lang.String name)
Set the study name.

Parameters:
name - the name of the study to which the roster belongs. May be null.

getStudyName

public java.lang.String getStudyName()
Return the study name.

Returns:
the name of the study to which the roster belongs. May be null.

setRosterLocation

void setRosterLocation(java.lang.String loc)
Set the roster location.

Parameters:
loc - the location to assign to this roster. May be null.

getRosterLocation

java.lang.String getRosterLocation()
Return the roster location.

Returns:
the location of this roster. May be null.

addRole

Role addRole(Role role)
Add a role to the roster. In all cases the Role parameter is added to the roster. The return value distinguishes two possibilities.

Parameters:
role - the Role to add to the roster.
Returns:
null means there was no role with the same user identifier already in the roster. non-null means that there was a role with the same user identifier already in the roster, and the return value is the old role which has been replaced by the new one.

removeRole

Role removeRole(java.lang.String userIdentifier)
Remove a role from the roster.

Parameters:
userIdentifier - the user identifier of the Role to remove from the roster.
Returns:
null means there was no role in the roster with the user identifier specified by the parameter; the roster is left unchanged. non-null means that there was a role in the roster with the user identifier specified by the parameter; the role has been removed from the roster, and the return value is the removed role.

clearRoles

void clearRoles()
Remove all roles from the roster. After a call of this method, the roster is empty, i.e., it contains no roles.


getRole

public Role getRole(java.lang.String userIdentifier)
Return a role from the roster.

Parameters:
userIdentifier - the identifier of the Role to get from the roster.
Returns:
null means there is no role in the roster with the user identifier specified by the parameter. non-null means that there is a role in the roster with the user identifier specified by the parameter, and the return value is the specified role.

containsRole

public boolean containsRole(java.lang.String userIdentifier)
Test if a role is in the roster.

Parameters:
userIdentifier - the identifier of the Role to test for.
Returns:
false means there is no role in the roster with the user identifier specified by the parameter. true means that there is a role in the roster with the user identifier specified by the parameter.

size

public int size()
Return the number of roles in the roster.

Returns:
the number of roles in the roster.

isEmpty

public boolean isEmpty()
Return true if the roster contains no roles.

Returns:
true if the roster contains no roles. false otherwise.

getUserIdentifiersSet

public java.util.Set<java.lang.String> getUserIdentifiersSet()
Return the user identifiers of all the roles in the roster as a Set<String>. This makes it possible to iterate over the role identifiers like this:
   for (String s : roster.getUserIdentifiersSet())
{ process role identifier s }

Returns:
a set of the user identifiers of all roles in the roster.

getRoleCollection

public java.util.Collection<Role> getRoleCollection()
Return all roles in the roster as a Collection<Role>. This makes it possible to iterate over all roles in the roster like this:
   for (Role r : roster.getRoleCollection())
   {
       process role r
   }
 

Returns:
a collection of all roles in the roster.

toString

public java.lang.String toString()
Return a string representation of this Roster. Note that for a role in the roster only the role identifier is represented as a string, not the entire role.

Overrides:
toString in class java.lang.Object
Returns:
the string representation of this Roster.

toStringInternal

java.lang.String toStringInternal(boolean showAll)
Return a string representation of this Roster. Note that for a role in the roster only the role identifier is represented as a string, not the entire role.

Parameters:
showAll - specifies if internal data members should be shown.
Returns:
the string representation of this Roster.