|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.db.AbstractDBEntry
com.antelmann.db.PropertyEntryImpl
com.antelmann.sql.RowItem
public class RowItem
represents a row in a sql database table and provides convenient access to its properties.
It is suggested to have special derived RowItem classes to handle
special mappings.
To customize the way the columns are accessed vs. how they are stored,
consider overriding getProperty() and setProperty()
to convert e.g. from java.util.Date to java.sql.Timestamp and vice versa.
Also, you may want to override checkPropertyChange to restrict
the type for certain columns.
To support the dirty tag, the ChangeListenerSupport is enabled for RowItems
by default.
ConnectionHelper,
Serialized Form| Field Summary |
|---|
| Fields inherited from class com.antelmann.db.PropertyEntryImpl |
|---|
propertyChangeSupport, props, um, vcs |
| Fields inherited from interface com.antelmann.db.DBEntry |
|---|
ENTRY_FLAVOR, ENTRY_LIST_FLAVOR |
| Constructor Summary | |
|---|---|
RowItem(Object id,
RowItem row)
|
|
RowItem(String tableName,
String idColumn,
Object id,
Map<String,?> props,
String... columns)
|
|
RowItem(String tableName,
String idColumn,
Object id,
String... columns)
constructs a RowItem with empty properties and the given columns |
|
| Method Summary | |
|---|---|
protected void |
checkPropertyChange(String key,
Object value)
allows only keys that correspond to an existing column, unless there are no columns present, in which case true is always returned. |
boolean |
equals(Object obj)
a row is equal only if id, tableName and idColumn are equal; columns (other than the idColumn) are ignored |
static RowItem |
extractRow(ResultSet rs,
String idField)
the current row must not have been accessed, yet |
Map<String,Object> |
getColumnProperties()
extracts only those properties that corresponds to a column of this instance |
String[] |
getColumns()
returns all columns of the table other than the idColumn; the return value should not be altered to avoid unexpected behavior. |
String |
getIdColumn()
returns the field name for accessing the primary key (whoms value can be accessed by getID(). |
Map<String,Class<?>> |
getMetaData()
provides access to optional meta data information, mapping property keys to the associated class; this may return null. |
String |
getTableName()
|
boolean |
isDirty()
the dirty flag is automatically set to true on each property change if the ChangeListenerSupport remains enabled |
void |
loadStreams()
converts occurring InputStream to byte[] and Reader to StringBuffer,
so that this instance can be properly serialized after it has been received from a ResultSet. |
static void |
loadStreams(Map<String,Object> map)
converts occurring InputStream to byte[] and Reader to StringBuffer,
so that this instance can be properly serialized after it has been received from a ResultSet. |
void |
prepareStreams()
converts occurring byte[] to InputStream and StringBuffer to Reader,
so that this instance can be properly used by a ConnectionHelper for insert/update. |
static void |
prepareStreams(Map<String,Object> map)
converts occurring byte[] to InputStream and StringBuffer to Reader,
so that this instance can be properly used by a ConnectionHelper for insert/update. |
boolean |
sameTable(RowItem row)
checks for table, idColumn and columns to be identical |
void |
setColumns(String[] columns)
allows to set the available columns in the table belonging to this row. |
void |
setDirty(boolean flag)
|
void |
setIdColumn(String idColumn)
|
void |
setMetaData(Map<String,Class<?>> meta)
allows to optionally set meta data information that - if non-null - overrides the columns set for the checkPropertyChange() method. |
void |
setTableName(String tableName)
|
String |
toString()
|
| Methods inherited from class com.antelmann.db.AbstractDBEntry |
|---|
getID, hashCode, hashEntry, sameEntry |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.antelmann.db.DBEntry |
|---|
getID |
| Constructor Detail |
|---|
public RowItem(Object id,
RowItem row)
public RowItem(String tableName,
String idColumn,
Object id,
String... columns)
public RowItem(String tableName,
String idColumn,
Object id,
Map<String,?> props,
String... columns)
| Method Detail |
|---|
public void setMetaData(Map<String,Class<?>> meta)
public Map<String,Class<?>> getMetaData()
protected void checkPropertyChange(String key,
Object value)
throws IllegalArgumentException
checkPropertyChange in class PropertyEntryImplIllegalArgumentException - if the change of the value is not to be allowedPropertyEntryImpl.setProperty(String, Object),
PropertyEntryImpl.removeProperty(String)public boolean isDirty()
public void setDirty(boolean flag)
public String getTableName()
public void setTableName(String tableName)
public String getIdColumn()
getID().
public void setIdColumn(String idColumn)
public String[] getColumns()
public boolean sameTable(RowItem row)
public void setColumns(String[] columns)
throws NullPointerException
NullPointerExceptionpublic boolean equals(Object obj)
equals in class AbstractDBEntrypublic Map<String,Object> getColumnProperties()
public String toString()
toString in class AbstractDBEntry
public void loadStreams()
throws IOException
InputStream to byte[] and Reader to StringBuffer,
so that this instance can be properly serialized after it has been received from a ResultSet.
IOExceptionprepareStreams()
public static void loadStreams(Map<String,Object> map)
throws IOException
InputStream to byte[] and Reader to StringBuffer,
so that this instance can be properly serialized after it has been received from a ResultSet.
IOExceptionprepareStreams(Map)public void prepareStreams()
InputStream and StringBuffer to Reader,
so that this instance can be properly used by a ConnectionHelper for insert/update.
loadStreams()public static void prepareStreams(Map<String,Object> map)
InputStream and StringBuffer to Reader,
so that this instance can be properly used by a ConnectionHelper for insert/update.
loadStreams(Map)
public static RowItem extractRow(ResultSet rs,
String idField)
throws SQLException
SQLException
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||