net.sourceforge.jsurveyor
Class UserComponent

java.lang.Object
  extended bynet.sourceforge.jsurveyor.UserComponent
Direct Known Subclasses:
User, UserGroup

public abstract class UserComponent
extends java.lang.Object

Class to handle the composite structure of users and usergroups

Version:
1.0
Author:
Claus Methmann Christensen, Anders Spliid Hansen, Esben Iversen Hansen, Lars H Jensen, Marcus Overheu, Thomas Ramdal, Peter Thomsen

Constructor Summary
UserComponent()
          Constructor for UserComponent
UserComponent(java.util.ArrayList refChildren, java.util.ArrayList refParents)
          Constructor for UserComponent
 
Method Summary
 void addChild(UserComponent userComponent)
          Adds a child.
 void addParent(UserComponent userComponent)
          Adds a parent to the userComponent in the composite structure.
 void clearParents()
          Removes all parents for the userComponent.
 boolean equals(UserComponent userComponent)
          Equals method that overrides the default Object.equals().
 java.util.ArrayList getParents()
          Returns an ArrayList with toString representation of the added parents.
 java.util.ArrayList getRefChildren()
          Returns an ArrayList with toString representations of the added children.
 java.util.ArrayList getRefParents()
          Returns an ArrayList with toString representations of the added parents.
 boolean isRefParentsEmpty()
          Checks whether or not any parents is added.
 void removeChild(UserComponent userComponent)
          Removes the userComponent from child list.
 void removeParent(UserComponent userComponent)
          Removes a parent from the userComponent.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserComponent

public UserComponent()
Constructor for UserComponent


UserComponent

public UserComponent(java.util.ArrayList refChildren,
                     java.util.ArrayList refParents)
Constructor for UserComponent

Parameters:
refChildren - ArrayList
refParents - ArrayList
Method Detail

addParent

public void addParent(UserComponent userComponent)
               throws java.lang.ArrayStoreException
Adds a parent to the userComponent in the composite structure.

Parameters:
userComponent - UserComponent
Throws:
java.lang.ArrayStoreException
PRE condition:
the input must be a userGroup., the userComponent must be added as a parent already., if the method is run from a usergroup it must not have a parent when the method is called.

clearParents

public void clearParents()
Removes all parents for the userComponent.


removeParent

public void removeParent(UserComponent userComponent)
Removes a parent from the userComponent.

Parameters:
userComponent - UserComponent
PRE condition:
the input must be an instance of userGroup, the userGroup must be added as a parent.

getParents

public java.util.ArrayList getParents()
Returns an ArrayList with toString representation of the added parents.

Returns:
ArrayList

addChild

public void addChild(UserComponent userComponent)
Adds a child.

Parameters:
userComponent - UserComponent
PRE condition:
the userComponent must not already be added., the method must only be called on instances of userGroups.

removeChild

public void removeChild(UserComponent userComponent)
Removes the userComponent from child list.

Parameters:
userComponent - UserComponent
PRE condition:
the method must only be called on instances of userGroups., the usercomponent must be added as a child.

getRefChildren

public java.util.ArrayList getRefChildren()
Returns an ArrayList with toString representations of the added children.

Returns:
ArrayList

getRefParents

public java.util.ArrayList getRefParents()
Returns an ArrayList with toString representations of the added parents.

Returns:
ArrayList

isRefParentsEmpty

public boolean isRefParentsEmpty()
Checks whether or not any parents is added.

Returns:
boolean

equals

public boolean equals(UserComponent userComponent)
Equals method that overrides the default Object.equals(). Necessary for the reference implementation of the composite pattern.

Parameters:
userComponent - UserComponent
Returns:
boolean