com.yosokumo.core
Class Catalog

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

public class Catalog
extends java.lang.Object

An index to all the studies on which a given user has a role. A catalog has these attributes:


Field Summary
private  java.lang.String catalogLocation
          URI of the catalog.
private  java.util.Map<java.lang.String,Study> studyCollection
          Collection of studies comprising the catalog.
private  java.lang.String userIdentifier
          Identifier of the user to whom the catalog belongs.
private  java.lang.String userName
          User name of the user to whom the catalog belongs.
 
Constructor Summary
Catalog()
          Initializes a newly created Catalog object with default attributes.
Catalog(java.lang.String userIdentifier, java.lang.String userName)
          Initializes a newly created Catalog object with attributes specified by the input parameters.
 
Method Summary
(package private)  Study addStudy(Study study)
          Add a study to the catalog.
(package private)  void clearStudies()
          Remove all studies from the catalog.
 boolean containsStudy(java.lang.String studyIdentifier)
          Test if a study is in the catalog.
(package private) static Catalog copyCatalog(Catalog oldCatalog)
          Make a deep copy of a catalog.
(package private)  java.lang.String getCatalogLocation()
          Return the catalog location.
 Study getStudy(java.lang.String studyIdentifier)
          Return a study from the catalog.
 java.util.Collection<Study> getStudyCollection()
          Return all studies in the catalog as a Collection<Study>.
 java.util.Set<java.lang.String> getStudyIdentifiersSet()
          Return the identifiers of all the studies in the catalog as a Set<String>.
 java.lang.String getUserIdentifier()
          Return the user identifier.
 java.lang.String getUserName()
          Return the user name.
 boolean isEmpty()
          Return true if the catalog contains no studies.
(package private)  Study removeStudy(java.lang.String studyIdentifier)
          Remove a study from the catalog.
(package private)  void setCatalogLocation(java.lang.String loc)
          Set the catalog location.
(package private)  void setUserIdentifier(java.lang.String id)
          Set the user identifier.
(package private)  void setUserName(java.lang.String name)
          Set the user name.
 int size()
          Return the number of studies in the catalog.
 java.lang.String toString()
          Return a string representation of this Catalog.
(package private)  java.lang.String toStringInternal(boolean showAll)
          Return a string representation of this Catalog.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

userIdentifier

private java.lang.String userIdentifier
Identifier of the user to whom the catalog belongs.


userName

private java.lang.String userName
User name of the user to whom the catalog belongs.


catalogLocation

private java.lang.String catalogLocation
URI of the catalog.


studyCollection

private java.util.Map<java.lang.String,Study> studyCollection
Collection of studies comprising the catalog.

Constructor Detail

Catalog

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


Catalog

Catalog(java.lang.String userIdentifier,
        java.lang.String userName)
Initializes a newly created Catalog object with attributes specified by the input parameters.

Parameters:
userIdentifier - the unique identifier for the user.
userName - the name of the user.
Method Detail

copyCatalog

static Catalog copyCatalog(Catalog oldCatalog)
Make a deep copy of a catalog.

Parameters:
oldCatalog - the catalog to copy.
Returns:
a deep copy of oldCatalog.

setUserIdentifier

void setUserIdentifier(java.lang.String id)
Set the user identifier.

Parameters:
id - the identifier of the user to whom the catalog belongs. May be null.

getUserIdentifier

public java.lang.String getUserIdentifier()
Return the user identifier.

Returns:
the identifier of the user to whom the catalog belongs. May be null.

setUserName

void setUserName(java.lang.String name)
Set the user name.

Parameters:
name - the name of the user to whom the catalog belongs. May be null.

getUserName

public java.lang.String getUserName()
Return the user name.

Returns:
the name of the user to whom the catalog belongs. May be null.

setCatalogLocation

void setCatalogLocation(java.lang.String loc)
Set the catalog location.

Parameters:
loc - the location of this catalog. May be null.

getCatalogLocation

java.lang.String getCatalogLocation()
Return the catalog location.

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

addStudy

Study addStudy(Study study)
Add a study to the catalog. In all cases the Study parameter is added to the catalog. The return value distinguishes two possibilities.

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

removeStudy

Study removeStudy(java.lang.String studyIdentifier)
Remove a study from the catalog.

Parameters:
studyIdentifier - the identifier of the Study to remove from the catalog.
Returns:
null means there was no study in the catalog with the identifier specified by the parameter; the catalog is left unchanged. non-null means that there was a study in the catalog with the identifier specified by the parameter; the study has been removed from the catalog, and the return value is the removed study.

clearStudies

void clearStudies()
Remove all studies from the catalog. After a call of this method, the catalog is empty, i.e., it contains no studies.


getStudy

public Study getStudy(java.lang.String studyIdentifier)
Return a study from the catalog.

Parameters:
studyIdentifier - the identifier of the Study to get from the catalog.
Returns:
null means there is no study in the catalog with the identifier specified by the parameter. non-null means that there is a study in the catalog with the identifier specified by the parameter, and the return value is the specified study.

containsStudy

public boolean containsStudy(java.lang.String studyIdentifier)
Test if a study is in the catalog.

Parameters:
studyIdentifier - the identifier of the Study to test for.
Returns:
false means there is no study in the catalog with the identifier specified by the parameter. true means that there is a study in the catalog with the identifier specified by the parameter.

size

public int size()
Return the number of studies in the catalog.

Returns:
the number of studies in the catalog.

isEmpty

public boolean isEmpty()
Return true if the catalog contains no studies.

Returns:
true if the catalog contains no studies. false otherwise.

getStudyIdentifiersSet

public java.util.Set<java.lang.String> getStudyIdentifiersSet()
Return the identifiers of all the studies in the catalog as a Set<String>. This makes it possible to iterate over the study identifiers like this:
   for (String s : catalog.getStudyIdentifiersSet())
{ process study identifier s }

Returns:
a set of the identifiers of all studies in the catalog.

getStudyCollection

public java.util.Collection<Study> getStudyCollection()
Return all studies in the catalog as a Collection<Study>. This makes it possible to iterate over all studies in the catalog like this:
   for (Study s : catalog.getStudyCollection())
   {
       process study s
   }
 

Returns:
a collection of all studies in the catalog.

toString

public java.lang.String toString()
Return a string representation of this Catalog. Note that for a study in the catalog only the study identifier and study name are represented as a string, not the entire study.

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

toStringInternal

java.lang.String toStringInternal(boolean showAll)
Return a string representation of this Catalog. Note that for a study in the catalog only the study identifier and study name are represented as a string, not the entire study.

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