nz.ac.waikato.mcennis.rat.graph.actor
Class BasicUser

java.lang.Object
  extended by nz.ac.waikato.mcennis.rat.graph.model.ModelShell
      extended by nz.ac.waikato.mcennis.rat.graph.actor.BasicUser
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, Actor, Model, ParsedObject

public class BasicUser
extends ModelShell
implements Actor

See Also:
Serialized Form

Field Summary
 
Fields inherited from class nz.ac.waikato.mcennis.rat.graph.model.ModelShell
listener
 
Constructor Summary
BasicUser(java.lang.String ID)
          Creates a new instance of BasicUser
 
Method Summary
 void add(Page p)
          Add a Page object to this class.
 void add(Property prop)
          Add the given property to this user.
protected  int comparePages(Actor right)
          Compare pages of this actor with the given actor.
protected  int compareProperties(Actor right)
          Compare properties of this actor with the given actor.
 int compareTo(java.lang.Object o)
          Throws ClassCastException when the parameter is not an Actor.
 Actor duplicate()
          Return a copy of this Actor that is equal by compareTo()
 boolean equals(java.lang.Object obj)
          implements equals in terms of CompareTo
 java.lang.String getID()
          Return the id (unique within its type)
 Page[] getPage()
          Returns the set of all page objects associated with this actor or null if no page objects havee been created
 Page getPage(java.lang.String ID)
          Return the page with the given ID (usually a URI String) or null iuf it doesn't exist
 Property[] getProperty()
          Return an array of all properties associated with this actor.
 Property getProperty(java.lang.String ID)
          Return the property with the given value.
 java.lang.String getType()
          Returns the type (mode) of this actor
 int hashCode()
           
 void removeProperty(java.lang.String ID)
          Remove a given property from this actor
 void setID(java.lang.String id)
          Sets an id unique (which must be its type).
 void setType(java.lang.String type)
          Set the type (mode) of this actor.
 java.lang.String toString()
           
 
Methods inherited from class nz.ac.waikato.mcennis.rat.graph.model.ModelShell
addListener, fireChange
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicUser

public BasicUser(java.lang.String ID)
Creates a new instance of BasicUser

Method Detail

getID

public java.lang.String getID()
Description copied from interface: Actor
Return the id (unique within its type)

Specified by:
getID in interface Actor
Returns:
ID of this actor

getPage

public Page[] getPage()
Description copied from interface: Actor
Returns the set of all page objects associated with this actor or null if no page objects havee been created

Specified by:
getPage in interface Actor
Returns:
array of Page objects

add

public void add(Page p)
Description copied from interface: Actor
Add a Page object to this class. If another Page with the same ID exists, it is overwritten by this class.

Specified by:
add in interface Actor
Parameters:
p - Page to be added.

getProperty

public Property[] getProperty()
Description copied from interface: Actor
Return an array of all properties associated with this actor. Returns null if no properties are attached.

Specified by:
getProperty in interface Actor
Returns:
array of properties

getPage

public Page getPage(java.lang.String ID)
Description copied from interface: Actor
Return the page with the given ID (usually a URI String) or null iuf it doesn't exist

Specified by:
getPage in interface Actor
Parameters:
ID - id of the page to be returned
Returns:
page with the given id

getProperty

public Property getProperty(java.lang.String ID)
Description copied from interface: Actor
Return the property with the given value. Returns null if no properties are attached.

Specified by:
getProperty in interface Actor
Parameters:
ID - key-name for the property.
Returns:
Property object having this key or null

removeProperty

public void removeProperty(java.lang.String ID)
Description copied from interface: Actor
Remove a given property from this actor

Specified by:
removeProperty in interface Actor
Parameters:
ID - key-name of property to remove.

add

public void add(Property prop)
Description copied from interface: Actor
Add the given property to this user. If a property with this name already exists, it is replaced by this property.

Specified by:
add in interface Actor
Parameters:
prop - property to be added

setType

public void setType(java.lang.String type)
Description copied from interface: Actor
Set the type (mode) of this actor. User ID's must be unique within a type.

Specified by:
setType in interface Actor
Parameters:
type - new type (mode) of this actor

getType

public java.lang.String getType()
Description copied from interface: Actor
Returns the type (mode) of this actor

Specified by:
getType in interface Actor
Returns:
type (mode) of this actor

compareTo

public int compareTo(java.lang.Object o)
Throws ClassCastException when the parameter is not an Actor. Comparisons are:
  1. String compareTo on type (mode)
  2. String compareTo on ID
  3. Property comparison: return compareTo on the first pair of properties that do not return 0
  4. Page comparison: return compareTo on the first pair of pages that do not return 0
  5. return 0

Specified by:
compareTo in interface java.lang.Comparable

compareProperties

protected int compareProperties(Actor right)
Compare properties of this actor with the given actor. Sort the property arrays and compare sequentially, returning the first non-zero value or returning zero if all properties are equal.

Parameters:
right - actor to be compared against
Returns:
compareTo over all properties

comparePages

protected int comparePages(Actor right)
Compare pages of this actor with the given actor. Sort the page arrays and compare sequentially, returning the first non-zero value or returning zero if all pages are equal.

Parameters:
right - actor to be compared against
Returns:
compareTo over all pages

equals

public boolean equals(java.lang.Object obj)
implements equals in terms of CompareTo

Specified by:
equals in interface Actor
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

setID

public void setID(java.lang.String id)
Description copied from interface: Actor
Sets an id unique (which must be its type).

Specified by:
setID in interface Actor
Parameters:
id - ID this actor should be set to

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

duplicate

public Actor duplicate()
Description copied from interface: Actor
Return a copy of this Actor that is equal by compareTo()

Specified by:
duplicate in interface Actor
Returns:
new duplicate Actor