org.jogre.common
Class UserList

java.lang.Object
  extended byjava.util.Observable
      extended byorg.jogre.common.UserList
All Implemented Interfaces:
ITransmittable

public class UserList
extends Observable
implements ITransmittable

Transmittable user list data object. Contains the a HashMap of users.

Version:
Alpha 0.2.3
Author:
Bob Marks

Field Summary
protected  HashMap userlist
          List of users.
 
Constructor Summary
UserList()
          Default constructor of a UserList object.
UserList(XMLElement message)
          Constructor which reads a user list from a String.
 
Method Summary
 void addUser(User user)
          Creates a new User using a username and a rating and adds to the HashMap.
 boolean containsUser(String username)
          Return true if the user list contains this user.
 XMLElement flatten()
          Flatten the current list of logged on users.
 User getUser(String username)
          Return a user object from a username.
 Vector getUserObjects()
          Return the user objects.
 Vector getUsers()
          Returns a list of all the users.
 void refreshObservers()
          Notify observers.
 void removeUser(String username)
          Remove user from the list.
 int size()
          Return the number of users.
 String toString()
          Return String version of the userList.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

userlist

protected HashMap userlist
List of users.

Constructor Detail

UserList

public UserList()
Default constructor of a UserList object.


UserList

public UserList(XMLElement message)
         throws TransmissionException
Constructor which reads a user list from a String.

Parameters:
message - XML element version of object.
Throws:
TransmissionException - Thrown if there is a problem in transmission.
Method Detail

addUser

public void addUser(User user)
Creates a new User using a username and a rating and adds to the HashMap.


removeUser

public void removeUser(String username)
Remove user from the list.

Parameters:
username -

containsUser

public boolean containsUser(String username)
Return true if the user list contains this user.

Parameters:
username - Username to check for in the list.
Returns:
True if list contains the username as a key.

getUsers

public Vector getUsers()
Returns a list of all the users.

Returns:
List of users as Strings in a Vector.

getUserObjects

public Vector getUserObjects()
Return the user objects.

Returns:

getUser

public User getUser(String username)
Return a user object from a username.

Parameters:
username - Username to search on
Returns:
User object if found.

flatten

public XMLElement flatten()
Flatten the current list of logged on users.

Specified by:
flatten in interface ITransmittable
Returns:
XML version of the state of an object which can be constructed again.
See Also:
ITransmittable.flatten()

size

public int size()
Return the number of users.

Returns:
Number of users (between 0 and GameProperties.getMaxNumOfUsers()).

toString

public String toString()
Return String version of the userList.

See Also:
Object.toString()

refreshObservers

public void refreshObservers()
Notify observers.

See Also:
Observable.notifyObservers()