org.starhope.appius.sql
Class SQLPeerDatum

java.lang.Object
  extended by org.starhope.appius.util.ManagedReferenceHolder
      extended by org.starhope.appius.sql.SQLPeerDatum
Direct Known Subclasses:
Filter, InventoryItem, Payment, PaymentGateway, Person, Room, SQLPeerEnum, StoreItem, UserAddress, UserEnrolment

public abstract class SQLPeerDatum
extends ManagedReferenceHolder


Constructor Summary
SQLPeerDatum()
           
 
Method Summary
 void changed()
           
protected
<T extends SQLPeerDatum>
SQLPeerDatum
findInCache()
          Find the object in the cache, if possible.
abstract  void flush()
           
static SQLPeerDatum get(Class<? extends SQLPeerDatum> klass, org.json.JSONObject object)
           throw new Error ("wtf?");
private  String getCacheGlobalID()
          Get the globally-unique ID for this object, including the canonical class name, for the cache.
protected abstract  String getCacheUniqueID()
           
static PreparedStatement prepare(String string)
           
static PreparedStatement prepare(String string, int returnGeneratedKeys)
          WRITEME: document this method (brpocock, Aug 25, 2009)
protected  void saveInCache()
          Store the local object into the cache
 void set(org.json.JSONObject o)
           
protected abstract  void set(ResultSet rs)
           
 org.json.JSONObject toJSON()
           
 
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
 

Constructor Detail

SQLPeerDatum

public SQLPeerDatum()
Method Detail

get

public static SQLPeerDatum get(Class<? extends SQLPeerDatum> klass,
                               org.json.JSONObject object)
throw new Error ("wtf?");

Parameters:
klass -
object -
Returns:

prepare

public static PreparedStatement prepare(String string)
Parameters:
string - The SQL string to form the prepared statement
Returns:
the PreparedStatement as from Connection.prepareStatement(String, int)

prepare

public static PreparedStatement prepare(String string,
                                        int returnGeneratedKeys)
WRITEME: document this method (brpocock, Aug 25, 2009)

Parameters:
string -
returnGeneratedKeys -
Returns:

changed

public void changed()

findInCache

protected <T extends SQLPeerDatum> SQLPeerDatum findInCache()
                            throws NotFoundException
Find the object in the cache, if possible. If not, throws a NotFoundException.

Type Parameters:
T - type
Returns:
the object, if already found
Throws:
NotFoundException - if it's not found

flush

public abstract void flush()

getCacheGlobalID

private String getCacheGlobalID()
Get the globally-unique ID for this object, including the canonical class name, for the cache.

Returns:
the ID for the cache

getCacheUniqueID

protected abstract String getCacheUniqueID()
Returns:
The local (Stringified) version of an unique ID; usually the database ID column

saveInCache

protected void saveInCache()
Store the local object into the cache


set

public void set(org.json.JSONObject o)
         throws NotImplementedException
Parameters:
o -
Throws:
NotImplementedException

set

protected abstract void set(ResultSet rs)
                     throws SQLException
Parameters:
rs -
Throws:
SQLException - if the database fails somehow

toJSON

public org.json.JSONObject toJSON()
Returns:
Throws:
org.json.JSONException