com.gtosoft.libvoyager.util
Class GeneralStats

java.lang.Object
  extended by com.gtosoft.libvoyager.util.GeneralStats

public class GeneralStats
extends java.lang.Object

This class will be used for stats collection across many classes such as elmbt, and the session layers. The idea is to have a common data type (this class) which we can funnel up to a higher level (hybridSession).

Author:
brad

Constructor Summary
GeneralStats()
           
 
Method Summary
 java.lang.String getAllStats()
          Produce a big string (CRLF line termination) which contains all stats contatined herein.
 java.lang.String getStat(java.lang.String statKey)
          Used to obtain a single stat from our hashmap.
 java.util.HashMap<java.lang.String,java.lang.String> getStats()
          Returns a new hashmap which contains a snapshot of the contents of our stats hashmap.
 java.util.HashMap<java.lang.String,java.lang.String> getStatsAsHashmap()
          Returns a new (thread-safe) hashmap containing all of our stats.
 boolean merge(java.lang.String tag, GeneralStats gs)
          Use this method to merge other GeneralStats data into your instance.
 java.util.HashMap<java.lang.String,java.lang.String> setStat(java.lang.String key, java.lang.String value)
          A single point to get (all stats at once) or set one stat at a time.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneralStats

public GeneralStats()
Method Detail

setStat

public java.util.HashMap<java.lang.String,java.lang.String> setStat(java.lang.String key,
                                                                    java.lang.String value)
A single point to get (all stats at once) or set one stat at a time. We can synchronize this function if needed. For now, don't, because it is a ton of overhead that's not needed.

Parameters:
key -
value -
Returns:
- returns the global hashmap of stats. If key is blank ("") then we return A COPY OF our local stats. This is a special case used when returning stats to a calling method.

getStatsAsHashmap

public java.util.HashMap<java.lang.String,java.lang.String> getStatsAsHashmap()
Returns a new (thread-safe) hashmap containing all of our stats.

Returns:
- returns a new hashmap containing all our stats.

getStats

public java.util.HashMap<java.lang.String,java.lang.String> getStats()
Returns a new hashmap which contains a snapshot of the contents of our stats hashmap. we return a copy of our stats hashmap so that the caller can do as they please with the information and not worry about concurrent modifications.

Returns:

merge

public boolean merge(java.lang.String tag,
                     GeneralStats gs)
Use this method to merge other GeneralStats data into your instance.

Parameters:
tag - - a unique tag to identify the stats you're merging
gs - - a generalstats instance which is to be merged.
Returns:
- true on success, false otherwise.

getStat

public java.lang.String getStat(java.lang.String statKey)
Used to obtain a single stat from our hashmap.

Returns:
- returns "" if the stat is not found, otherwise the exact value of the stat from the hashmap.

getAllStats

public java.lang.String getAllStats()
Produce a big string (CRLF line termination) which contains all stats contatined herein.

Returns:
- returns a big string with CRLF line delimiters.