org.tentackle.db
Class DbObjectClassVariables

java.lang.Object
  extended by org.tentackle.db.DbObjectClassVariables
Direct Known Subclasses:
AppDbObjectClassVariables

public class DbObjectClassVariables
extends Object

Holds static class variables for classes derived from DbObject. This is a "singleton per class". All classvariables register to a static Map that can be queried by apps by tablename.

Author:
harald

Field Summary
 boolean alwaysPrepare
          true if prepared statements should always be prepared (i.e.
 String classBaseName
          the base-classname
 String className
          the full classname
 Class<? extends DbObject> clazz
          the class
 int deleteStatementId
          prepared statement ID for delete()
 int dummyUpdateStatementId
          prepared statement ID for dummyUpdate()
 TableSerialExpirationBacklog expirationBacklog
          table serial expiration backlog
 int fieldCount
          number of db-columns, 0 = not known so far
 int idSourceId
          the source for obtaining a new ID
 int insertStatementId
          prepared statement ID for insert()
 long instanceCount
          General purpose instance (or ID) counter.
 String multiName
          name for multiple objects
 Properties properties
          class properties
 int remoteDelegateId
          ID for the remote delegate for this class.
 int selectAllStatementId
          prepared statement ID for selectAll()
 int selectExpiredTableSerials1StatementId
          prepared statement ID for selectExpiredTableSerials()
 int selectExpiredTableSerials2StatementId
           
 int selectLockedStatementId
          prepared statement ID for selectLocked()
 int selectSerialStatementId
          prepared statement ID for selectSerial()
 int selectStatementId
          prepared statement ID for select()
 String singleName
          name for a single object
 String tableName
          database table name
 int updateSerialAndTableSerialStatementId
          prepared statement ID for updateSerialAndTableSerial()
 int updateSerialStatementId
          prepared statement ID for updateSerial()
 int updateStatementId
          prepared statement ID for update()
 int updateTableSerialStatementId
          prepared statement ID for updateTableSerial()
 
Constructor Summary
DbObjectClassVariables(Class<? extends DbObject> clazz, String tableName, String singleName, String multiName)
          constructs a classvariable.
 
Method Summary
 long countInstance()
          Gets a unique instance number for pseudo-objects (e.g.
 String getProperty(String key)
          Gets a class property.
 DbObjectRemoteDelegate getRemoteDelegate(Db db)
          Gets the RemoteDelegate for the class and db.
 int getRemoteDelegateId(Db db)
          Gets the delegateId of the class, i.e.
static DbObjectClassVariables getVariables(String tableName)
          Gets the classvariables for a given tablename.
 String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

clazz

public Class<? extends DbObject> clazz
the class


className

public String className
the full classname


classBaseName

public String classBaseName
the base-classname


properties

public Properties properties
class properties


tableName

public String tableName
database table name


singleName

public String singleName
name for a single object


multiName

public String multiName
name for multiple objects


fieldCount

public int fieldCount
number of db-columns, 0 = not known so far


remoteDelegateId

public int remoteDelegateId
ID for the remote delegate for this class.


alwaysPrepare

public boolean alwaysPrepare
true if prepared statements should always be prepared (i.e. if the statement is changing for some reasons, e.g. the tablename).


selectStatementId

public int selectStatementId
prepared statement ID for select()


selectAllStatementId

public int selectAllStatementId
prepared statement ID for selectAll()


selectLockedStatementId

public int selectLockedStatementId
prepared statement ID for selectLocked()


selectSerialStatementId

public int selectSerialStatementId
prepared statement ID for selectSerial()


insertStatementId

public int insertStatementId
prepared statement ID for insert()


updateStatementId

public int updateStatementId
prepared statement ID for update()


deleteStatementId

public int deleteStatementId
prepared statement ID for delete()


dummyUpdateStatementId

public int dummyUpdateStatementId
prepared statement ID for dummyUpdate()


updateSerialStatementId

public int updateSerialStatementId
prepared statement ID for updateSerial()


updateTableSerialStatementId

public int updateTableSerialStatementId
prepared statement ID for updateTableSerial()


updateSerialAndTableSerialStatementId

public int updateSerialAndTableSerialStatementId
prepared statement ID for updateSerialAndTableSerial()


selectExpiredTableSerials1StatementId

public int selectExpiredTableSerials1StatementId
prepared statement ID for selectExpiredTableSerials()


selectExpiredTableSerials2StatementId

public int selectExpiredTableSerials2StatementId

expirationBacklog

public TableSerialExpirationBacklog expirationBacklog
table serial expiration backlog


idSourceId

public int idSourceId
the source for obtaining a new ID


instanceCount

public long instanceCount
General purpose instance (or ID) counter. Use countInstance() to get a new unique number.

Constructor Detail

DbObjectClassVariables

public DbObjectClassVariables(Class<? extends DbObject> clazz,
                              String tableName,
                              String singleName,
                              String multiName)
constructs a classvariable. Throws IllegalStateException if already constructed.

Parameters:
clazz - is the class of the derived DbObject
tableName - is the SQL tablename
singleName - text for a single object
multiName - text for multiple objects
Method Detail

countInstance

public long countInstance()
Gets a unique instance number for pseudo-objects (e.g. AppDbPseudoObject to simulate a unique ID. Or for other purposes.

Returns:
the instance number

getRemoteDelegateId

public int getRemoteDelegateId(Db db)
Gets the delegateId of the class, i.e. subclass of DbObject. If the remoteDelegateId is 0, it will be prepared The delegateId is unique for each class. It is valid only in remote connections and is the same for all remote Db's. The RMI-server creates a delegate for each subclass of DbObject (DbObjectRemoteDelegateImpl resp.)

Parameters:
db - the db connection
Returns:
the delegate id

getRemoteDelegate

public DbObjectRemoteDelegate getRemoteDelegate(Db db)
Gets the RemoteDelegate for the class and db.

Parameters:
db - the db connection
Returns:
the delegate

getProperty

public String getProperty(String key)
Gets a class property.

Parameters:
key - the property key
Returns:
the property value

toString

public String toString()
Description copied from class: java.lang.Object
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Overrides:
toString in class Object
Returns:
a string representation of the object.

getVariables

public static DbObjectClassVariables getVariables(String tableName)
Gets the classvariables for a given tablename.

Parameters:
tableName - is the database tablename
Returns:
the classvariables or null if no such tablename


Copyright © 2001-2008 Harald Krake, Bergstr. 48, 78098 Triberg, Germany, harald@krake.de