|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.iplanet.jato.model.DefaultModel
A simple, in-memory Model
implementation which supports multiple
rows of arbitrary data. If display fields are not bound to another type of
model, they should normally be bound to a DefaultModel
instance.
Each container view has an implicit DefaultModel
instance that
should be used for this purpose.
Inner Class Summary | |
protected static class |
DefaultModel.Context
Encapsulates all the state for a context. |
protected static class |
DefaultModel.RowValueArrayList
An array list for storing rows of values. |
Field Summary | |
static java.lang.String |
DEFAULT_CONTEXT_NAME
|
static int |
UNDEFINED_ROW_INDEX
|
Constructor Summary | |
DefaultModel()
Construct an empty model |
|
DefaultModel(java.lang.String name)
Construct an empty model with the given name |
Method Summary | |
protected DefaultModel.Context |
addContext(java.lang.String name)
Adds an additional named context to this model |
void |
appendRow()
Append an empty row of data |
void |
beforeFirst()
Moves the internal location iterator to a special position such that a call to next() will position the location at the first row (if
available). |
protected boolean |
checkRowIndex()
Check that the current row index is within the bounds of the model's data. |
void |
clear()
Clears all values (from all rows) in this model |
protected void |
clearModelData()
Remove all existing model data and reset to the "before first" state |
protected java.util.Map |
createValueMap()
Allocates a new map object to store row data. |
void |
dumpValues(java.io.PrintStream out)
This method can be used during debugging to print all values in this model to the specified stream. |
void |
dumpValues(java.io.PrintWriter out)
This method can be used during debugging to print all values in this model to the specified stream. |
protected void |
ensureRow(int row)
Ensures that the specified row exists in the model's data store. |
boolean |
first()
Moves the internal location iterator to the first available row. |
protected DefaultModel.Context |
getContext(java.lang.String name)
Returns the named context object |
java.lang.String[] |
getContextNames()
Returns the full set of context names available in this model |
protected DefaultModel.Context |
getCurrentContext()
Returns the currently selected context object |
java.lang.String |
getCurrentContextName()
Returns the currently active context name |
java.lang.Object |
getDefaultValue(java.lang.String name)
Returns a named value from this model |
protected java.util.Map |
getDefaultValueMap()
Returns the default value map |
java.lang.Object[] |
getDefaultValues(java.lang.String name)
Returns a named set of values from this model |
int |
getLocation()
Returns the current row index |
int |
getLocationOffset()
Returns the offset of the first row of data |
java.lang.String |
getName()
Returns the logical instance name of this model. |
int |
getNumRows()
Returns the curren number of rows in this model |
int |
getRowIndex()
Returns the current row index, or location |
protected java.util.List |
getRowList()
Returns the internal list used to store rows of data. |
int |
getSize()
Return the number of available rows |
java.lang.Object |
getValue(java.lang.String name)
Returns a named value from this model |
protected java.util.Map |
getValueMap()
Returns the value map for the current row. |
protected java.util.Map |
getValueMap(int row)
Returns the value map for the specified row. |
java.lang.Object[] |
getValues(java.lang.String name)
Returns a named set of values from this model |
boolean |
hasValue(java.lang.String name)
Returns whether a value exists for the specified name |
protected void |
initializeDefaultContext()
Initializes the default context. |
void |
insertRow()
Insert an empty row of data at the current location |
boolean |
isDefaultContext()
Checks if the current context is the default context |
boolean |
isUseDefaultValues()
Indicates whether this model instance will use default values for empty fields. |
boolean |
last()
Moves the internal location iterator to the last available row. |
boolean |
next()
Moves the internal location iterator to the next available row |
boolean |
previous()
Moves the internal location iterator to the previous available row |
protected void |
removeContext(java.lang.String name)
Removes the named context from this model |
void |
selectContext(java.lang.String name)
Change the current context to the specified context |
void |
selectDefaultContext()
Change the current context to the default context |
void |
setDefaultValue(java.lang.String name,
java.lang.Object value)
Sets a named value in this model. |
void |
setDefaultValues(java.lang.String name,
java.lang.Object[] value)
Sets a named set of values in this model |
void |
setLocation(int location)
Sets the current row index |
void |
setName(java.lang.String value)
Sets the logical name of this model |
void |
setNumRows(int value)
Sets the current number of rows |
void |
setRowIndex(int value)
Sets the current row index, or location |
protected void |
setRowList(java.util.List value)
Sets the internal list used to store rows of data. |
void |
setSize(int value)
Sets the number of available rows. |
void |
setUseDefaultValues(boolean value)
Sets whether this model instance will use default values for empty fields. |
void |
setValue(java.lang.String name,
java.lang.Object value)
Sets a named value in this model. |
void |
setValues(java.lang.String name,
java.lang.Object[] value)
Sets a named set of values in this model |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int UNDEFINED_ROW_INDEX
public static final java.lang.String DEFAULT_CONTEXT_NAME
Constructor Detail |
public DefaultModel()
public DefaultModel(java.lang.String name)
Method Detail |
public java.lang.String getName()
ModelManager
may assign a name to a model based
on user request.getName
in interface Model
public void setName(java.lang.String value)
setName
in interface Model
name
- The new name of this modelpublic boolean isUseDefaultValues()
public void setUseDefaultValues(boolean value)
value
- Set to true if a default value should be used for a field when
its value is nullpublic void clear()
protected final void clearModelData()
public void dumpValues(java.io.PrintStream out)
out
- The stream to which to write the debug value informationpublic void dumpValues(java.io.PrintWriter out)
out
- The stream to which to write the debug value informationpublic int getSize() throws ModelControlException
getSize
in interface DatasetModel
ModelControlException
- Thrown if an error occurrs determining the number of rowspublic void setSize(int value) throws ModelControlException
setSize
in interface DatasetModel
ModelControlException
- Thrown if an error occurrs setting the number of rowspublic int getLocationOffset() throws ModelControlException
getLocationOffset
in interface DatasetModel
public int getLocation() throws ModelControlException
getLocation
in interface DatasetModel
ModelControlException
- Thrown if an error occurrs determining the current locationpublic void setLocation(int location) throws ModelControlException
setLocation
in interface DatasetModel
ModelControlException
- Thrown if an error occurrs setting the current locationpublic void beforeFirst() throws ModelControlException
next()
will position the location at the first row (if
available). Normally, a call to getLocation()
after this method
is called should return negative one (-1).beforeFirst
in interface DatasetModel
ModelControlException
- Thrown if an error occurrs setting the location to this special
positionpublic boolean first() throws ModelControlException
getLocation()
after this method is called should return zero
(0).first
in interface DatasetModel
ModelControlException
- Thrown if an error occurrs moving to the first datasetpublic boolean last() throws ModelControlException
getLocation()
after this method is called should return
getSize()-1
.last
in interface DatasetModel
ModelControlException
- Thrown if an error occurrs moving to the last rowpublic boolean next() throws ModelControlException
next
in interface DatasetModel
ModelControlException
- Thrown if an error occurrs positioning at the next rowpublic boolean previous() throws ModelControlException
previous
in interface DatasetModel
ModelControlException
- Thrown if an error occurrs positioning at the previous rowpublic int getNumRows()
public void setNumRows(int value)
value
- The new number of rows this model should contain. If the value is
greater than the current number of rows in the mode, the values of
newly allocated rows are allocated to null. If the specified value
is smaller than the number of current rows, the row data is truncated
to the number specified.public int getRowIndex()
getLocation()
public void setRowIndex(int value)
setLocation(int)
public void appendRow()
public void insertRow()
protected boolean checkRowIndex()
protected void ensureRow(int row)
row
- The index of the row up to which the data store will be
initializedprotected java.util.List getRowList()
protected void setRowList(java.util.List value)
protected java.util.Map createValueMap()
protected java.util.Map getValueMap()
protected java.util.Map getValueMap(int row)
protected java.util.Map getDefaultValueMap()
public java.lang.Object getValue(java.lang.String name)
getValue
in interface Model
name
- The name of the value to returnpublic void setValue(java.lang.String name, java.lang.Object value)
setValue
in interface Model
name
- The name of the value to setvalue
- The value to set in this modelpublic java.lang.Object[] getValues(java.lang.String name)
getValues
in interface Model
name
- The name of the value set to returnpublic void setValues(java.lang.String name, java.lang.Object[] value)
setValues
in interface Model
name
- The name of the value set to set in the modelvalues
- The set of values to set in this modelpublic boolean hasValue(java.lang.String name)
The
- name of the value to testpublic java.lang.Object getDefaultValue(java.lang.String name)
name
- The name of the value to returnpublic void setDefaultValue(java.lang.String name, java.lang.Object value)
name
- The name of the value to setvalue
- The value to set in this modelpublic java.lang.Object[] getDefaultValues(java.lang.String name)
name
- The name of the value set to returnpublic void setDefaultValues(java.lang.String name, java.lang.Object[] value)
name
- The name of the value set to set in the modelvalues
- The set of values to set in this modelpublic java.lang.String getCurrentContextName()
getCurrentContextName
in interface ContextualModel
public java.lang.String[] getContextNames()
getContextNames
in interface ContextualModel
public void selectContext(java.lang.String name) throws InvalidContextException
selectContext
in interface ContextualModel
com.iplanet.jato.model.ContextualModel
InvalidContextException
- Thrown if the provided context name does not represent
an available contextpublic void selectDefaultContext() throws InvalidContextException
selectDefaultContext
in interface ContextualModel
com.iplanet.jato.model.ContextualModel
InvalidContextException
- Thrown if the provided context name does not represent
an available contextpublic boolean isDefaultContext()
isDefaultContext
in interface ContextualModel
protected void initializeDefaultContext()
protected DefaultModel.Context getCurrentContext()
protected DefaultModel.Context addContext(java.lang.String name)
protected DefaultModel.Context getContext(java.lang.String name)
protected void removeContext(java.lang.String name)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |