org.starhope.appius.sql
Class SQLPeerEnum

java.lang.Object
  extended by org.starhope.appius.util.ManagedReferenceHolder
      extended by org.starhope.appius.sql.SQLPeerDatum
          extended by org.starhope.appius.sql.SQLPeerEnum
Direct Known Subclasses:
AvatarClass, Currency

public abstract class SQLPeerEnum
extends SQLPeerDatum

This is a class for infrequently-changed objects that are enumerated types referenced by integer ID columns. Things like the set of available avatar classes fall into this category.

Author:
brpocock

Field Summary
protected static ConcurrentHashMap<Integer,String> enumeration
          enumeration of all possible values
protected  int instance
          instance ID
(package private) static int tinySpinner
           
 
Constructor Summary
  SQLPeerEnum()
          TODO
protected SQLPeerEnum(int id)
          TODO
 
Method Summary
protected  void cache(ResultSet set)
          This method caches into the internal "enumeration" hashmap the results of an SQL query specific to this SQLPeerEnum class of object.
protected  String getCacheUniqueID()
          This is an overriding method.
 int getID()
          WRITEME: document this method (brpocock, Aug 14, 2009)
static int getID(String s)
          WRITEME: document this method (brpocock, Jul 8, 2009)
protected abstract  PreparedStatement getStatement(Connection connection)
          WRITEME: document this method (brpocock, Aug 14, 2009)
 String getString()
           
static String getString(int id)
          WRITEME: document this method (brpocock, Jul 8, 2009)
protected  void prepCache()
           
 org.json.JSONObject toJSON()
          This is an overriding method.
 
Methods inherited from class org.starhope.appius.sql.SQLPeerDatum
changed, findInCache, flush, get, prepare, prepare, saveInCache, set, set
 
Methods inherited from class org.starhope.appius.util.ManagedReferenceHolder
deref, setRef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

enumeration

protected static final ConcurrentHashMap<Integer,String> enumeration
enumeration of all possible values


tinySpinner

static int tinySpinner

instance

protected int instance
instance ID

Constructor Detail

SQLPeerEnum

public SQLPeerEnum()
TODO


SQLPeerEnum

protected SQLPeerEnum(int id)
TODO

Parameters:
id - the specific ID
Method Detail

getID

public static int getID(String s)
WRITEME: document this method (brpocock, Jul 8, 2009)

Parameters:
s - the string value for which to search
Returns:
the ID (number) of the string value, or -1 if it's not found

getString

public static String getString(int id)
WRITEME: document this method (brpocock, Jul 8, 2009)

Parameters:
id - The value
Returns:
the string related to that value

cache

protected void cache(ResultSet set)
              throws SQLException
This method caches into the internal "enumeration" hashmap the results of an SQL query specific to this SQLPeerEnum class of object. The ResultSet must have a long (probably INT UNSIGNED) in the first column of the results, and the string value for it in column 1.

Parameters:
set - The ResultSet from the SQL query
Throws:
SQLException - if anything goes wrong from the query

getCacheUniqueID

protected String getCacheUniqueID()
This is an overriding method.

Specified by:
getCacheUniqueID in class SQLPeerDatum
Returns:
The local (Stringified) version of an unique ID; usually the database ID column
See Also:
SQLPeerDatum.getCacheUniqueID()

getID

public int getID()
WRITEME: document this method (brpocock, Aug 14, 2009)

Returns:

getStatement

protected abstract PreparedStatement getStatement(Connection connection)
WRITEME: document this method (brpocock, Aug 14, 2009)

Parameters:
connection -
Returns:

getString

public String getString()

prepCache

protected void prepCache()

toJSON

public org.json.JSONObject toJSON()
This is an overriding method.

Overrides:
toJSON in class SQLPeerDatum
Returns:
See Also:
SQLPeerDatum.toJSON()