org.jogre.common
Class TableList

java.lang.Object
  |
  +--org.jogre.common.TableList
All Implemented Interfaces:
ITransmittable

public class TableList
extends Object
implements ITransmittable

Contains a HashMap of all the Table objects currently in play. This class also implements the ITransmittable interface so this object can be transferred across the network.

Version:
Alpha 0.1
Author:
Bob Marks

Field Summary
static String TABLE_LIST
          Header token of String created from its ITransmittable.flatten() method.
protected  HashMap tablelist
          HashMap contain a number of Table objects.
 
Constructor Summary
TableList()
          Default constructor which sets up a brand new TableList object with no Tables in its HashMap.
TableList(String inString)
          Constructor which recreates a Table object using a String from the ITransmittable.flatten() method from another TableList object.
 
Method Summary
 void addTable(String username, boolean isPublic)
          Add a new Table object to the HashMap.
 Integer computeNewTableNum()
          Computes a new table number.
 String flatten()
          Flatten the current list of logged on users.
 Table getTable(int tableNum)
           
 int[] getTablesNumbers()
          Returns a list of all the table numbers.
 void removePlayer(int tableNum, String player)
          Remove a player from a table.
 void removeTable(int tableNum)
          Remove table from the list.
 void removeUserFromTables(String player)
           
 int size()
           
 void updateTable(int tableNum, Table table)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TABLE_LIST

public static final String TABLE_LIST
Header token of String created from its ITransmittable.flatten() method.

tablelist

protected HashMap tablelist
HashMap contain a number of Table objects. They key is an Integer object of the table number.
Constructor Detail

TableList

public TableList()
Default constructor which sets up a brand new TableList object with no Tables in its HashMap.

TableList

public TableList(String inString)
          throws TransmissionException
Constructor which recreates a Table object using a String from the ITransmittable.flatten() method from another TableList object.
Parameters:
inString - String representation of a TableList object
Throws:
TransmissionException -  
Method Detail

addTable

public void addTable(String username,
                     boolean isPublic)
Add a new Table object to the HashMap. The Table object is created using the parameters username, isPublic and a computed table number which is generated using the computeNewTableNum() method. This Table object is then stored in a HashMap with this computed table number (Integer) as its key.
Parameters:
username -  
isPublic -  

removeTable

public void removeTable(int tableNum)
Remove table from the list. This is usually called when all the users leave a particular table for example.
Parameters:
tableNum - Number of the table to be removed.

removePlayer

public void removePlayer(int tableNum,
                         String player)
Remove a player from a table. If the player is the last player to leave the table OR if this player is the owner of the table then the table will also be removed from the HashMap.
Parameters:
tableNum - Table number.
player -  

removeUserFromTables

public void removeUserFromTables(String player)
Parameters:
player -  

getTable

public Table getTable(int tableNum)
Parameters:
tableNum -  
Returns:
 

getTablesNumbers

public int[] getTablesNumbers()
Returns a list of all the table numbers.
Returns:
 

updateTable

public void updateTable(int tableNum,
                        Table table)
Parameters:
tableNum -  
table -  

size

public int size()
Returns:
 

computeNewTableNum

public Integer computeNewTableNum()
Computes a new table number.
Returns:
 

flatten

public String flatten()
Flatten the current list of logged on users.
Specified by:
flatten in interface ITransmittable
See Also:
ITransmittable.flatten()