org.tentackle.db
Class DbPreferencesKey

java.lang.Object
  extended by org.tentackle.db.DbObject
      extended by org.tentackle.db.DbPreferencesKey
All Implemented Interfaces:
Serializable, Cloneable, Comparable<DbObject>

public class DbPreferencesKey
extends DbObject

A preferences key/value pair stored in the database.

Author:
harald
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.tentackle.db.DbObject
DbObject.CopyAllToDbLogger, DbObject.IdComparator<T extends DbObject>, DbObject.NameComparator<T extends DbObject>, DbObject.NameIdComparator<T extends DbObject>
 
Field Summary
static String FIELD_KEY
          database column name for key
static String FIELD_NODEID
          database column name for nodeId
static String FIELD_VALUE
          database column name for value
static String TABLENAME
          database tablename
 
Fields inherited from class org.tentackle.db.DbObject
BEGIN, COMMIT, DELETE, DELETEALL, FIELD_ID, FIELD_SERIAL, FIELD_TABLESERIAL, idComparator, INSERT, lazyMethodInterval, nameComparator, nameIdComparator, TX_DELETE_LIST, TX_DELETE_MISSING_IN_LIST, TX_DELETE_OBJECT, TX_DUMMY_UPDATE, TX_INSERT_OBJECT, TX_INSERT_PLAIN, TX_SAVE, TX_SAVE_LIST, TX_UPDATE_OBJECT, TX_UPDATE_PLAIN, TX_UPDATE_SERIAL, TX_UPDATE_SERIAL_AND_TABLESERIAL, TX_UPDATE_TABLESERIAL, UPDATE
 
Constructor Summary
DbPreferencesKey()
          Creates a preferences key (without db connection).
DbPreferencesKey(Db db)
          Creates a preferences key.
 
Method Summary
 int deleteByNodeId(long nodeId)
          Deletes all keys for a node.
 DbObjectClassVariables getDbObjectClassVariables()
          Gets the some attributes and variables common to all objects of the same class.
 boolean getFields(ResultSetWrapper rs)
          Retrieves the values of all fields (all columns of the database table) in the given ResultSetWrapper and stores them in the object's attributes.
 ImageIcon getIcon()
          Gets the icon of this object.
 String getKey()
          Gets the db attribute key
 DbPreferencesNode getLazyNode()
           
 long getNodeId()
          Gets the db attribute nodeId
 String getValue()
          Gets the db attribute value
 boolean isCountingModification(int modType)
          Determines whether modifications of this object are counted in the modification table.
 boolean isTableSerialValid()
          By default objects don't need to include the tableSerial in the database table.
 boolean isTracked()
          Overridden cause of "--tracked".
 int prepareInsertStatement()
          Prepares the insert statement.
 boolean prepareSetFields()
          Prepares the object's attributes before the object is saved to the database.
 int prepareUpdateStatement()
          Prepare the update statement.
 DbPreferencesKey select(long id)
          Selects a preferences key by its ID.
 List<DbPreferencesKey> selectByNodeId(long nodeId)
          Gets all keys belonging to a node.
 DbPreferencesKey selectByNodeIdKey(long nodeId, String key)
          Get a preferences key by nodeid and key name.
 int setFields(PreparedStatementWrapper st)
          Sets the values of all fields (all columns of the database table) in the given PreparedStatementWrapper from the object's attributes.
 void setKey(String key)
          Sets the db attribute key
 void setLazyNode(DbPreferencesNode node)
          sets the "lazy" parent, i.e.
 void setNodeId(long nodeId)
          Sets the db attribute nodeId
 void setValue(String value)
          Sets the db attribute value
 String toString()
          Gets the default string value.
The default implementation invokes DbObject.toGenericString().
 
