|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.empire.commons.ErrorObject
org.apache.empire.db.DBObject
org.apache.empire.db.DBRecordData
org.apache.empire.db.DBRecord
public class DBRecord
This class handles one record from a database table.
Field Summary | |
---|---|
static int |
REC_EMTPY
|
static int |
REC_INVALID
|
static int |
REC_MODIFIED
|
static int |
REC_NEW
|
static int |
REC_VALID
|
Constructor Summary | |
---|---|
DBRecord()
Create a new DBRecord object. |
Method Summary | |
---|---|
boolean |
addColumnDesc(org.w3c.dom.Element parent)
This function set the field descriptions to the the XML tag. |
boolean |
addRowValues(org.w3c.dom.Element parent)
Add the values of this record to the specified XML Element object. |
DBRecord |
clone()
|
void |
close()
Closes the record by releasing all resources and resetting the record's state to invalid. |
boolean |
create(DBRowSet table)
Creates a new record for the given table. |
boolean |
create(DBRowSet table,
java.sql.Connection conn)
Creates a new record for the given table. |
boolean |
delete(java.sql.Connection conn)
This helper function calls the DBRowset.deleteRecord method to delete the record. |
int |
fillMissingDefaults(java.sql.Connection conn)
Initialisieren the field with the values (NO_VALUE) of the vector 'field'. |
Column |
getColumn(int index)
Implements the Record Interface getColumn method. |
ColumnExpr |
getColumnExpr(int index)
Returns a DBColumnExpr object by a specified index value. |
DBDatabase |
getDatabase()
Returns the current DBDatabase object. |
DBColumn |
getDBColumn(int index)
Returns the DBColumn for the field at the given index. |
int |
getFieldCount()
Returns the number of the columns. |
int |
getFieldIndex(ColumnExpr column)
Returns the index value by a specified DBColumnExpr object. |
int |
getFieldIndex(java.lang.String column)
Returns the index value by a specified column name. |
Options |
getFieldOptions(Column column)
Gets the possbile Options for a field in the context of the current record. |
Options |
getFieldOptions(DBColumn column)
Gets the possbile Options for a field in the context of the current record. |
Column[] |
getKeyColumns()
returns an array of key columns which uniquely identify the record. |
java.lang.Object[] |
getKeyValues()
Returns the array of primary key columns. |
DBRowSet |
getRowSet()
Returns the DBRowSet object. |
java.lang.Object |
getRowSetData()
Returns the DBRowSet object. |
int |
getState()
Returns the record state. |
java.lang.Object |
getValue(int index)
Returns the value for the given column or null if either the index is out of range or the value is not valid (see isValueValid(int) ) |
org.w3c.dom.Document |
getXmlDocument()
Returns a XML document with the field descriptiona an values of this record. |
boolean |
init(DBRowSet table,
java.lang.Object[] keyValues,
boolean insert)
Initializes this record object by attaching it to a rowset, setting its primary key values and setting the record state. |
boolean |
initNew(DBRowSet table)
Deprecated. use create(DBRowSet) |
boolean |
initNew(DBRowSet table,
java.sql.Connection conn)
Deprecated. use create(DBRowSet, Connection) |
boolean |
isFieldReadOnly(Column column)
returns whether a field is read only or not |
boolean |
isFieldReadOnly(DBColumn column)
returns whether a field is read only or not |
boolean |
isFieldVisible(Column column)
returns whether a field is read only or not |
boolean |
isFieldVisible(DBColumn column)
returns whether a field is visible to the client or not May be overridden to implement context specific logic. |
boolean |
isModified()
Returns true if the record is modified. |
boolean |
isNew()
Returns true if this record is a new record. |
boolean |
isValid()
Returns true if the record is valid. |
boolean |
isValueValid(int index)
Returns whether a field value is provided i.e. the value is not DBRowSet.NO_VALUE This function is only useful in cases where records are partically loaded. |
void |
modifyValue(int i,
java.lang.Object value)
Modifies a column value bypassing all checks made by setValue. |
boolean |
read(DBRowSet table,
java.lang.Object[] keys,
java.sql.Connection conn)
Loads a record from the database identified by it's primary key. |
boolean |
read(DBRowSet table,
java.lang.Object id,
java.sql.Connection conn)
Loads a record from the database identified by it's primary key. |
boolean |
setBeanValues(java.lang.Object bean)
Sets record values from the suppied java bean. |
boolean |
setBeanValues(java.lang.Object bean,
java.util.Collection<Column> ignoreList)
Sets record values from the suppied java bean. |
void |
setModified(DBColumn column,
boolean isModified)
Sets the modified state of a column. |
boolean |
setValue(Column column,
java.lang.Object value)
Sets the value of the column in the record. |
boolean |
setValue(int i,
java.lang.Object value)
Sets the value of the column in the record. |
boolean |
update(java.sql.Connection conn)
Updates the record and saves all changes in the database. |
boolean |
wasModified(Column column)
Returns true if the field was modified. |
boolean |
wasModified(int index)
Returns true if the field was modified. |
Methods inherited from class org.apache.empire.db.DBRecordData |
---|
getBeanProperties, getBeanProperties, getBoolean, getBoolean, getDateTime, getDateTime, getDouble, getDouble, getInt, getInt, getLong, getLong, getString, getString, getValue, isNull, isNull |
Methods inherited from class org.apache.empire.commons.ErrorObject |
---|
clearError, getErrorMessage, getErrorParams, getErrorSource, getErrorType, getMessage, hasError, isExceptionsEnabled, setExceptionsEnabled |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.empire.data.RecordData |
---|
getBeanProperties, getBeanProperties, getValue, isNull, isNull |
Field Detail |
---|
public static final int REC_INVALID
public static final int REC_EMTPY
public static final int REC_VALID
public static final int REC_MODIFIED
public static final int REC_NEW
Constructor Detail |
---|
public DBRecord()
Method Detail |
---|
public void close()
close
in class DBRecordData
public DBRecord clone()
clone
in class java.lang.Object
Object.clone()
public DBDatabase getDatabase()
getDatabase
in class DBObject
public DBRowSet getRowSet()
public java.lang.Object getRowSetData()
public int getState()
public boolean isValid()
isValid
in interface Record
public boolean isModified()
isModified
in interface Record
public boolean isNew()
isNew
in interface Record
public int getFieldCount()
getFieldCount
in interface RecordData
getFieldCount
in class DBRecordData
public int getFieldIndex(ColumnExpr column)
getFieldIndex
in interface RecordData
getFieldIndex
in class DBRecordData
column
- the column for which to return the index
public int getFieldIndex(java.lang.String column)
getFieldIndex
in interface RecordData
getFieldIndex
in class DBRecordData
column
- the name of the column for which to return the index
public DBColumn getDBColumn(int index)
public final Column getColumn(int index)
getColumn
in interface Record
index
- index of a requested column
public final ColumnExpr getColumnExpr(int index)
getColumnExpr
in interface RecordData
getColumnExpr
in class DBRecordData
index
- field index of the column expression
public boolean wasModified(int index)
public final boolean wasModified(Column column)
wasModified
in interface Record
column
- the requested column
public void setModified(DBColumn column, boolean isModified)
public Column[] getKeyColumns()
getKeyColumns
in interface Record
public java.lang.Object[] getKeyValues()
public java.lang.Object getValue(int index)
isValueValid(int)
)
getValue
in interface RecordData
getValue
in class DBRecordData
index
- the field index for which to return the value
public boolean isValueValid(int index)
ObjectUtils.NO_VALUE
public Options getFieldOptions(DBColumn column)
public final Options getFieldOptions(Column column)
getFieldOptions
in interface Record
column
- the column to check for visibility
public void modifyValue(int i, java.lang.Object value)
i
- index of the columnvalue
- the column valuepublic boolean setValue(int i, java.lang.Object value)
setValue
in interface Record
i
- the index of the columnvalue
- the value
public final boolean setValue(Column column, java.lang.Object value)
setValue
in interface Record
column
- a DBColumn objectvalue
- the value
public boolean isFieldReadOnly(DBColumn column)
public final boolean isFieldReadOnly(Column column)
isFieldReadOnly
in interface Record
column
- the requested column
public boolean isFieldVisible(DBColumn column)
May be overridden to implement context specific logic.
column
- the column which to check for visibility
public final boolean isFieldVisible(Column column)
isFieldVisible
in interface Record
column
- the column to check for visibility
public boolean init(DBRowSet table, java.lang.Object[] keyValues, boolean insert)
table
- the rowsetkeyValues
- a Object array, the primary key(s)insert
- if true change the state of this object to REC_NEW
@Deprecated public final boolean initNew(DBRowSet table, java.sql.Connection conn)
create(DBRowSet, Connection)
@Deprecated public final boolean initNew(DBRowSet table)
create(DBRowSet)
public boolean create(DBRowSet table, java.sql.Connection conn)
If a connection is supplied sequence generated values will be obtained
Otherwise the sequence will be generated later.
table
- the table for which to create a recordconn
- a valid JDBC connection
public boolean create(DBRowSet table)
table
- the table for which to create a record
public boolean read(DBRowSet table, java.lang.Object[] keys, java.sql.Connection conn)
table
- the rowset from which to read the recordkeys
- an array of the primary key valuesconn
- a valid connection to the database.
DBRowSet.readRecord(DBRecord, Object[], Connection)
public final boolean read(DBRowSet table, java.lang.Object id, java.sql.Connection conn)
table
- the rowset from which to read the recordid
- the primary key of the record to load.conn
- a valid connection to the database.
DBRowSet.readRecord(DBRecord, Object[], Connection)
public boolean update(java.sql.Connection conn)
conn
- a valid connection to the database.
DBRowSet.updateRecord(DBRecord, Connection)
public boolean delete(java.sql.Connection conn)
conn
- a valid connection to the database.
DBTable.deleteRecord(Object[], Connection)
public boolean addColumnDesc(org.w3c.dom.Element parent)
addColumnDesc
in class DBRecordData
public boolean addRowValues(org.w3c.dom.Element parent)
addRowValues
in class DBRecordData
parent
- the XML Element object
public org.w3c.dom.Document getXmlDocument()
getXmlDocument
in class DBRecordData
public int fillMissingDefaults(java.sql.Connection conn)
public boolean setBeanValues(java.lang.Object bean, java.util.Collection<Column> ignoreList)
setBeanValues
in interface Record
bean
- the Java Bean from which to read the value fromignoreList
- list of column to ignore
public final boolean setBeanValues(java.lang.Object bean)
setBeanValues
in interface Record
bean
- the Java Bean from which to read the value from
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |