Package org.apache.empire.db
Class DBRecordData
java.lang.Object
org.apache.empire.db.DBObject
org.apache.empire.db.DBRecordData
- All Implemented Interfaces:
RecordData,DBContextAware
- Direct Known Subclasses:
DBReader,DBRecordBase
This class provides access to the fields of one data-row of a table, view or query
The fields can be accessed either by Column or by index
There are various accessor functions for many data types.
The field values are converted to the desired type if possible.
The field values can be transferred to a classical Java-bean (aka Pojo)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract intaddXmlData(Element parent) abstract intaddXmlMeta(Element parent) protected StringformatValue(ColumnExpr column, Object value) Convert a non-string value to a stringget(ColumnExpr column) Returns a data value for the desired column .final <V> Vget(ColumnExpr column, Class<V> valueType) returns the record value for a particular columnfinal Object[]getArray(ColumnExpr... columns) Returns an array of values for the given column expressionsfinal booleangetBoolean(int index) Returns a data value identified by the column index.final booleangetBoolean(ColumnExpr column) Returns a data value for the desired column.final DategetDate(int index) Returns the value as as a java.util.Date object The data value is converted to a Date if necessary.final DategetDate(ColumnExpr column) Returns the value as as a java.util.Date object The data value is converted to a Date if necessary.final DategetDateTime(int index) Deprecated.final DategetDateTime(ColumnExpr column) Deprecated.final BigDecimalgetDecimal(int index) Returns a data value identified by the column index.final BigDecimalgetDecimal(ColumnExpr column) Returns a data value for the desired column.doublegetDouble(int index) Returns a data value identified by the column index.final doublegetDouble(ColumnExpr column) Returns a data value for the desired column.final <T extends Enum<?>>
TReturns the value of a field as an enum For numeric columns the value is assumed to be an ordinal of the enumeration item For non numeric columns the value is assumed to be the name of the enumeration itemfinal <T extends Enum<?>>
TReturns the value of a field as an enum This assumes that the column attribute "enumType" has been set to an enum type For numeric columns the value is assumed to be an ordinal of the enumeration itemfinal <T extends Enum<?>>
TgetEnum(ColumnExpr column, Class<T> enumType) Returns the value of a field as an enum For numeric columns the value is assumed to be an ordinal of the enumeration item For non numeric columns the value is assumed to be the name of the enumeration itemabstract intreturns the number of field availableabstract intgetFieldIndex(String column) returns the index of the column expression with the given nameabstract intgetFieldIndex(ColumnExpr column) returns the index of the given column expression Indexed operations provide better performance for bulk processingfinal intgetInt(int index) Returns a data value identified by the column index.final intgetInt(ColumnExpr column) Returns a data value for the desired column.final LocalDategetLocalDate(int index) Returns a data value identified by the column index.final LocalDategetLocalDate(ColumnExpr column) Returns a data value for the desired column.final LocalDateTimegetLocalDateTime(int index) Returns a data value identified by the column index.final LocalDateTimegetLocalDateTime(ColumnExpr column) Returns a data value for the desired column.final longgetLong(int index) Returns a data value identified by the column index.final longgetLong(ColumnExpr column) Returns a data value for the desired column.final StringgetString(int index) Returns a data value identified by the column index.final StringgetString(ColumnExpr column) Returns a data value for the desired column.final StringReturns the value of a column as a formatted text This converts the value to a string if necessary and performs an options lookup To customize conversion please override convertToString()getText(ColumnExpr column) Returns the value of a column as a formatted text This converts the value to a string if necessary and performs an options lookup To customize conversion please override convertToString()final TimestampgetTimestamp(int index) Returns the value as as a java.sql.Timestamp objectfinal TimestampgetTimestamp(ColumnExpr column) Returns the value as as a java.sql.Timestamp objectabstract ObjectgetValue(int index) Returns the raw field value based on the field index.<V> Vreturns the record value for a particular columnabstract DocumentbooleanisNull(int index) Checks whether or not the value for the given column is null.final booleanisNull(ColumnExpr column) Checks whether or not the value for the given column is null.booleanisZero(ColumnExpr column) Returns true if a numeric value is Zero For numeric columns only!final intsetBeanProperties(Object bean) Injects the current field values into a java bean.intsetBeanProperties(Object bean, Collection<? extends ColumnExpr> ignoreList) Injects the current field values into a java bean.protected voidsetBeanProperty(ColumnExpr column, Object bean, Object value) Set a single property value on a java bean objectMethods inherited from class org.apache.empire.db.DBObject
checkParamNull, getDatabaseMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.empire.db.context.DBContextAware
getContextMethods inherited from interface org.apache.empire.data.RecordData
getColumn
-
Constructor Details
-
DBRecordData
public DBRecordData()
-
-
Method Details
-
getFieldCount
public abstract int getFieldCount()Description copied from interface:RecordDatareturns the number of field available- Specified by:
getFieldCountin interfaceRecordData- Returns:
- field count
-
getFieldIndex
Description copied from interface:RecordDatareturns the index of the given column expression Indexed operations provide better performance for bulk processing- Specified by:
getFieldIndexin interfaceRecordData- Parameters:
column- the column for which to return the index- Returns:
- the field index of the given column
-
getFieldIndex
Description copied from interface:RecordDatareturns the index of the column expression with the given name- Specified by:
getFieldIndexin interfaceRecordData- Parameters:
column- the name of the column for which to return the index- Returns:
- the field index of the given column
-
addXmlMeta
-
addXmlData
-
getXmlDocument
-
getValue
Returns the raw field value based on the field index.- Specified by:
getValuein interfaceRecordData- Parameters:
index- the field index- Returns:
- the raw field value
-
getValue
returns the record value for a particular column- Specified by:
getValuein interfaceRecordData- Type Parameters:
V- the desired return type for the value- Parameters:
index- the field index for which to return the valuevalueType- the desired value type- Returns:
- the record value for the given column
-
get
returns the record value for a particular column- Specified by:
getin interfaceRecordData- Parameters:
column- the column for which to return the valuevalueType- the desired value type- Returns:
- the record value for the given column
-
get
Returns a data value for the desired column .- Specified by:
getin interfaceRecordData- Parameters:
column- the column for which to obtain the value- Returns:
- the record value
-
isNull
public boolean isNull(int index) Checks whether or not the value for the given column is null.- Specified by:
isNullin interfaceRecordData- Parameters:
index- index of the column- Returns:
- true if the value is null or false otherwise
-
isNull
Checks whether or not the value for the given column is null.- Specified by:
isNullin interfaceRecordData- Parameters:
column- identifying the column- Returns:
- true if the value is null or false otherwise
-
isZero
Returns true if a numeric value is Zero For numeric columns only!- Parameters:
column- the column- Returns:
- true if the value is zero or false otherwise
-
getString
Returns a data value identified by the column index. The data value is converted to a string if necessary.- Parameters:
index- index of the column- Returns:
- the value
-
getString
Returns a data value for the desired column. The data value is converted to a string if necessary.- Parameters:
column- identifying the column- Returns:
- the value
-
getInt
public final int getInt(int index) Returns a data value identified by the column index. The value is converted to integer if necessary .- Parameters:
index- index of the column- Returns:
- the record value
-
getInt
Returns a data value for the desired column. The data value is converted to integer if necessary.- Parameters:
column- identifying the column- Returns:
- the value
-
getLong
public final long getLong(int index) Returns a data value identified by the column index. The data value is converted to a long if necessary.- Parameters:
index- index of the column- Returns:
- the value
-
getLong
Returns a data value for the desired column. The data value is converted to a long if necessary.- Parameters:
column- identifying the column- Returns:
- the value
-
getDouble
public double getDouble(int index) Returns a data value identified by the column index. The data value is converted to double if necessary.- Parameters:
index- index of the column- Returns:
- the value
-
getDouble
Returns a data value for the desired column. The data value is converted to double if necessary.- Parameters:
column- identifying the column- Returns:
- the value
-
getDecimal
Returns a data value identified by the column index. The data value is converted to double if necessary.- Parameters:
index- index of the column- Returns:
- the value
-
getDecimal
Returns a data value for the desired column. The data value is converted to BigDecimal if necessary.- Parameters:
column- identifying the column- Returns:
- the value
-
getBoolean
public final boolean getBoolean(int index) Returns a data value identified by the column index. The data value is converted to boolean if necessary.- Parameters:
index- index of the column- Returns:
- the value
-
getBoolean
Returns a data value for the desired column. The data value is converted to boolean if necessary.- Parameters:
column- identifying the column- Returns:
- the value
-
getDate
Returns the value as as a java.util.Date object The data value is converted to a Date if necessary.- Parameters:
index- index of the column- Returns:
- the value
-
getDate
Returns the value as as a java.util.Date object The data value is converted to a Date if necessary.- Parameters:
column- identifying the column- Returns:
- the value
-
getDateTime
Deprecated. -
getDateTime
Deprecated. -
getTimestamp
Returns the value as as a java.sql.Timestamp object- Parameters:
index- the column index- Returns:
- the timestamp value
-
getTimestamp
Returns the value as as a java.sql.Timestamp object- Parameters:
column- the timestamp column- Returns:
- the timestamp value
-
getLocalDate
Returns a data value identified by the column index. The data value is converted to a Date if necessary.- Parameters:
index- index of the column- Returns:
- the value
-
getLocalDate
Returns a data value for the desired column. The data value is converted to a Date if necessary.- Parameters:
column- identifying the column- Returns:
- the value
-
getLocalDateTime
Returns a data value identified by the column index. The data value is converted to a Date if necessary.- Parameters:
index- index of the column- Returns:
- the value
-
getLocalDateTime
Returns a data value for the desired column. The data value is converted to a Date if necessary.- Parameters:
column- identifying the column- Returns:
- the value
-
getEnum
Returns the value of a field as an enum For numeric columns the value is assumed to be an ordinal of the enumeration item For non numeric columns the value is assumed to be the name of the enumeration item- Type Parameters:
T- the enum type- Parameters:
index- index of the fieldenumType- the enum type class- Returns:
- the enum value
-
getEnum
Returns the value of a field as an enum For numeric columns the value is assumed to be an ordinal of the enumeration item For non numeric columns the value is assumed to be the name of the enumeration item- Type Parameters:
T- the enum type- Parameters:
column- the column for which to retrieve the valueenumType- the enum type class- Returns:
- the enum value
-
getEnum
Returns the value of a field as an enum This assumes that the column attribute "enumType" has been set to an enum type For numeric columns the value is assumed to be an ordinal of the enumeration item- Type Parameters:
T- the enum type- Parameters:
column- the column for which to retrieve the value- Returns:
- the enum value
-
getArray
Returns an array of values for the given column expressions- Parameters:
columns- the column expressions- Returns:
- the corresponding record values
-
getText
Returns the value of a column as a formatted text This converts the value to a string if necessary and performs an options lookup To customize conversion please override convertToString()- Parameters:
column- the column for which to get the formatted value- Returns:
- the formatted value
-
getText
Returns the value of a column as a formatted text This converts the value to a string if necessary and performs an options lookup To customize conversion please override convertToString()- Parameters:
name- the column for which to get the formatted value- Returns:
- the formatted value
-
setBeanProperties
Injects the current field values into a java bean. The property name is detected by ColumnExpr.getBeanPropertyName()- Specified by:
setBeanPropertiesin interfaceRecordData- Parameters:
bean- the Java Bean for which to set the propertiesignoreList- list of columns to skip (optional)- Returns:
- the number of bean properties set on the supplied bean
-
setBeanProperties
Injects the current field values into a java bean. The property name is detected by ColumnExpr.getBeanPropertyName()- Parameters:
bean- the Java Bean for which to set the properties- Returns:
- the number of bean properties set on the supplied bean
-
setBeanProperty
Set a single property value on a java bean object- Parameters:
column- the column expressionbean- the beanvalue- the value
-
formatValue
Convert a non-string value to a string- Parameters:
column- the column expressionvalue- the value to format- Returns:
- the formatted string
-