Methods inherited from class org.tentackle.db.DbObject
_delete, _save, alwaysPrepare, assertLazyNotWithinTX, attributesModified, beginTx, clone, compareTo, copyAllToDb, copyLazyValues, copyToDb, countModification, countModification, createModificationLog, delete, deleteLinkedObjects, deleteList, deleteMissingInList, deleteObject, deletePlain, dummyUpdate, equals, finishModification, finishNotUpdated, getClassBaseName, getClassName, getDb, getDeleteStatementId, getDummyUpdateStatementId, getExpirationBacklog, getExpiredTableSerials, getFieldCount, getId, getIdSource, getInsertStatementId, getMultiName, getRemoteDelegate, getRemoteDelegateId, getSelectAllStatementId, getSelectExpiredTableSerials1StatementId, getSelectExpiredTableSerials2StatementId, getSelectLockedStatementId, getSelectSerialStatementId, getSelectStatementId, getSerial, getSingleName, getSqlAllFields, getSqlPrefix, getSqlPrefixWithDot, getSqlSelectAllFields, getTableName, getTableSerial, getUpdateSerialAndTableSerialStatementId, getUpdateSerialStatementId, getUpdateStatementId, getUpdateTableSerialStatementId, hashCode, initModification, insert, insertObject, insertPlain, invalidateLazyValues, isDeleted, isEditable, isEditableLazy, isEntity, isGettingFieldCount, isIdValid, isLazyElapsed, isListModified, isLoggingModification, isModified, isNew, isPartial, isReferenced, isReferencedLazy, isRemovable, isRemovableLazy, isSaveable, isTxObject, isUpdatingSerialEvenIfNotModified, isVirgin, loadLinkedObjects, logModification, markDeleted, markListDeleted, newByClass, newByClass, newByClassWrapped, newId, newObject, prepareDeleteStatement, prepareDummyUpdateStatement, prepareSelectLockedStatement, prepareSelectSerialStatement, prepareSelectStatement, prepareUpdateSerialAndTableSerialStatement, prepareUpdateSerialStatement, prepareUpdateTableSerialStatement, readFromResultSetWrapper, readFromResultSetWrapper, reload, reloadLocked, reserveId, save, saveLinkedObjects, saveList, saveList, select, select, select, selectAll, selectAll, selectAll, selectAllCursor, selectAllCursor, selectAllResultSet, selectExpiredTableSerials, selectExpiredTableSerials, selectInValidContext, selectLocked, selectLocked, selectModification, selectNext, selectSerial, selectSerial, setAlwaysPrepare, setDb, setDeleteStatementId, setDummyUpdateStatementId, setId, setInsertStatementId, setModified, setSelectAllStatementId, setSelectExpiredTableSerials1StatementId, setSelectExpiredTableSerials2StatementId, setSelectLockedStatementId, setSelectSerialStatementId, setSelectStatementId, setSerial, setTableSerial, setUpdateSerialAndTableSerialStatementId, setUpdateSerialStatementId, setUpdateStatementId, setUpdateTableSerialStatementId, sync, syncObject, toGenericString, update, updateFieldCount, updateFields, updateObject, updatePlain, updateSerial, updateSerialAndTableSerial, updateTableSerial
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TABLENAME

public static final String TABLENAME
database tablename

See Also:
Constant Field Values

FIELD_NODEID

public static final String FIELD_NODEID
database column name for nodeId

See Also:
Constant Field Values

FIELD_KEY

public static final String FIELD_KEY
database column name for key

See Also:
Constant Field Values

FIELD_VALUE

public static final String FIELD_VALUE
database column name for value

See Also:
Constant Field Values
Constructor Detail

DbPreferencesKey

public DbPreferencesKey(Db db)
Creates a preferences key.

Parameters:
db - the db connection

DbPreferencesKey

public DbPreferencesKey()
Creates a preferences key (without db connection).

Method Detail

toString

public String toString()
Description copied from class: DbObject
Gets the default string value.
The default implementation invokes DbObject.toGenericString().

Overrides:
toString in class DbObject
Returns:
the string value of this DbObject

getIcon

public ImageIcon getIcon()
Description copied from class: DbObject
Gets the icon of this object. The icon is displayed in trees, for example. The default implementation returns PlafGlobal.getIcon(java.lang.String, java.lang.String)("unknown").

Overrides:
getIcon in class DbObject
Returns:
the icon

isCountingModification

public boolean isCountingModification(int modType)
Description copied from class: DbObject
Determines whether modifications of this object are counted in the modification table. The default implementation returns false. Must be overridden if counting the modifications is desired.

Overrides:
isCountingModification in class DbObject
Parameters:
modType - is one of the modtypes INSERT, UPDATE, DELETE, ...
Returns:
true if count modification, false if not.
See Also:
ModificationCounter

