ir.thinkinsql
Class BaseRow

java.lang.Object
  extended by ir.thinkinsql.BaseRow
All Implemented Interfaces:
IRow
Direct Known Subclasses:
BaseRecord

public abstract class BaseRow
extends java.lang.Object
implements IRow

Provides an IRow adapter. BaseRow maps columns to properties as follows:

If a jdbc driver returns column names in mixed case, the case will be respected, except for characters following underscores. If you want to override the mapping convention, override getColumns and getFields.


Constructor Summary
BaseRow()
           
 
Method Summary
 void afterRead(Database db)
          afterRead is called after the values from an IReader are placed on the row.
 java.lang.String[] getColumns()
          Returns an array of column names, from which fields are populated.
 java.lang.String[] getFields()
          Returns a list of bean properties to receive result set values.
<T> T
getTemporaryProperty(java.lang.Object key, java.lang.Class<T> returnType)
          Allows retrieval of values placed using putTemporaryProperty.
 void putTemporaryProperty(java.lang.Object key, java.lang.Object value)
          Allows placement of arbitrary, non-persisted values on the instance.
 boolean setValueSpecial(Database db, java.lang.String columnName, java.lang.String propertyName, java.lang.Object value)
          Provides a plug point to transform a value taken from the named column on a ResultSet before assigning it to the named property.
 java.lang.String toString()
          Overridden to return JSON {t:getClass().getSimpleName(),[if IRecord, "pk1.pk2.pk3..."],col:val,col:val,...}
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ir.thinkinsql.IRow
getDatabase
 

Constructor Detail

BaseRow

public BaseRow()
Method Detail

afterRead

public void afterRead(Database db)
               throws java.lang.Exception
Description copied from interface: IRow
afterRead is called after the values from an IReader are placed on the row. This event handler can be implemented to perform any preparations that the IRow implementer may require before consuming code asks for values.

Specified by:
afterRead in interface IRow
Throws:
java.lang.Exception

getColumns

public java.lang.String[] getColumns()
                              throws java.lang.Exception
Description copied from interface: IRow
Returns an array of column names, from which fields are populated. The array returned must be parallel with that returned by getFields.

Specified by:
getColumns in interface IRow
Throws:
java.lang.Exception

getFields

public java.lang.String[] getFields()
                             throws java.lang.Exception
Description copied from interface: IRow
Returns a list of bean properties to receive result set values. The array returned must be parallel with that returned by getColumns.

Specified by:
getFields in interface IRow
Throws:
java.lang.Exception

getTemporaryProperty

public <T> T getTemporaryProperty(java.lang.Object key,
                                  java.lang.Class<T> returnType)
Description copied from interface: IRow
Allows retrieval of values placed using putTemporaryProperty.

Specified by:
getTemporaryProperty in interface IRow
returnType - saves casting
Returns:
value or null if not found

putTemporaryProperty

public void putTemporaryProperty(java.lang.Object key,
                                 java.lang.Object value)
Description copied from interface: IRow
Allows placement of arbitrary, non-persisted values on the instance.

Specified by:
putTemporaryProperty in interface IRow

setValueSpecial

public boolean setValueSpecial(Database db,
                               java.lang.String columnName,
                               java.lang.String propertyName,
                               java.lang.Object value)
                        throws java.lang.Exception
Description copied from interface: IRow
Provides a plug point to transform a value taken from the named column on a ResultSet before assigning it to the named property.
Return true if a special assignment has been made, or false if the standard assignment method should be used.

Specified by:
setValueSpecial in interface IRow
Throws:
java.lang.Exception

toString

public java.lang.String toString()
Overridden to return JSON {t:getClass().getSimpleName(),[if IRecord, "pk1.pk2.pk3..."],col:val,col:val,...}

Overrides:
toString in class java.lang.Object