|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.dynamide.DynamideObject com.dynamide.db.SimpleDatasource
public class SimpleDatasource
Implements the IDatasource interface as a simple grid; NOTE: Column names default to CASE-INSENSITIVE, unless setCaseInsensitive(false) is called. This class is not backed by any persistent store -- it is just for keeping values in memory.
Test with dynamide/src/shell/tests/test-SimpleDatasource.bs
Here's some notes on the implementation:
Registered Fields: current row: A B C rows: A0 B0 D0 A1 B1 C1 A2 B2 C2 single row widget: cb.field = "A" edit.field = "B" label.field = "C" cb.fieldIndex = "" edit.fieldIndex = "" label.fieldIndex = "" multi row input grid: cb.field = "A" edit.field = "B" label.field = "C" cb.fieldIndex = "0" edit.fieldIndex = "0" label.fieldIndex = "0" cb.field = "A" edit.field = "B" label.field = "C" cb.fieldIndex = "1" edit.fieldIndex = "1" label.fieldIndex = "1" cb.field = "A" edit.field = "B" label.field = "C" cb.fieldIndex = "2" edit.fieldIndex = "2" label.fieldIndex = "2"
Nested Class Summary | |
---|---|
class |
SimpleDatasource.SimpleDatasourceIterator
|
Field Summary | |
---|---|
protected StringList |
m_propertiesTable
|
Fields inherited from class com.dynamide.DynamideObject |
---|
m_id |
Fields inherited from interface com.dynamide.db.IDatasource |
---|
AFTER, BEFORE, BEFORE_FIRST, BEGIN, END, ROW_COUNT_NOT_ALLOWED, ROW_INDEX_UNKNOWN |
Constructor Summary | |
---|---|
SimpleDatasource()
|
|
SimpleDatasource(DynamideObject owner)
|
|
SimpleDatasource(DynamideObject owner,
Session session)
|
Method Summary | |
---|---|
void |
addColumn(java.lang.String fieldName,
java.lang.Object metadata)
|
Field |
addField(java.lang.String fieldName,
java.lang.Object value)
|
Field |
addField(java.lang.String fieldName,
java.lang.Object value,
java.lang.Object metadata)
|
void |
addRow()
|
void |
cancel()
|
void |
clear()
Clear the columns and cached data rows from this object, not necessarily from the underlying back end data -- calls clearColumns() and clearRows(). |
void |
clearColumns()
|
StringList |
clearCurrentRow()
|
void |
clearRows()
|
boolean |
deleteRow()
|
boolean |
deleteRow(int index)
|
int |
distanceToIndex(int distance)
|
static int |
distanceToIndex(int distance,
int currentRowIndex,
int rowCount)
|
java.lang.String |
dump()
Subclasses can override this with something more descriptive, for logging and debugging. |
java.lang.String |
dump(java.lang.String nl)
|
java.lang.String |
dumpErrorsHTML()
|
java.lang.String |
dumpRow()
|
static java.lang.String |
dumpRow(StringList row)
|
static java.lang.String |
dumpRow(java.lang.String id,
java.util.Map row)
|
protected java.lang.String |
fixCase(java.lang.String fieldName)
|
java.lang.Object |
get(java.lang.String what)
Subclasses can override this. |
boolean |
getCaseInsensitive()
|
java.lang.String |
getCategoryID()
|
java.lang.String |
getColumnNames()
|
java.util.List |
getColumnNamesList()
|
StringList |
getCurrentRow()
|
int |
getCurrentRowIndex()
The zero-based index of the current row: single-row implementations can always return 0, implementations that don't support row indices should return IDatasource.ROW_INDEX_UNKNOWN; |
IDatasource |
getDatasourceHelper()
By default, simply return a reference to "this", since the implementing class is an instance of IDatasource. |
Field |
getField(java.lang.String fieldName)
Maintain a list of Field objects; return the live Field when asked by this method. |
Field |
getField(java.lang.String fieldName,
java.lang.String fieldIndex)
This class can support indexed Fields, by any arbitrary String index, which will for tabular datasets, be the zero-based row index; however the index can be any valid string which could itself be a search specifier that is used by this method. |
java.util.Map |
getFields()
|
java.lang.String |
getID()
A unique name within the Application for this datasource, it becomes the ID by which Widgets can discover the datasource. |
java.lang.Object |
getMetadataForColumn(java.lang.String fieldName)
|
protected StringList |
getProperties()
|
Property |
getProperty(java.lang.String propertyName)
%% this is funky, since right now all are stored as String name and value. isEvent is just lost, for example. |
StringList |
getRow(int index)
|
int |
getRowCount()
The row count of the current dataset, or IDatasource.ROW_COUNT_NOT_ALLOWED if the operation is not supported. |
Session |
getSession()
|
boolean |
go(int distance)
go(0) should go to the first row in the set, if supported, go(-1) should go back a row, if supported, go(1) should go forward a row if supported, go(IDatasource.END) should go to the last row in the set, leaving the last row active, that is, not after the last row, and all unsupported actions should simply be no-ops. |
boolean |
hasMore()
|
void |
insertRow()
|
boolean |
insertRow(int index)
|
boolean |
isCurrentRow()
|
boolean |
isReadOnly()
Updateable datasets should return false. |
boolean |
isRowCountAllowed()
Report if calling getRowCount() will be allowed. |
java.util.Iterator |
iterator()
Return an Iterator which knows how to properly iterate over your implementation. |
boolean |
next()
|
void |
onRowChanged()
Subclasses can override to hook this notification; nothing is done in this class. |
boolean |
post()
If isReadOnly() returns false, and the underlying data can be updated, return true. |
void |
reload()
|
boolean |
seek(int zeroBasedIndex)
Jump to the absolute zero based index. |
boolean |
seekBegin()
|
boolean |
seekEnd()
|
void |
setCaseInsensitive(boolean new_value)
|
void |
setColumnNames(java.lang.String new_value)
Pass in a comma separated list of column names, and the columns will be created, without any associated metadata. |
protected void |
setCurrentRow(StringList newRow)
|
void |
setFieldError(java.lang.String fieldName,
java.lang.String errorMsg)
|
void |
setFieldValue(java.lang.String fieldName,
java.lang.Object value)
The editable Dynamide Widgets can use this to modify the underlying Fields. |
boolean |
setFieldValue(java.lang.String fieldName,
java.lang.Object value,
java.lang.String fieldIndex)
Optional operation: Dynamide Widgets can use this to modify the underlying datasource if the datasource supports indexed Fields. |
void |
setProperty(java.lang.String name,
java.lang.String value)
Rather than having a complicated interface to IDatasource, specialized behaviors can be set/retrieved using setProperty/getProperty, for example, "isMultiRowEditable". |
void |
setReadOnly(boolean new_value)
|
void |
setSession(Session new_value)
|
java.lang.String |
toString()
|
protected void |
updateCurrentRowPointers()
|
Methods inherited from class com.dynamide.DynamideObject |
---|
clearProfiler, dump, dumpHTML, expand, finalize, findParentExpander, findParentPage, findParentSession, findTopParentPage, getDotName, getNextGetter, getObjectID, getOwner, getProfiler, isDebugEnabled, isInfoEnabled, logDebug, logDebug, logDebug, logDebug, logError, logError, logError, logError, logInfo, logInfo, logInfo, logInfo, logWarn, logWarn, logWarn, logWarn, popLogContext, printf, printProfiler, profileEnter, profileLeave, pushLogContext, setDotName, setID, setNextGetter, setObjectID, setOwner, sprintf, useProfiler, walkParents |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected StringList m_propertiesTable
Constructor Detail |
---|
public SimpleDatasource(DynamideObject owner)
public SimpleDatasource()
public SimpleDatasource(DynamideObject owner, Session session)
Method Detail |
---|
public Session getSession()
public void setSession(Session new_value)
public StringList getRow(int index)
public StringList getCurrentRow()
protected void setCurrentRow(StringList newRow)
public StringList clearCurrentRow()
public boolean getCaseInsensitive()
public void setCaseInsensitive(boolean new_value)
public java.lang.String getColumnNames()
public void setColumnNames(java.lang.String new_value)
public java.util.List getColumnNamesList()
public java.lang.Object getMetadataForColumn(java.lang.String fieldName)
public java.lang.String getCategoryID()
getCategoryID
in class DynamideObject
protected java.lang.String fixCase(java.lang.String fieldName)
public void setReadOnly(boolean new_value)
protected void updateCurrentRowPointers()
public void onRowChanged()
onRowChanged
in interface IDatasource
public java.lang.String dump()
DynamideObject
dump
in class DynamideObject
public java.lang.String dump(java.lang.String nl)
public java.lang.String dumpRow()
public static java.lang.String dumpRow(StringList row)
public static java.lang.String dumpRow(java.lang.String id, java.util.Map row)
public java.lang.String dumpErrorsHTML()
dumpErrorsHTML
in interface IDatasource
public java.lang.String toString()
toString
in class java.lang.Object
public void clear()
clear
in interface IDatasource
public void clearColumns()
public void clearRows()
public boolean seekBegin()
seekBegin
in interface IDatasource
public boolean seekEnd()
seekEnd
in interface IDatasource
public void addRow()
public void insertRow()
public boolean insertRow(int index)
insertRow
in interface IDatasource
index
- Is one of IDatasource.BEGIN, IDatasource.END, IDatasource.AFTER, IDatasource.BEFORE
or is an absolute index the new row will occupy. For examle, if there is one row in the dataset,
then insertRow(0) would insert the new row at index 0, before the current row, while insertRow(1)
would place the new row at index 1, after the current row. IDatasource.AFTER would place the
new row after the current row, regardless of absolute index, and IDatasource.BEFORE would place the row
before the current row.
public boolean deleteRow()
public boolean deleteRow(int index)
public IDatasource getDatasourceHelper()
IDatasource
getDatasourceHelper
in interface IDatasource
getDatasourceHelper
in interface IDatasourceBasic
IDatasourceBasic
public java.util.Iterator iterator()
IDatasourceBasic
public class MyClass implements IDatasourceBasic{ public class MyDatasourceIterator implements Iterator { private MyClass m_target; private int m_iterCount = 0; public SessionDatasourceIterator(MyClass target){ m_target = target; } public Object next(){ m_iterCount++; return m_target; } public boolean hasNext(){ return (m_iterCount < 1); } public void remove(){ throw new UnsupportedOperationException(); } } }
iterator
in interface IDatasource
iterator
in interface IDatasourceBasic
IDatasourceBasic.iterator()
public void addColumn(java.lang.String fieldName, java.lang.Object metadata)
public Field addField(java.lang.String fieldName, java.lang.Object value, java.lang.Object metadata) throws DatatypeException
DatatypeException
public Field addField(java.lang.String fieldName, java.lang.Object value) throws DatatypeException
DatatypeException
public java.lang.String getID()
IDatasource
getID
in interface IDatasource
getID
in interface IDatasourceBasic
getID
in class DynamideObject
public java.util.Map getFields()
getFields
in interface IDatasource
getFields
in interface IDatasourceBasic
public Field getField(java.lang.String fieldName)
IDatasource
getField
in interface IDatasource
getField
in interface IDatasourceBasic
public Field getField(java.lang.String fieldName, java.lang.String fieldIndex)
IDatasource
getField
in interface IDatasource
public java.lang.Object get(java.lang.String what)
DynamideObject
get
in interface IDatasource
get
in interface IDatasourceBasic
get
in interface IGet
get
in class DynamideObject
public void setFieldValue(java.lang.String fieldName, java.lang.Object value)
IDatasource
setFieldValue
in interface IDatasource
public boolean setFieldValue(java.lang.String fieldName, java.lang.Object value, java.lang.String fieldIndex)
IDatasource
setFieldValue
in interface IDatasource
public void setFieldError(java.lang.String fieldName, java.lang.String errorMsg)
public boolean hasMore()
public boolean isCurrentRow()
public boolean isReadOnly()
IDatasource
isReadOnly
in interface IDatasource
public boolean post()
IDatasource
post
in interface IDatasource
public void cancel()
cancel
in interface IDatasource
public void reload() throws java.lang.Exception
reload
in interface IDatasource
java.lang.Exception
public boolean next()
public boolean seek(int zeroBasedIndex)
IDatasource
seek
in interface IDatasource
public boolean go(int distance)
IDatasource
go
in interface IDatasource
public int distanceToIndex(int distance)
public static int distanceToIndex(int distance, int currentRowIndex, int rowCount)
public boolean isRowCountAllowed()
IDatasource
isRowCountAllowed
in interface IDatasource
public int getRowCount()
IDatasource
getRowCount
in interface IDatasource
public int getCurrentRowIndex()
IDatasource
getCurrentRowIndex
in interface IDatasource
protected StringList getProperties()
public void setProperty(java.lang.String name, java.lang.String value) throws DatatypeException
IDatasource
setProperty
in interface IDatasource
DatatypeException
public Property getProperty(java.lang.String propertyName)
getProperty
in interface IDatasource
IDatasource.get(String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |