org.apache.empire.data.bean
Class BeanRecordProxy<T>

java.lang.Object
  extended by org.apache.empire.commons.ErrorObject
      extended by org.apache.empire.data.bean.BeanRecordProxy<T>
Type Parameters:
T - the type of the class proxied by this BeanRecordProxy
All Implemented Interfaces:
ErrorInfo, Record, RecordData
Direct Known Subclasses:
SampleRecord

public class BeanRecordProxy<T>
extends ErrorObject
implements Record

BeanRecordProxy This class defines proxy that allows any POJO to behave like a record object.

Author:
Rainer

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.empire.commons.ErrorObject
ErrorObject.ObjectErrorInfo
 
Field Summary
protected static org.apache.commons.logging.Log log
           
 
Constructor Summary
BeanRecordProxy(BeanClass beanClass)
           
BeanRecordProxy(java.util.List<Column> columns, Column[] keyColumns)
           
BeanRecordProxy(T data, BeanClass beanClass)
           
BeanRecordProxy(T data, java.util.List<Column> columns, Column[] keyColumns)
           
 
Method Summary
 void clearModified()
          clears the modification status of the object and all fields.
 T getBean()
           
 boolean getBeanProperties(java.lang.Object bean)
          writes all field values into a static Java Bean.
 boolean getBeanProperties(java.lang.Object bean, java.util.Collection<ColumnExpr> ignoreList)
          writes all field values into a static Java Bean.
 Column getColumn(int index)
          returns the column at the specified index.
 ColumnExpr getColumnExpr(int index)
          returns the column expression for a given column This is the reverse operation of getFieldIndex()
 int getFieldCount()
          returns the number of field available
 int getFieldIndex(ColumnExpr column)
          returns the index of the given column expression Indexed operations provide better performace for bulk processing
 int getFieldIndex(java.lang.String columnName)
          returns the index of the column expression with the given name
 Options getFieldOptions(Column column)
          returns the Options list for the given record field.
 Column[] getKeyColumns()
          returns an array of key columns which uniquely identify the record.
 java.lang.Object[] getKeyValues()
          Returns the array of primary key columns.
 java.lang.Object getValue(ColumnExpr column)
          returns the record value for a particular column
 java.lang.Object getValue(int index)
          returns the value of the field at the given index position Indexed operations provide better performace for bulk processing compared to getValue(ColumnExpr)
 boolean isFieldReadOnly(Column column)
          returns true if the field is read-only.
 boolean isFieldVisible(Column column)
          returns true if the field is visible to the client.
 boolean isModified()
          returns true if the record has been modified.
 boolean isNew()
          returns true if this record is a new record.
 boolean isNull(ColumnExpr column)
          checks if the record contains no value (null) for the given column
 boolean isNull(int index)
          checks if the field at the given index position contains no value (null) Indexed operations provide better performace for bulk processing compared to isNull(ColumnExpr)
 boolean isValid()
          returns true if the record is valid.
 void setBean(T data)
           
 boolean setBeanValues(java.lang.Object bean)
          sets all record values from a particular bean.
 boolean setBeanValues(java.lang.Object bean, java.util.Collection<Column> ignoreList)
          sets all record values from a particular bean.
 boolean setValue(Column column, java.lang.Object value)
          sets the value of a field.
 boolean setValue(int i, java.lang.Object value)
          sets the value of a field.
 boolean wasModified(Column column)
          Detects whether or not a particular field has been modified.
 
Methods inherited from class org.apache.empire.commons.ErrorObject
clearError, clearErrorInfo, error, error, error, error, error, error, error, getErrorInfo, getErrorMessage, getErrorParams, getErrorSource, getErrorType, getMessage, hasError, internalSetError, isExceptionsEnabled, setExceptionsEnabled, success
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.commons.logging.Log log
Constructor Detail

BeanRecordProxy

public BeanRecordProxy(T data,
                       java.util.List<Column> columns,
                       Column[] keyColumns)

BeanRecordProxy

public BeanRecordProxy(java.util.List<Column> columns,
                       Column[] keyColumns)

BeanRecordProxy

public BeanRecordProxy(T data,
                       BeanClass beanClass)

BeanRecordProxy

public BeanRecordProxy(BeanClass beanClass)
Method Detail

getBean

public T getBean()

setBean

public void setBean(T data)

getColumn

public Column getColumn(int index)
Description copied from interface: Record
returns the column at the specified index.

Specified by:
getColumn in interface Record
Parameters:
index - index of a requested column
Returns:
the column on the specified index

getColumnExpr

public ColumnExpr getColumnExpr(int index)
Description copied from interface: RecordData
returns the column expression for a given column This is the reverse operation of getFieldIndex()

Specified by:
getColumnExpr in interface RecordData
Parameters:
index - field index of the column expression
Returns:
the column expression object or null if the index is out of range

getKeyColumns

public Column[] getKeyColumns()
Description copied from interface: Record
returns an array of key columns which uniquely identify the record.

Specified by:
getKeyColumns in interface Record
Returns:
the array of key columns if any

getKeyValues

public java.lang.Object[] getKeyValues()
Returns the array of primary key columns.

Returns:
the array of primary key columns

getFieldCount

public int getFieldCount()
Description copied from interface: RecordData
returns the number of field available

Specified by:
getFieldCount in interface RecordData
Returns:
field count

getFieldIndex

public int getFieldIndex(ColumnExpr column)
Description copied from interface: RecordData
returns the index of the given column expression Indexed operations provide better performace for bulk processing

