com.autonomy.utilities
Class League

java.lang.Object
  |
  +--com.autonomy.utilities.League

public class League
extends java.lang.Object

This class maintains a list of objects and scores. Scores can be added and subtracted and at any point a Vector of entries sorted by score can be returned.

Also 'spare' data can be associated with eache league key.


Field Summary
 java.util.Vector m_vLeague
           
 
Constructor Summary
League()
          Create an empty league structure
League(java.util.Hashtable htIn)
          Create a league structure from an existing Hashtable.
 
Method Summary
 boolean add(com.autonomy.utilities.LeagueEntry entry)
          Add to the league the given LeagueEntry
 boolean add(java.lang.String sName, int nScore)
          Add nScore to sNames points total
 void addSpareData(java.lang.String sKey, java.lang.String sName, java.lang.Object oToAdd)
          Adds to the repository for spare data.
 void display()
          Writes the league to stdout
 java.util.Hashtable getHashtable()
          Returns the hashtable object
 int getScore(java.lang.String sName)
          Returns the current score in the league for sName A return value of -1 means there is no entry called sName in the league
 java.lang.Object getSpareData(java.lang.String sKey, java.lang.String sName)
          Retrieves spare data
 java.util.Vector makeLeagueTable()
          The returned vector is a list of entries in the league, sorted by score.
 java.util.Vector makeLeagueTable(java.lang.String sSpareKey)
          The returned vector is a list of entries in the league, sorted by score.
 void setMaxScore(int nMaxScore)
          Sets a maximum score acheivable in the league Non-positive scores are ignored
 boolean subtract(com.autonomy.utilities.LeagueEntry entry)
          Subtract from the league the given LeagueEntry
 boolean subtract(java.lang.String sName, int nScore)
          subtract nScore from sNames points total
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_vLeague

public java.util.Vector m_vLeague
Constructor Detail

League

public League()
Create an empty league structure


League

public League(java.util.Hashtable htIn)
Create a league structure from an existing Hashtable. The hashtables keys must be Strings and the values must be Integers

Method Detail

add

public boolean add(java.lang.String sName,
                   int nScore)
Add nScore to sNames points total

Returns:
true if sName is already in the league, false if sName was just added

add

public boolean add(com.autonomy.utilities.LeagueEntry entry)
Add to the league the given LeagueEntry

Returns:
true if sName is already in the league, false if sName was just added

subtract

public boolean subtract(com.autonomy.utilities.LeagueEntry entry)
Subtract from the league the given LeagueEntry

Returns:
true if sName is already in the league, false if sName was just added

subtract

public boolean subtract(java.lang.String sName,
                        int nScore)
subtract nScore from sNames points total

Returns:
true if sName is already in the league, false if sName was just added

getScore

public int getScore(java.lang.String sName)
Returns the current score in the league for sName A return value of -1 means there is no entry called sName in the league


setMaxScore

public void setMaxScore(int nMaxScore)
Sets a maximum score acheivable in the league Non-positive scores are ignored


makeLeagueTable

public java.util.Vector makeLeagueTable()
The returned vector is a list of entries in the league, sorted by score.


makeLeagueTable

public java.util.Vector makeLeagueTable(java.lang.String sSpareKey)
The returned vector is a list of entries in the league, sorted by score.


display

public void display()
Writes the league to stdout


getHashtable

public java.util.Hashtable getHashtable()
Returns the hashtable object


addSpareData

public void addSpareData(java.lang.String sKey,
                         java.lang.String sName,
                         java.lang.Object oToAdd)
Adds to the repository for spare data. If this the first occurrence of a particular key, then the repository is created, otherwise it is added to the existing repository for this key name

Parameters:
sKey - Name of spare data repository
sName - name of the league entry to which the data belongs
oToAdd - Object to add

getSpareData

public java.lang.Object getSpareData(java.lang.String sKey,
                                     java.lang.String sName)
Retrieves spare data

Parameters:
sKey - Name of spare data repository
sName - name of the league entry to which the data belongs