|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.extentech.ExtenBean.DataObjectImpl
com.extentech.ExtenBean.ExtenDataObject
public abstract class ExtenDataObject
The ExtenDataObject provides the functionality of a persistent entity bean.
It is intended to be subclassed by objects which
represent data in a database or other persistent store.
An example of an implementation of the ExtenDataObject would be
a User class which contains information such as first name,
last name, and login credentials.
By using the built-in methods of the ExtenDataObject, a subclass
can easily populate itself with data from a database,
then perform updates/inserts/deletes with single method calls.
To instantiate an ExtenDataObject with data requires a number of steps
and the use of a ExtenBeanFactory which performs the database
calls to populate the object.
******** How To Retrieve Data Using DataObjects ********
1. Use the new constructor to get an empty instance of a subclass of a DataObject:
User u = new User();
2. Set the SQL for the object according to the data that
you wish to load into the object:
u.setSQL("SELECT * FROM USERS WHERE FIRSTNAME = " + firstname);
(note) for a more 'hard-coded' object, you can setSQL within the
constructor for the object.
3. Create (or use an existing) ExtenBeanFactory to do
the work of populating the data.
ExtenBeanFactory factory = new ExtenBeanFactory();
4. Send the DataObject to the factory to get its data:
u = factory.initDataObject(u);
5. Now that the DataObject has data, you can use the built-in
ExtenDataObject methods to access values.
The getVal command will access values based on
the name of the columns returned by the SQL query.
Logger.logInfo(u.getVal("FIRSTNAME");
******** How To Insert Data Using DataObjects ********
To Create a new DataObject, set its values, then save it to the database:
1. Use the new constructor to get an empty instance:
User u = new User();
2. Set the name of the table that you want to insert this object
into, as well as the key column that the bean will use to perform
the insert.
i.setTableName("USERS");
i.setDOLookupField("ID");
3. Create (or use an existing) ExtenBeanFactory to do
the work of populating the data.
ExtenBeanFactory factory = new ExtenBeanFactory();
4. Send the DataObject to the factory to get its MetaData information:
u = factory.createNewDataObject(u);
5. Use the methods of the empty object to set
the data. The setVal command will set values based on
the name of the columns in the database.
u.setVal(0,"FIRSTNAME", "John");
u.setVal(0,"LASTNAME", "Torres");
6. And perform the insert through the factory method:
u.store();
******** How To Delete Data Using DataObjects ********
factory.removeDataObject(u);
******** How To Update Data Using DataObjects ********
1. Set the new values:
u.setVal("FIRSTNAME", "Joe");
2. When done, use the factory method to update the database
u.store();
ExtenBeanFactory,
DataObject,
colinfo,
Serialized Form| Field Summary | |
|---|---|
boolean |
bof
|
boolean |
eof
|
int |
index
|
boolean |
validateEarly
|
| Fields inherited from class com.extentech.ExtenBean.DataObjectImpl |
|---|
dataObjectActionListeners, doparent, EXTENBEAN_LOADER_NAME, props |
| Constructor Summary | |
|---|---|
ExtenDataObject()
|
|
| Method Summary | |
|---|---|
void |
activate()
A container invokes this method when the instance is taken out of the pool of available instances to become associated with a specific EJB object. |
void |
addChildObject(RelationalObject o)
|
void |
addCol(String colname)
add a new col to this dataobject may affect ability to persist if model does not match |
void |
addOrderByItem(int idx,
Object obj)
Maintain a numeric lookup for this DataObject. |
boolean |
beginTrans()
A simple roll-back mechanism copies the data to a backup hashtable, then waits for a commit from factory. |
void |
dumpNameVals()
a convenience method for debugging which outputs all names and values for the data in this object. |
Object |
get(Object name)
implementation of Input Validation interface |
int |
getAbsolutePage()
|
boolean |
getBOF()
|
int |
getChangedRowCount()
|
Object[] |
getChangedRows()
|
List |
getChildObjects()
return a Listof all Child Objects |
colinfo[] |
getColinfo()
Returns the column metadata for this row of data. |
colinfo |
getColinfoByName(String colname)
|
int |
getColNumByName(String colname)
Find the column number in the data array which contains the column represented by this columnname. |
Map |
getData()
|
Object[] |
getDataArray()
This returns only the first row of the data array as an array of objects. |
SimpleDataObject |
getDataObject(int x)
get a new DataObject from this collection of Data. |
Object[] |
getDataRow(int idx)
get the data Object Array at the specified index. |
String |
getDOLookupField()
|
boolean |
getEOF()
|
boolean |
getHasChildren()
|
int |
getId()
|
int |
getIndex()
|
boolean |
getIsLastPage()
|
boolean |
getIsMultiKey()
|
boolean |
getIsMultiple()
|
colinfo |
getKeyCol()
|
String |
getKeyColName()
get the key column name for this dataobject |
int |
getLevel()
|
Hashtable |
getMetaDataHashtable()
|
Hashtable |
getOrderByHash()
|
int |
getPageSize()
|
int |
getParentId()
get the unique id of the parent object |
RelationalObject |
getParentObject()
get the parent DataObject for this child |
String |
getResourceName()
|
String |
getSequenceName()
|
String |
getSQL()
|
String |
getStringVal(int idx,
String key)
return the String value for the named column (field) at the row index specified ie: '0' for singleton DataObjects |
Object |
getVal(int idx,
String key)
Get String value for field at the specified index. |
Object |
getVal(int idx,
String key,
boolean nativeType)
|
String |
getVal(Object key)
Look up the key value, return the String value of the first field. |
Object |
getVal(Object key,
boolean nativeType)
Returns native datatype. |
String |
getVal(Object key,
int col)
Get value for field at the specified index. |
Object |
getVal(Object key,
int col,
boolean nativeType)
|
Object |
getVal(Object key,
String field)
Get value for field at the specified index. |
Object |
getVal(Object key,
String field,
boolean nativeType)
|
Object |
getVal(String key)
Look up the key value, return the String value of the first field. |
Object |
getVal(String key,
boolean nativeType)
|
void |
init()
perform post-data-initialization tasks |
boolean |
isPageable()
|
void |
moveFirst()
|
void |
moveLast()
|
void |
moveNext()
|
void |
movePrevous()
|
void |
passivate()
A container invokes this method on an instance before the instance becomes disassociated with a specific EJB object. |
void |
remove()
A container invokes this method before it removes the EJB object that is currently associated with the instance. |
void |
removeAll()
|
void |
removeByKey(Object key)
|
void |
removeChangedRow(Object o)
removes a changed row identified by the Object index |
void |
removeChangedRows()
|
boolean |
rollBack()
A simple roll-back mechanism copies the data back from a backup hashtable, then waits for a DB update from factory. |
void |
setAbsolutePage(int absolutePage)
|
void |
setBOF(boolean b)
|
void |
setColinfo(colinfo[] c)
set the array of colinfos for this DataObject |
void |
setData(Map d)
|
void |
setDataRowChanged(int idx)
|
void |
setDataRowChanged(Object idx)
|
void |
setDEBUG(boolean b)
|
void |
setDOLookupField(String k)
set the lookup (unique id) field for this DataObject |
void |
setEOF(boolean b)
|
void |
setHasChildren(boolean b)
|
void |
setId(int id)
set the Id for this DataObject |
boolean |
setIndex(int index)
|
void |
setIsLastPage(boolean isLastPage)
|
void |
setKeyCol(colinfo c)
|
void |
setKeyCol(String c)
Set the key column for this DataObject Manually |
void |
setLevel(int i)
the level indicates the depth of this object in a Relational Heirarchy |
void |
setMetaDataHashtable(Hashtable h)
|
void |
setMethodValsFromDO()
set the values of this dataobject using the set methods with the data from the getVal() methods. |
void |
setPageSize(int pageSize)
|
void |
setParent(RelationalObject par)
set the parent DataObject for this child |
void |
setParentForeignKey(String fldname)
set the key name of the parent DataObject |
void |
setResourceName(String s)
|
void |
setSequenceName(String sequenceName)
|
void |
setSQL(String sql)
set the SQL for this XDO |
void |
setVal(int idx,
String key,
Object val)
update the value in the data object array pointed to by the index value |
void |
setVal(Object idx,
Object key,
Object val)
update the value in the data object array pointed to by the index value |
void |
setVal(String key,
Object val)
update the first value in the data object array pointed to by the index value |
void |
setValsFromObject(Object obj)
pass an Object to this DataObject and set the DataObject values to the values of the Object where the member variable names have matching setVal("fieldname") fields. |
void |
setValsOnObject(Object obj)
pass an Object to this DataObject and set the Object's values to the values of the DataObject where the member variable names have matching getVal("fieldname") fields. |
void |
store()
A container invokes this method to instruct the instance to synchronize its state by storing it to the underlying database. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.extentech.ExtenBean.DataObject |
|---|
addDataObjectActionListener, fireDataObjectActionEvent, getCascadeUpdates, getChildByName, getColnames, getDataObjectActionListeners, getFactory, getIsNew, getNumRows, load, removeDataObjectActionListener, removeDataObjectActionListeners, setCascadeUpdates, setFactory, setIsMultiple, setIsNew |
| Methods inherited from interface com.extentech.ExtenBean.SimpleDataObject |
|---|
getColNames, getStringVal, isNew |
| Methods inherited from interface com.extentech.ExtenBean.RelationalObject |
|---|
getAllChildrenInHeirarchy, hasChildren |
| Methods inherited from interface com.extentech.ExtenBean.SQLObject |
|---|
getIsUpdateable, getParentForeignKey, getTableName, setIsUpdateable, setTableName |
| Field Detail |
|---|
public boolean validateEarly
public int index
public boolean eof
public boolean bof
| Constructor Detail |
|---|
public ExtenDataObject()
| Method Detail |
|---|
public int getChangedRowCount()
getChangedRowCount in interface DataObjectgetChangedRowCount in class DataObjectImplpublic void setDEBUG(boolean b)
setDEBUG in class DataObjectImplpublic void setResourceName(String s)
public String getResourceName()
public boolean isPageable()
isPageable in interface DataObjectisPageable in class DataObjectImplpublic void setEOF(boolean b)
public void setBOF(boolean b)
public boolean getEOF()
public boolean getBOF()
public void setLevel(int i)
setLevel in interface RelationalObjectsetLevel in class DataObjectImplpublic int getLevel()
getLevel in interface RelationalObjectgetLevel in class DataObjectImplpublic void activate()
activate in interface DataObjectpublic void passivate()
passivate in interface DataObjectpassivate in class DataObjectImpl
public void remove()
throws SQLException
remove in interface DataObjectremove in interface SimpleDataObjectremove in class DataObjectImplSQLException
public void store()
throws SQLException
store in interface DataObjectstore in interface SimpleDataObjectstore in class DataObjectImplSQLExceptionpublic Object get(Object name)
public void dumpNameVals()
dumpNameVals in class DataObjectImplpublic void setValsFromObject(Object obj)
public void setMethodValsFromDO()
public void setValsOnObject(Object obj)
public void setPageSize(int pageSize)
public int getPageSize()
public void setAbsolutePage(int absolutePage)
public int getAbsolutePage()
public void setIsLastPage(boolean isLastPage)
public boolean getIsLastPage()
public String getSequenceName()
public void setSequenceName(String sequenceName)
public boolean setIndex(int index)
public int getIndex()
public void moveFirst()
public void moveLast()
public void movePrevous()
public void moveNext()
public Object getVal(String key,
boolean nativeType)
public String getStringVal(int idx,
String key)
DataObject
getStringVal in interface DataObjectgetStringVal in interface SimpleDataObjectgetStringVal in class DataObjectImpl
public Object getVal(Object key,
boolean nativeType)
public Object getVal(Object key,
String field,
boolean nativeType)
public Object getVal(Object key,
int col,
boolean nativeType)
public Object getVal(int idx,
String key,
boolean nativeType)
public String getKeyColName()
getKeyColName in interface SQLObjectgetKeyColName in class DataObjectImplpublic void setKeyCol(colinfo c)
setKeyCol in interface SQLObjectsetKeyCol in class DataObjectImplpublic void setParentForeignKey(String fldname)
setParentForeignKey in interface SQLObjectsetParentForeignKey in class DataObjectImplpublic int getParentId()
getParentId in interface SQLObjectgetParentId in class DataObjectImplpublic void setParent(RelationalObject par)
setParent in interface RelationalObjectsetParent in class DataObjectImplpublic RelationalObject getParentObject()
getParentObject in interface RelationalObjectgetParentObject in class DataObjectImplpublic void setKeyCol(String c)
setKeyCol in interface SQLObjectsetKeyCol in class DataObjectImplpublic colinfo getKeyCol()
getKeyCol in interface SQLObjectgetKeyCol in class DataObjectImplpublic String getDOLookupField()
getDOLookupField in interface DataObjectgetDOLookupField in class DataObjectImplpublic void setDOLookupField(String k)
DataObject
setDOLookupField in interface DataObjectsetDOLookupField in class DataObjectImplpublic boolean getIsMultiKey()
getIsMultiKey in class DataObjectImplpublic void init()
init in interface DataObjectpublic SimpleDataObject getDataObject(int x)
getDataObject in interface SimpleDataObjectpublic boolean rollBack()
rollBack in interface SQLObjectrollBack in class DataObjectImplpublic boolean beginTrans()
beginTrans in interface SQLObjectbeginTrans in class DataObjectImpl
public void addOrderByItem(int idx,
Object obj)
addOrderByItem in interface DataObjectaddOrderByItem in class DataObjectImplpublic Hashtable getOrderByHash()
getOrderByHash in interface DataObjectgetOrderByHash in class DataObjectImplpublic colinfo[] getColinfo()
DataObject
getColinfo in interface DataObjectgetColinfo in interface SimpleDataObjectgetColinfo in class DataObjectImplpublic void setColinfo(colinfo[] c)
DataObject
setColinfo in interface DataObjectsetColinfo in class DataObjectImplpublic Object[] getDataArray()
getDataArray in class DataObjectImplpublic void setDataRowChanged(int idx)
setDataRowChanged in class DataObjectImplpublic void setDataRowChanged(Object idx)
setDataRowChanged in class DataObjectImplpublic Object[] getChangedRows()
getChangedRows in interface DataObjectgetChangedRows in class DataObjectImplpublic void removeChangedRow(Object o)
DataObject
removeChangedRow in interface DataObjectremoveChangedRow in class DataObjectImplpublic void removeChangedRows()
removeChangedRows in interface DataObjectremoveChangedRows in class DataObjectImplpublic void setMetaDataHashtable(Hashtable h)
public Hashtable getMetaDataHashtable()
public void setData(Map d)
setData in interface SQLObjectsetData in class DataObjectImplpublic Map getData()
getData in interface DataObjectgetData in class DataObjectImplpublic boolean getHasChildren()
public String getSQL()
getSQL in interface SQLObjectgetSQL in class DataObjectImplpublic void setHasChildren(boolean b)
setHasChildren in class DataObjectImplpublic void setSQL(String sql)
setSQL in interface SQLObjectsetSQL in class DataObjectImplpublic Object getVal(String key)
getVal in interface DataObjectgetVal in interface SimpleDataObjectgetVal in class DataObjectImplpublic String getVal(Object key)
public Object getVal(Object key,
String field)
getVal in interface DataObjectgetVal in class DataObjectImplkey - field -
public String getVal(Object key,
int col)
key - field -
public Object getVal(int idx,
String key)
getVal in interface DataObjectgetVal in interface SimpleDataObjectgetVal in class DataObjectImplkey - idx - public void addCol(String colname)
colname -
public void setVal(String key,
Object val)
setVal in interface DataObjectsetVal in interface SimpleDataObjectsetVal in class DataObjectImpl
public void setVal(int idx,
String key,
Object val)
setVal in interface DataObjectsetVal in interface SimpleDataObjectsetVal in class DataObjectImpl
public void setVal(Object idx,
Object key,
Object val)
setVal in class DataObjectImplpublic colinfo getColinfoByName(String colname)
getColinfoByName in interface DataObjectgetColinfoByName in interface SimpleDataObjectgetColinfoByName in class DataObjectImplpublic int getColNumByName(String colname)
getColNumByName in interface DataObjectgetColNumByName in class DataObjectImplpublic Object[] getDataRow(int idx)
getDataRow in interface DataObjectgetDataRow in interface SimpleDataObjectgetDataRow in class DataObjectImplpublic void addChildObject(RelationalObject o)
addChildObject in interface RelationalObjectaddChildObject in class DataObjectImplpublic List getChildObjects()
RelationalObject
getChildObjects in interface RelationalObjectgetChildObjects in class DataObjectImplpublic boolean getIsMultiple()
getIsMultiple in interface DataObjectgetIsMultiple in interface SimpleDataObjectgetIsMultiple in class DataObjectImplpublic int getId()
getId in interface DataObjectgetId in class DataObjectImplpublic void setId(int id)
DataObject
setId in interface DataObjectsetId in class DataObjectImplpublic void removeAll()
removeAll in class DataObjectImplpublic void removeByKey(Object key)
removeByKey in class DataObjectImpl
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||