Specified by:
getFieldIndex in interface RecordData
Parameters:
column - the column for which to return the index
Returns:
the field index of the given column

getFieldIndex

public int getFieldIndex(java.lang.String columnName)
Description copied from interface: RecordData
returns the index of the column expression with the given name

Specified by:
getFieldIndex in interface RecordData
Parameters:
columnName - the name of the column for which to return the index
Returns:
the field index of the given column

getFieldOptions

public Options getFieldOptions(Column column)
Description copied from interface: Record
returns the Options list for the given record field.

Specified by:
getFieldOptions in interface Record
Parameters:
column - the column to check for visibility
Returns:
an options collection containing all allowed field values

isFieldReadOnly

public boolean isFieldReadOnly(Column column)
Description copied from interface: Record
returns true if the field is read-only.

Specified by:
isFieldReadOnly in interface Record
Parameters:
column - the requested column
Returns:
true if the field is read-only

isFieldVisible

public boolean isFieldVisible(Column column)
Description copied from interface: Record
returns true if the field is visible to the client.

Specified by:
isFieldVisible in interface Record
Parameters:
column - the column to check for visibility
Returns:
true if the field is visible to the client

isModified

public boolean isModified()
Description copied from interface: Record
returns true if the record has been modified.

Specified by:
isModified in interface Record
Returns:
true if the record has been modified or false otherwise

isNew

public boolean isNew()
Description copied from interface: Record
returns true if this record is a new record.

Specified by:
isNew in interface Record
Returns:
true if this record is a new record

isValid

public boolean isValid()
Description copied from interface: Record
returns true if the record is valid.

Specified by:
isValid in interface Record
Returns:
true if the record is valid

getValue

public java.lang.Object getValue(ColumnExpr column)
Description copied from interface: RecordData
returns the record value for a particular column

Specified by:
getValue in interface RecordData
Parameters:
column - the column for which to return the value
Returns:
the record value for the given column

getValue

public java.lang.Object getValue(int index)
Description copied from interface: RecordData
returns the value of the field at the given index position Indexed operations provide better performace for bulk processing compared to getValue(ColumnExpr)

Specified by:
getValue in interface RecordData
Parameters:
index - the field index for which to return the value
Returns:
the record value for the given field

isNull

public boolean isNull(ColumnExpr column)
Description copied from interface: RecordData
checks if the record contains no value (null) for the given column

Specified by:
isNull in interface RecordData
Parameters:
column - the column
Returns:
true if the value for the column is null or false otherwise

isNull

public boolean isNull(int index)
Description copied from interface: RecordData
checks if the field at the given index position contains no value (null) Indexed operations provide better performace for bulk processing compared to isNull(ColumnExpr)

Specified by:
isNull in interface RecordData
Parameters:
index - the field index
Returns:
true if the field value is null or false otherwise

setValue

public boolean setValue(Column column,
                        java.lang.Object value)
sets the value of a field.

Specified by:
setValue in interface Record
Parameters:
column - the requested column
value - the new record value for the given column
Returns:
true if value has been set or false if the value cannot be set for this column

setValue

public boolean setValue(int i,
                        java.lang.Object value)
sets the value of a field.

Specified by:
setValue in interface Record
Parameters:
i - index of the field for which to set the value
value - the new field value
Returns:
true if value has been set or false if the value cannot be set for this field

wasModified

public boolean wasModified(Column column)
Detects whether or not a particular field has been modified.

Specified by:
wasModified in interface Record
Parameters:
column - the requested column
Returns:
Returns true if a column has been modified

clearModified

public void clearModified()
clears the modification status of the object and all fields.


getBeanProperties

public boolean getBeanProperties(java.lang.Object bean)
Description copied from interface: RecordData
writes all field values into a static Java Bean.

In order to map column names to property names the property name is detected by ColumnExpr.getBeanPropertyName()

Specified by:
getBeanProperties in interface RecordData
Parameters:
bean - the Java Bean for which to set the properties
Returns:
true if at least one property has been successfully set

getBeanProperties

public boolean getBeanProperties(java.lang.Object bean,
                                 java.util.Collection<ColumnExpr> ignoreList)
Description copied from interface: RecordData
writes all field values into a static Java Bean.

In order to map column names to property names the property name is detected by ColumnExpr.getBeanPropertyName()

Specified by:
getBeanProperties in interface RecordData
Parameters:
bean - the Java Bean for which to set the properties
ignoreList - list of columns to skip (optional)
Returns:
true if at least one property has been successfully set

setBeanValues

public boolean setBeanValues(java.lang.Object bean,
                             java.util.Collection<Column> ignoreList)
Description copied from interface: Record
sets all record values from a particular bean.

The bean must provide corresponding getter functions for all desired column.

In order to map column names to property names the property name is detected by ColumnExpr.getBeanPropertyName()

Specified by:
setBeanValues in interface Record
Parameters:
bean - the Java Bean from which to read the value from
ignoreList - list of column to ignore
Returns:
true if at least one field value has been successfully set

setBeanValues

public boolean setBeanValues(java.lang.Object bean)
Description copied from interface: Record
sets all record values from a particular bean.

The bean must provide corresponding getter functions for all desired column.

Specified by:
setBeanValues in interface Record
Parameters:
bean - the Java Bean from which to read the value from
Returns:
true if at least one field value has been successfully set


Copyright © 2008-2009 Apache Software Foundation. All Rights Reserved.