org.starhope.appius.sql
Class SQLPeerEnum

java.lang.Object
  extended by org.starhope.appius.sql.SQLPeerDatum
      extended by org.starhope.appius.sql.SQLPeerEnum
All Implemented Interfaces:
Serializable, Comparable<Object>
Direct Known Subclasses:
GameFlagValue, MedalType, RoomBadge, SecurityCapability

Deprecated.

@Deprecated
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.

Note to Self: XXX On some future revision, it should be possible to (by contractual enforcement, since I don't think I can enforce this through Java inheritance, but I can put a runtime exception check on it) require implementors to register their class for reload events through a static initialiser and introduce a no-argument constructor.

e.g. ...

 protected SQLPeerEnum () {
        if ( !hasRegisteredClass (this.getClass ())) {
                throw new RuntimeExceptionAgainstBadImplementation (this
                                .getClass ());
        } // ...
 }
 

Author:
brpocock@star-hope.org
See Also:
Serialized Form

Field Summary
protected static ConcurrentHashMap<Class<? extends SQLPeerEnum>,ConcurrentHashMap<Integer,String>> enumeration
          Deprecated. enumeration of all possible values
private static ConcurrentHashMap<Class<? extends SQLPeerEnum>,Integer> hasCached
          Deprecated. Index of which classes have been cached already.
protected  int instance
          Deprecated. instance ID
private static HashSet<Class<? extends SQLPeerEnum>> knownChildren
          Deprecated. WRITEME: document this field (brpocock@star-hope.org, Dec 11, 2009) knownChildren (SQLPeerEnum)
private static long serialVersionUID
          Deprecated. WRITEME: document this field (brpocock@star-hope.org, Oct 13, 2009) serialVersionUID (long)
 
Constructor Summary
  SQLPeerEnum(Class<? extends SQLPeerEnum> klass)
          Deprecated. WRITEME
protected SQLPeerEnum(Class<? extends SQLPeerEnum> klass, int id)
          Deprecated. WRITEME
 
Method Summary
protected  void cache(ResultSet set)
          Deprecated. This method caches into the internal "enumeration" hashmap the results of an SQL query specific to this SQLPeerEnum class of object.
private  void doRealCacheReset()
          Deprecated. Actually flush the cache for all SQLPeerEnums
static void doRealCacheResetStatic()
          Deprecated. WRITEME: document this method (brpocock@star-hope.org, Dec 11, 2009)
 boolean equals(Object o)
          Deprecated. This is an overriding method.
 boolean equals(SQLPeerEnum o)
          Deprecated.  
static
<T extends SQLPeerEnum>
T
get(Class<T> klass, int id)
          Deprecated. WRITEME: document this method (brpocock@star-hope.org, Nov 19, 2009)
static
<T extends DataRecord>
T
Get(Class<T> klass, int id)
          Deprecated. use Nomenclator.getDataRecord(Class,int)
static
<T extends SQLPeerEnum>
T
get(Class<T> klass, String str)
          Deprecated. Get an instance of an enumerated type
static
<T extends DataRecord>
T
Get(Class<T> klass, String ident)
          Deprecated. use Nomenclator.getDataRecord(Class,String)
protected  String getCacheUniqueID()
          Deprecated. This is an overriding method.
protected  ConcurrentHashMap<Integer,String> getEnumeration()
          Deprecated.  
 int getID()
          Deprecated. WRITEME: document this method (brpocock@star-hope.org, Aug 14, 2009)
 int getID(String s)
          Deprecated. WRITEME: document this method (brpocock@star-hope.org, Jul 8, 2009)
protected abstract  PreparedStatement getStatement(Connection connection)
          Deprecated. WRITEME: document this method (brpocock@star-hope.org, Aug 14, 2009)
 String getString()
          Deprecated. WRITEME: document this method (brpocock@star-hope.org, Oct 13, 2009)
 String getString(int id)
          Deprecated. WRITEME: document this method (brpocock@star-hope.org, Jul 8, 2009)
 int hashCode()
          Deprecated. This is an overriding method.
static void invalidateCache()
          Deprecated. WRITEME: document this method (brpocock@star-hope.org, Dec 11, 2009)
static void invalidateCaches()
          Deprecated. WRITEME: document this method (brpocock@star-hope.org, Dec 11, 2009)
protected  void prepCache()
          Deprecated. WRITEME: document this method (brpocock@star-hope.org, Oct 13, 2009)
private static void registerClass(Class<? extends SQLPeerEnum> klass)
          Deprecated. WRITEME: document this method (brpocock@star-hope.org, Dec 11, 2009)
 void resetCache()
          Deprecated. WRITEME: document this method (brpocock@star-hope.org, Oct 13, 2009)
 void set(int id)
          Deprecated. WRITEME: document this method (brpocock@star-hope.org, Nov 19, 2009)
 void set(String str)
          Deprecated. Set the contents of the string value of the instance of the enumeration
 org.json.JSONObject toJSON()
          Deprecated. This is an overriding method.
 String toString()
          Deprecated. Create a stringified version of this enumeration.
 
Methods inherited from class org.starhope.appius.sql.SQLPeerDatum
changed, compareTo, findInCache, flush, get, saveInCache, set, set
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

enumeration

protected static final ConcurrentHashMap<Class<? extends SQLPeerEnum>,ConcurrentHashMap<Integer,String>> enumeration
Deprecated. 
enumeration of all possible values


hasCached

private static final ConcurrentHashMap<Class<? extends SQLPeerEnum>,Integer> hasCached
Deprecated. 
Index of which classes have been cached already. A value of -1 means that the class is being cached presently; zero or more represents some state of completion, no longer requiring precaching.


knownChildren

private static final HashSet<Class<? extends SQLPeerEnum>> knownChildren
Deprecated. 
WRITEME: document this field (brpocock@star-hope.org, Dec 11, 2009) knownChildren (SQLPeerEnum)


serialVersionUID

private static final long serialVersionUID
Deprecated. 
WRITEME: document this field (brpocock@star-hope.org, Oct 13, 2009) serialVersionUID (long)

See Also:
Constant Field Values

instance

protected int instance
Deprecated. 
instance ID

Constructor Detail

SQLPeerEnum

public SQLPeerEnum(Class<? extends SQLPeerEnum> klass)
Deprecated. 
WRITEME

Parameters:
klass - WRITEME

SQLPeerEnum

protected SQLPeerEnum(Class<? extends SQLPeerEnum> klass,
                      int id)
Deprecated. 
WRITEME

Parameters:
klass - WRITEME
id - the specific ID
Method Detail

doRealCacheResetStatic

public static void doRealCacheResetStatic()
Deprecated. 
WRITEME: document this method (brpocock@star-hope.org, Dec 11, 2009)


get

public static <T extends SQLPeerEnum> T get(Class<T> klass,
                                            int id)
Deprecated. 
WRITEME: document this method (brpocock@star-hope.org, Nov 19, 2009)

Type Parameters:
T - WRITEME
Parameters:
klass - WRITEME
id - WRITEME
Returns:
WRITEME

get

public static <T extends SQLPeerEnum> T get(Class<T> klass,
                                            String str)
Deprecated. 
Get an instance of an enumerated type

Type Parameters:
T - the enumerated type to get
Parameters:
klass - the enumerated type's class, passed in as a parameter
str - the identifying string for that type
Returns:
an enumerated type representing the provided string

Get

@Deprecated
public static <T extends DataRecord> T Get(Class<T> klass,
                                                      int id)
Deprecated. use Nomenclator.getDataRecord(Class,int)

Deprecated from birth: backward-compatibility routine for objects that have been migrated from SQLPeerEnum to DataRecord

Type Parameters:
T - class
Parameters:
klass - class
id - ID
Returns:
object

Get

@Deprecated
public static <T extends DataRecord> T Get(Class<T> klass,
                                                      String ident)
Deprecated. use Nomenclator.getDataRecord(Class,String)

Deprecated from birth: backward-compatibility routine for objects that have been migrated from SQLPeerEnum to DataRecord

Type Parameters:
T - class
Parameters:
klass - class
ident - ID
Returns:
object

invalidateCache

public static void invalidateCache()
Deprecated. 
WRITEME: document this method (brpocock@star-hope.org, Dec 11, 2009)


invalidateCaches

public static void invalidateCaches()
Deprecated. 
WRITEME: document this method (brpocock@star-hope.org, Dec 11, 2009)


registerClass

private static void registerClass(Class<? extends SQLPeerEnum> klass)
Deprecated. 
WRITEME: document this method (brpocock@star-hope.org, Dec 11, 2009)

Parameters:
klass - WRITEME

cache

protected void cache(ResultSet set)
              throws SQLException
Deprecated. 
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

doRealCacheReset

private void doRealCacheReset()
Deprecated. 
Actually flush the cache for all SQLPeerEnums


equals

public boolean equals(Object o)
Deprecated. 
This is an overriding method.

Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

equals

public boolean equals(SQLPeerEnum o)
Deprecated. 
Parameters:
o - The other type
Returns:
true if the two types are equal
See Also:
Object.equals(Object)

getCacheUniqueID

protected String getCacheUniqueID()
Deprecated. 
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()

getEnumeration

protected ConcurrentHashMap<Integer,String> getEnumeration()
Deprecated. 
Returns:
the enumeration

getID

public int getID()
Deprecated. 
WRITEME: document this method (brpocock@star-hope.org, Aug 14, 2009)

Returns:
WRITEME

getID

public int getID(String s)
Deprecated. 
WRITEME: document this method (brpocock@star-hope.org, 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

getStatement

protected abstract PreparedStatement getStatement(Connection connection)
                                           throws SQLException
Deprecated. 
WRITEME: document this method (brpocock@star-hope.org, Aug 14, 2009)

Parameters:
connection - WRITEME
Returns:
WRITEME
Throws:
SQLException - WRITEME

getString

public String getString()
Deprecated. 
WRITEME: document this method (brpocock@star-hope.org, Oct 13, 2009)

Returns:
WRITEME

getString

public String getString(int id)
Deprecated. 
WRITEME: document this method (brpocock@star-hope.org, Jul 8, 2009)

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

hashCode

public int hashCode()
Deprecated. 
This is an overriding method.

Overrides:
hashCode in class Object
See Also:
Object.hashCode()

prepCache

protected void prepCache()
Deprecated. 
WRITEME: document this method (brpocock@star-hope.org, Oct 13, 2009)


resetCache

public void resetCache()
Deprecated. 
WRITEME: document this method (brpocock@star-hope.org, Oct 13, 2009)


set

public void set(int id)
Deprecated. 
WRITEME: document this method (brpocock@star-hope.org, Nov 19, 2009)

Parameters:
id - WRITEME

set

public void set(String str)
Deprecated. 
Set the contents of the string value of the instance of the enumeration

Parameters:
str - the new value for this enumerated instance

toJSON

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

Overrides:
toJSON in class SQLPeerDatum
Returns:
This object's data, serialized into JSON form.
See Also:
SQLPeerDatum.toJSON()

toString

public String toString()
Deprecated. 
Create a stringified version of this enumeration. Usually the integer ID, a colon, and the string name, but might be overridden in a child class.

Overrides:
toString in class Object
See Also:
Object.toString()