isTableSerialValid

public boolean isTableSerialValid()
Description copied from class: DbObject
By default objects don't need to include the tableSerial in the database table. Override this method if object contains a TABLESERIAL-column.

Overrides:
isTableSerialValid in class DbObject
Returns:
true if object is using the tableSerial column, false if not.

setLazyNode

public void setLazyNode(DbPreferencesNode node)
sets the "lazy" parent, i.e. a new parent without an ID.

Parameters:
node - the parent node, null if none.

getLazyNode

public DbPreferencesNode getLazyNode()
Returns:
the lazy parent, if any

prepareSetFields

public boolean prepareSetFields()
Prepares the object's attributes before the object is saved to the database. Should be overridden. The default implementation does nothing. Used to setup, check and align values.

Overridden to set the parent id if lazy parent set and has no id

Overrides:
prepareSetFields in class DbObject
Returns:
true if proceed with save/insert/update, false if some error.

getFields

public boolean getFields(ResultSetWrapper rs)
Description copied from class: DbObject
Retrieves the values of all fields (all columns of the database table) in the given ResultSetWrapper and stores them in the object's attributes.

Specified by:
getFields in class DbObject
Parameters:
rs - the result set
Returns:
true if all fields retrieved

setFields

public int setFields(PreparedStatementWrapper st)
Description copied from class: DbObject
Sets the values of all fields (all columns of the database table) in the given PreparedStatementWrapper from the object's attributes.

Specified by:
setFields in class DbObject
Parameters:
st - the statement
Returns:
the number of fields set, -1 if error.

select

public DbPreferencesKey select(long id)
Selects a preferences key by its ID.

Overrides:
select in class DbObject
Parameters:
id - is the object id
Returns:
object if loaded, null if no such object

getDbObjectClassVariables

public DbObjectClassVariables getDbObjectClassVariables()
Description copied from class: DbObject
Gets the some attributes and variables common to all objects of the same class. Class variables for classes derived from DbObject are kept in an instance of DbObjectClassVariables.

Specified by:
getDbObjectClassVariables in class DbObject
Returns:
the class variables

prepareInsertStatement

public int prepareInsertStatement()
Description copied from class: DbObject
Prepares the insert statement.

Specified by:
prepareInsertStatement in class DbObject
Returns:
the statememt id

prepareUpdateStatement

public int prepareUpdateStatement()
Description copied from class: DbObject
Prepare the update statement.

Specified by:
prepareUpdateStatement in class DbObject
Returns:
the statememt id

selectByNodeId

public List<DbPreferencesKey> selectByNodeId(long nodeId)
Gets all keys belonging to a node.

Parameters:
nodeId - the node's ID
Returns:
List of keys
Wurblet:
selectByNodeId DbSelectList $mapfile $remote nodeId

selectByNodeIdKey

public DbPreferencesKey selectByNodeIdKey(long nodeId,
                                          String key)
Get a preferences key by nodeid and key name.

Parameters:
nodeId - the node ID
key - the key name
Returns:
the preferences key, null if not found
Wurblet:
selectByNodeIdKey DbSelectUnique $mapfile $remote nodeId key

deleteByNodeId

public int deleteByNodeId(long nodeId)
Deletes all keys for a node.

Parameters:
nodeId - the node's ID
Returns:
the number of keys deleted
Wurblet:
deleteByNodeId DbDeleteBy $mapfile $remote nodeId

isTracked

public boolean isTracked()
Overridden cause of "--tracked".

Overrides:
isTracked in class DbObject
Returns:
true = setters check for modification

getNodeId

public long getNodeId()
Gets the db attribute nodeId

Returns:
ID of the preferences node

setNodeId

public void setNodeId(long nodeId)
Sets the db attribute nodeId

Parameters:
nodeId - ID of the preferences node

getKey

public String getKey()
Gets the db attribute key

Returns:
name of the key

setKey

public void setKey(String key)
Sets the db attribute key

Parameters:
key - name of the key

getValue

public String getValue()
Gets the db attribute value

Returns:
value of the key

setValue

public void setValue(String value)
Sets the db attribute value

Parameters:
value - value of the key


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