public abstract class DBRecordBase extends DBRecordData implements Record, Cloneable, Serializable
Modifier and Type | Class and Description |
---|---|
static class |
DBRecordBase.DBRecordRollbackHandler
DBRecordRollbackHandler
|
static class |
DBRecordBase.State |
Modifier and Type | Field and Description |
---|---|
protected boolean |
allowReadOnlyUpdate |
protected boolean |
validateFieldValues |
Modifier | Constructor and Description |
---|---|
protected |
DBRecordBase()
Internal constructor for DBRecord
May be used by derived classes to provide special behaviour
|
Modifier and Type | Method and Description |
---|---|
int |
addXmlData(Element parent)
Add the values of this record to the specified XML Element object.
|
int |
addXmlMeta(Element parent)
This function set the field descriptions to the the XML tag.
|
protected boolean |
allowFieldChange(DBColumn column)
Checks whether or not this field can be changed at all.
|
protected void |
assignParentIdentities()
For DBMS with IDENTITY-columns the deferred parent-keys are set by this functions
The parent records must have been previously set using setParentRecord
|
protected void |
changeState(DBRecordBase.State newState)
changes the state of the record
|
protected void |
checkUpdateable()
Checks whether the record is updateable
If its read-only a RecordReadOnlyException is thrown
|
protected void |
checkValid()
helper to check if the object is valid
|
protected void |
checkValid(int fieldIndex)
helper to check if the object is valid
|
DBRecordBase |
clone() |
void |
close()
Closes the record by releasing all resources and resetting the record's state to invalid.
|
protected DBRollbackHandler |
createRollbackHandler()
Factory function to create createRollbackHandler();
|
DBColumn |
getColumn(int index)
Implements the Record Interface getColumn method.
|
DBDatabase |
getDatabase()
Returns the current DBDatabase object.
|
EntityType |
getEntityType()
returns true if this record is a new record.
|
int |
getFieldCount()
Returns the number of the columns.
|
int |
getFieldIndex(ColumnExpr column)
Returns the index value by a specified DBColumnExpr object.
|
int |
getFieldIndex(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.
|
protected Object[] |
getFields()
This function provides direct access to the record fields.
|
Object[] |
getKey()
Returns a array of key columns by a specified DBRecord object.
|
Column[] |
getKeyColumns()
returns an array of key columns which uniquely identify the record.
|
abstract DBRowSet |
getRowSet()
Returns the DBRowSet object.
|
DBRecordBase.State |
getState()
Returns the record state.
|
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) ) |
protected DBXmlDictionary |
getXmlDictionary()
returns the DBXmlDictionary that should used to generate XMLDocuments
|
Document |
getXmlDocument()
Returns a XML document with the field description an values of this record.
|
protected void |
initData(boolean newRecord)
This method is used internally by the RowSet to initialize the record's properties
|
protected boolean |
isColumn(int index,
DBColumn... column)
helper function to check if a given field index corresponds to one of the given columns
|
boolean |
isExists()
Returns true if this record is a existing record (valid but not new).
|
boolean |
isFieldReadOnly(Column column)
returns whether a field is read only or not
|
boolean |
isFieldRequired(Column column)
returns whether a field is required or not
|
boolean |
isFieldVisible(Column 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 |
isReadOnly()
Returns true if the record is valid.
|
abstract boolean |
isRollbackHandlingEnabled()
Returns whether or not RollbackHandling is enabled for this record
|
boolean |
isSame(DBRecordBase other)
Compares the record to another one
|
boolean |
isValid()
Returns true if the record is valid.
|
boolean |
isValidateFieldValues()
Returns whether or not values are checked for validity when calling setValue().
|
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 partially loaded. |
protected void |
modifyValue(int index,
Object value,
boolean fireChangeEvent)
Modifies a column value bypassing all checks made by setValue.
|
protected void |
onFieldChanged(int i)
Override this to get notified when a field value changes
|
protected void |
onRecordChanged()
Override this to do extra handling when the record changes
|
DBRecordBase |
set(Column column,
Object value)
Sets the value of a column in the record.
|
void |
setParentRecord(DBColumn parentIdColumn,
DBRecordBase record)
For DBMS with IDENTITY-columns defer setting the parent-id until the record is inserted
The parent record must have a one-column primary key
|
protected void |
setRecordValue(Column column,
Object bean,
String property)
set a record value from a particular bean property.
|
int |
setRecordValues(Object bean)
Sets record values from the suppied java bean.
|
int |
setRecordValues(Object bean,
Collection<Column> ignoreList)
Sets record values from the supplied java bean.
|
void |
setValidateFieldValues(boolean validateFieldValues)
Set whether or not values are checked for validity when calling setValue().
|
DBRecordBase |
setValue(Column column,
Object value)
Deprecated.
|
void |
setValue(int index,
Object value)
Sets the value of a column in the record.
|
protected void |
updateComplete()
This method is used internally to indicate that the record update has completed
This will set change the record's state to Valid |
void |
validateAllValues()
validates all modified values of a record
|
Object |
validateValue(Column column,
Object value)
Validates a value before it is set in the record.
|
boolean |
wasAnyModified(Column... columns)
Returns true if any of the given fields was modified.
|
boolean |
wasModified(Column column)
Returns true if the field was modified.
|
boolean |
wasModified(int index)
Returns true if the field was modified.
|
formatValue, get, get, getArray, getBoolean, getBoolean, getDateTime, getDateTime, getDecimal, getDecimal, getDouble, getDouble, getEnum, getEnum, getEnum, getInt, getInt, getLocalDate, getLocalDate, getLocalDateTime, getLocalDateTime, getLong, getLong, getString, getString, getText, getValue, getValue, getValues, isNull, isNull, setBeanProperties, setBeanProperties, setBeanProperty
checkParamNull
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
get, isNull, isNull, setBeanProperties
getContext
protected boolean validateFieldValues
protected boolean allowReadOnlyUpdate
protected DBRecordBase()
protected void checkValid()
ObjectNotValidException
- if the object is not validprotected void checkValid(int fieldIndex)
ObjectNotValidException
- if the object is not validpublic void close()
public DBRecordBase clone()
public abstract DBRowSet getRowSet()
public abstract boolean isRollbackHandlingEnabled()
public EntityType getEntityType()
getEntityType
in interface Record
public DBDatabase getDatabase()
getDatabase
in class DBObject
public DBRecordBase.State getState()
public boolean isValid()
public boolean isReadOnly()
isReadOnly
in interface Record
public boolean isModified()
isModified
in interface Record
public boolean isNew()
public boolean isExists()
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 indexpublic int getFieldIndex(String column)
getFieldIndex
in interface RecordData
getFieldIndex
in class DBRecordData
column
- the name of the column for which to return the indexpublic DBColumn getColumn(int index)
getColumn
in interface Record
getColumn
in interface RecordData
index
- field index of the column expressionpublic boolean wasModified(int index)
index
- the field indexpublic final boolean wasModified(Column column)
wasModified
in interface Record
column
- the requested columnpublic final boolean wasAnyModified(Column... columns)
public boolean isValidateFieldValues()
public void setValidateFieldValues(boolean validateFieldValues)
validateFieldValues
- flag whether to check validitypublic Column[] getKeyColumns()
getKeyColumns
in interface Record
public Object[] getKey()
public Object getValue(int index)
isValueValid(int)
)getValue
in interface RecordData
getValue
in class DBRecordData
index
- the field index for which to return the valuepublic boolean isValueValid(int index)
index
- the filed indexObjectUtils.NO_VALUE
public Options getFieldOptions(DBColumn column)
column
- the database field columnpublic final Options getFieldOptions(Column column)
getFieldOptions
in interface Record
column
- the column to check for visibilitypublic void validateAllValues()
public void setValue(int index, Object value)
@Deprecated public DBRecordBase setValue(Column column, Object value)
public DBRecordBase set(Column column, Object value)
public Object validateValue(Column column, Object value)
validateValue
in interface Record
column
- the column that needs to be changedvalue
- the new valuepublic boolean isFieldVisible(Column column)
May be overridden to implement context specific logic.
isFieldVisible
in interface Record
column
- the column which to check for visibilitypublic boolean isFieldReadOnly(Column column)
isFieldReadOnly
in interface Record
column
- the database columnpublic boolean isFieldRequired(Column column)
isFieldRequired
in interface Record
column
- the database columnpublic int setRecordValues(Object bean, Collection<Column> ignoreList)
setRecordValues
in interface Record
bean
- the Java Bean from which to read the value fromignoreList
- list of column to ignorepublic final int setRecordValues(Object bean)
setRecordValues
in interface Record
bean
- the Java Bean from which to read the value frompublic void setParentRecord(DBColumn parentIdColumn, DBRecordBase record)
parentIdColumn
- the column for which to set the parentrecord
- the parent record to be set for the columnpublic boolean isSame(DBRecordBase other)
other
- the record to compare this record withpublic int addXmlMeta(Element parent)
addXmlMeta
in class DBRecordData
public int addXmlData(Element parent)
addXmlData
in class DBRecordData
parent
- the XML Element objectpublic Document getXmlDocument()
getXmlDocument
in class DBRecordData
protected Object[] getFields()
protected void changeState(DBRecordBase.State newState)
newState
- protected DBRollbackHandler createRollbackHandler()
protected void initData(boolean newRecord)
newRecord
- flag whether the record is new (non-existing) in the databaseprotected void updateComplete()
protected void checkUpdateable()
RecordReadOnlyException
protected boolean allowFieldChange(DBColumn column)
column
- the column that needs to be changedprotected void modifyValue(int index, Object value, boolean fireChangeEvent)
index
- index of the columnvalue
- the column valueprotected void onRecordChanged()
protected void onFieldChanged(int i)
protected void setRecordValue(Column column, Object bean, String property)
For a property called FOO this is equivalent of calling
setValue(column, bean.getFOO())
bean
- the Java Bean from which to read the value fromproperty
- the name of the propertycolumn
- the column for which to set the record valueprotected void assignParentIdentities()
protected boolean isColumn(int index, DBColumn... column)
index
- the field indexcolumn
- one or more columns to checkprotected DBXmlDictionary getXmlDictionary()
Copyright © 2008–2023 Apache Software Foundation. All rights reserved.