|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.xoetrope.xui.data.XModel
net.xoetrope.xui.data.XBaseModel
net.xoetrope.xui.data.table.XTableModel
net.xoetrope.optional.data.sql.DatabaseTableModel
public class DatabaseTableModel
A wrapper for a database table allowing it to integrate with the XModel
The table model consists of a set of DatabaseRowModel objects and these in turn consist of DatabaseFieldModel nodes. These objects all act as wrappers for the DatabaseTable object and do not themselves maintain data.
Copyright: Copyright (c) 2003
License: see license.txt
| Field Summary | |
|---|---|
protected XProject |
currentProject
|
protected java.lang.String |
modelId
|
| Fields inherited from class net.xoetrope.xui.data.XBaseModel |
|---|
addByDefault, appendByDefault, attributeNames, attributeValues, ID_ATTRIBUTE, NUM_FIXED_ATTRIBUTE, VALUE_ATTRIBUTE, values |
| Fields inherited from class net.xoetrope.xui.data.XModel |
|---|
parentModel, tagName |
| Constructor Summary | |
|---|---|
DatabaseTableModel(XProject project)
Create a new model node for a database table |
|
| Method Summary | |
|---|---|
java.lang.Object |
append(java.lang.String id)
This method does not nothing it is provided merely as an implementation of the XModel interface. |
void |
dump(java.io.Writer w)
Write the contents of this model node to a stream |
int |
executeUpdate(java.lang.String sqlStr)
Update the underlying database table using the specified SQL statement |
DatabaseRowModel |
findRow(int fieldIdx,
java.lang.String value)
Find a row with a specified field value |
DatabaseRowModel |
findRow(java.lang.String where)
Find a row with a specified field value |
DatabaseTableModel |
findRows(int fieldIdx,
java.lang.String value)
Find a set of rows with a specified field value |
DatabaseTableModel |
findRows(java.lang.String where)
Find a set of rows with a specified field value |
DatabaseTableModel |
findRows(java.lang.String requestFields,
java.lang.String where)
Find a set of rows with a specified field value. |
void |
first()
Moves the table's cursor to the first row |
java.lang.Object |
get()
gets the value attribute |
XModel |
get(int i)
Get the XModel at element i |
java.lang.Object |
get(java.lang.String element)
Get the value of the element located at the path in the element parameter If the attribName parameter is not null we get the value of the attributeValues |
java.lang.String |
getAttribName(int i)
Gets the attribute name for field i. |
int |
getAttribute(java.lang.String attribName)
returns the index of the attribiteNames array whose value is the same as the attribName |
java.lang.Object |
getAttribValue(int i)
Get the value of an attribute (row) |
double |
getAttribValueAsDouble(int i)
Get an attribute as a double value |
int |
getAttribValueAsInt(int i)
Get an attribute as an int value |
java.lang.String |
getAttribValueAsString(int i)
Get an attribute as a String object |
boolean |
getDoesEscapeProcessing()
Gets the escape processing flag for the underlying JDBC implementation |
java.lang.String |
getFieldValue(int colIdx)
Provides iterative access to the table values. |
java.lang.String |
getFieldValue(int rowIdx,
int colIdx)
Provides random access to the table values. |
java.lang.String |
getId()
Gets the name attribute, by default the table name |
java.sql.ResultSetMetaData |
getMetaData()
Get the table's meta data |
int |
getNumAttributes()
Get the number of fields in this TableModel |
int |
getNumChildren()
Gets the number of rows for this table |
java.lang.String |
getOriginalSql()
|
int |
getSelectedRow()
Get the row selection index |
CachedDatabaseTable |
getTable()
|
static DatabaseTableModel |
getTable(XProject currentProject,
java.lang.String tableName)
Look up a table by name in the overall model. |
java.lang.String |
getTagName()
Gets the model element tag name, e.g. |
java.lang.String |
getValue()
Provides iterative access to the table values. |
XModel |
getValue(int i)
Get a child value/node (a DatabaseRowModel) at the specified index |
double |
getValueAsDouble(java.lang.String elementName)
Gets the value attribute as a double value from the current record |
int |
getValueAsInt(java.lang.String elementName)
Gets the value attribute of the specified node as an int. |
int |
hashCode()
Get the hashcode for this model node |
boolean |
hasMoreRows()
Has the table more records/rows? |
boolean |
isDistinct()
Check if the table is set to retrieve distinct rows |
void |
last()
Moves the table's cursor to the last row |
boolean |
next()
Moves the table's cursor to the next row |
boolean |
previous()
Moves the table's cursor to the previous row |
void |
retrieve()
Get the table data. |
void |
set(java.lang.Object s)
Sets the model value |
void |
set(java.lang.String attribName,
java.lang.Object newObject)
Set the value of the XModel located at the elementName |
void |
set(java.lang.String elementName,
java.lang.String attribName,
java.lang.Object newObject)
Set the value of the attribute in the XModel located at the elementName |
static void |
setAllowNull(boolean allow)
Set a flag to determine how null values are treated. |
void |
setAttribValue(int i,
java.lang.Object value)
Sets the attribute value |
void |
setDirty(boolean isDirty)
Ensures that the query is recalled. |
void |
setDistinct(boolean isDistinct)
Set the table to retrieve distinct rows |
void |
setDoesEscapeProcessing(boolean escapeProcessing)
Set the escape processing flag for the underlying JDBC implementation |
void |
setFieldValue(int rowIdx,
int colIdx,
java.lang.String newValue)
Set a field value |
void |
setFieldValue(int colIdx,
java.lang.String newValue)
Set a field value |
void |
setName(java.lang.String newName)
Sets the name attribute and constructs a new table of that name |
void |
setOrderField(java.lang.String fld)
Set the field(s) used ORDER clause of the SQL query |
void |
setParams(java.lang.String[] params)
Used in the case of a PreparedStatement. |
void |
setReadOnly(boolean b)
Sets the read only flag indicating whether or not the underlying table is read-only |
void |
setSelectedRow(int rowIdx)
Set the row selection index |
void |
setSqlStatement(java.lang.String sqlStr,
java.lang.String connName,
boolean writable)
Specify the sql statement in its entirety. |
void |
setupTable(java.lang.String tableName)
List the fields retrieved from the table |
void |
setupTable(java.lang.String tableName,
java.lang.String fields,
java.lang.String whereClause)
List the fields retrieved from the table |
void |
setupTable(java.lang.String tableName,
java.lang.String fields,
java.lang.String whereClause,
boolean writable)
List the fields retrieved from the table |
void |
setupTable(java.lang.String tableName,
java.lang.String fields,
java.lang.String whereClause,
java.lang.String connName,
boolean writable)
List the fields retrieved from the table |
void |
sync()
Syncs the model with the service response is the xtable has been changed or if the node has timed out. |
| Methods inherited from class net.xoetrope.xui.data.XBaseModel |
|---|
append, getAddByDefault, getAppendByDefault, getAttribFromPath, getAttribValueAsDouble, getBaseFromPath, getChildExists, getModel, getValueAsString, hasAutoId, hasAutoId, insertChildAt, remove, removeAttributes, removeChild, removeChild, removeChildren, setAddByDefault, setAppendByDefault, setAttribValue, setId, setNumAttributes, setNumChildren, swapNodes |
| Methods inherited from class net.xoetrope.xui.data.XModel |
|---|
addModelListener, clear, fireModelUpdated, getParent, prefixOutputPath, reset, resetAttributes, setParent, setTagName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String modelId
protected XProject currentProject
| Constructor Detail |
|---|
public DatabaseTableModel(XProject project)
project - the owner project| Method Detail |
|---|
public static void setAllowNull(boolean allow)
allow - if false then nulls are return as zero or an empty string, if
true the null is returned for string types and Double.NaN for doubles and
Integer.MIN_VALUE for int fields and so onpublic void setDirty(boolean isDirty)
isDirty - boolean to set the dirty flagpublic void setName(java.lang.String newName)
newName - the new namepublic int hashCode()
hashCode in class XBaseModelpublic void setupTable(java.lang.String tableName)
tableName - the database table name
public void setupTable(java.lang.String tableName,
java.lang.String fields,
java.lang.String whereClause)
tableName - the database table namefields - the database field names, or null if all fields are to be retrievedwhereClause - the where clause, or null if all rows are to be selected
public void setupTable(java.lang.String tableName,
java.lang.String fields,
java.lang.String whereClause,
java.lang.String connName,
boolean writable)
writable - true if the table is to be treated as writabletableName - the database table namefields - the database field names, or null if all fields are to be retrievedwhereClause - the where clause, or null if all rows are to be selectedconnName - the connection name
public void setSqlStatement(java.lang.String sqlStr,
java.lang.String connName,
boolean writable)
writable - true if the table is to be treated as writeablesqlStr - the full SQL statementconnName - the connection namepublic java.lang.String getOriginalSql()
public int executeUpdate(java.lang.String sqlStr)
throws java.lang.Exception
sqlStr - the full UPDATE SQL statement
java.lang.Exception - SqlException(s) thrown while performing the updatepublic void setDistinct(boolean isDistinct)
isDistinct - true if the DISTINCT keyword is to be used in the querypublic boolean isDistinct()
public void setOrderField(java.lang.String fld)
fld - the field name(s)
public void setupTable(java.lang.String tableName,
java.lang.String fields,
java.lang.String whereClause,
boolean writable)
tableName - the database table namefields - the database field names, or null if all fields are to be retrievedwhereClause - the where clause, or null if all rows are to be selectedwritable - sets the table as writable, normally this should be falsepublic void setReadOnly(boolean b)
b - true for a read-only table.public void sync()
sync in class XTableModelpublic java.lang.Object get(java.lang.String element)
get in class XBaseModelelement - The path to the XModel we require
public void set(java.lang.String elementName,
java.lang.String attribName,
java.lang.Object newObject)
elementName - The path to the XModel in the format 'base/fooattribName - The name of the attribute whose value we requirenewObject - The new value of the attribute
public void set(java.lang.String attribName,
java.lang.Object newObject)
set in class XBaseModelattribName - The path to the XModel in the format 'base/foonewObject - The new value of the XModelpublic XModel get(int i)
get in class XBaseModeli - The index of the values array
public java.lang.Object get()
get in class XBaseModelpublic java.lang.Object append(java.lang.String id)
append in class XBaseModelid - the node id
public void set(java.lang.Object s)
set in class XBaseModels - the new valuepublic java.lang.Object getAttribValue(int i)
getAttribValue in class XBaseModeli - The index of the attributeValues array whose value we want
public java.lang.String getAttribValueAsString(int i)
getAttribValueAsString in class XTableModeli - The index of the attributeValues array whose value we want
public double getAttribValueAsDouble(int i)
getAttribValueAsDouble in class XBaseModeli - The index of the attributeValues array whose value we want
public int getAttribValueAsInt(int i)
getAttribValueAsInt in class XBaseModeli - The index of the attributeValues array whose value we want
public int getAttribute(java.lang.String attribName)
getAttribute in class XBaseModelattribName - The name of the attribute we are trying to locate
public void retrieve()
retrieve in class XTableModelpublic void first()
public void last()
public boolean next()
public boolean hasMoreRows()
public boolean previous()
public java.lang.String getValue()
public XModel getValue(int i)
i - The index into the values array
public java.lang.String getFieldValue(int colIdx)
getFieldValue in class XTableModelcolIdx - the column of field index
public java.lang.String getFieldValue(int rowIdx,
int colIdx)
getFieldValue in class XTableModelrowIdx - the row indexcolIdx - the column of field index
public void setFieldValue(int colIdx,
java.lang.String newValue)
setFieldValue in class XTableModelcolIdx - the field index, zero basednewValue - the new field value
public void setFieldValue(int rowIdx,
int colIdx,
java.lang.String newValue)
setFieldValue in class XTableModelrowIdx - the row index, zero basedcolIdx - the field index, zero basednewValue - the new field valuepublic double getValueAsDouble(java.lang.String elementName)
getValueAsDouble in class XBaseModelelementName - the field/column name
public int getValueAsInt(java.lang.String elementName)
getValueAsInt in class XBaseModelelementName - the field name
public java.lang.String getAttribName(int i)
getAttribName in class XBaseModeli - The index of the attributeNames array whose value we want
public java.lang.String getId()
getId in class XBaseModel
public void setAttribValue(int i,
java.lang.Object value)
setAttribValue in class XBaseModeli - The index of the attributeValues array whose value we wantvalue - the value objectpublic int getNumChildren()
getNumChildren in class XBaseModelpublic int getNumAttributes()
getNumAttributes in class XBaseModelpublic java.lang.String getTagName()
getTagName in class XModel
public DatabaseTableModel findRows(int fieldIdx,
java.lang.String value)
fieldIdx - the index of the search fieldvalue - the search value
public DatabaseTableModel findRows(java.lang.String where)
where - the search criteria
public void setParams(java.lang.String[] params)
params - The String array which will popuate the PreparedStatement.
public DatabaseTableModel findRows(java.lang.String requestFields,
java.lang.String where)
requestFields - the fields to returnwhere - the search criteria
public DatabaseRowModel findRow(int fieldIdx,
java.lang.String value)
fieldIdx - the index of the search fieldvalue - the search value
public DatabaseRowModel findRow(java.lang.String where)
where - the search criteria
public static DatabaseTableModel getTable(XProject currentProject,
java.lang.String tableName)
tableName - the table name
public void dump(java.io.Writer w)
dump in interface DumpWriterw - the write/streampublic void setSelectedRow(int rowIdx)
setSelectedRow in interface XRowSelectorrowIdx - the new row selection index (zero based)public int getSelectedRow()
getSelectedRow in interface XRowSelectorpublic java.sql.ResultSetMetaData getMetaData()
public CachedDatabaseTable getTable()
public boolean getDoesEscapeProcessing()
public void setDoesEscapeProcessing(boolean escapeProcessing)
doesEscapeProcessing - true to setEscapeProcssing( true )
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||