org.formaria.aria.data
Class ListModelAdapter

java.lang.Object
  extended by org.formaria.aria.data.ListModelAdapter
All Implemented Interfaces:
ModelAdapter

public class ListModelAdapter
extends java.lang.Object
implements ModelAdapter

Adapts an DataModel to provide access to child nodes as a list in a way that is more convenient for use with UI components and so that some state information can be maintained.

Copyright: Copyright (c) Formaria Ltd., 2008
License: see license.txt


Field Summary
protected  int columnIdx
           
protected  java.lang.String columnName
           
protected  DataModel model
           
 
Constructor Summary
ListModelAdapter()
          Constructs a new adapter.
ListModelAdapter(DataModel src)
          Constructs a new adapter for the specified model node.
 
Method Summary
 int find(java.lang.String key, int columnIdx)
          Locate a key value in the underlying data source
 java.lang.Object get(int i)
          Gets the individual list item value
 DataModel getDataModel()
          Get the model being used by this adapter
 int getNumChildren()
          Get the number of children belong to the model node that this object adapts
 java.lang.Object getSelected()
          Gets the value of the selected item from the list.
 java.lang.String getTagName()
          Gets the name of the model node
 void set(java.lang.Object o)
          Set the value of the listitem
 void setDataModel(DataModel src)
          Set the adapter source
 void setKeyColumn(int colIdx)
          Set the index of the column to use when getting values from this adapter
 void setKeyColumn(java.lang.String colName)
          Set the name of the column to use when getting values from this adapter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

protected DataModel model

columnIdx

protected int columnIdx

columnName

protected java.lang.String columnName
Constructor Detail

ListModelAdapter

public ListModelAdapter(DataModel src)
Constructs a new adapter for the specified model node.

Parameters:
src - The model for which this adapter is working

ListModelAdapter

public ListModelAdapter()
Constructs a new adapter.

Method Detail

setKeyColumn

public void setKeyColumn(int colIdx)
Set the index of the column to use when getting values from this adapter

Parameters:
colIdx - the (zero based) column index.

setKeyColumn

public void setKeyColumn(java.lang.String colName)
Set the name of the column to use when getting values from this adapter

Parameters:
colName - the column name.

getNumChildren

public int getNumChildren()
Get the number of children belong to the model node that this object adapts

Specified by:
getNumChildren in interface ModelAdapter
Returns:
the number of children

get

public java.lang.Object get(int i)
Gets the individual list item value

Specified by:
get in interface ModelAdapter
Parameters:
i - The index of the listitem
Returns:
The value of the listitem

set

public void set(java.lang.Object o)
Set the value of the listitem

Specified by:
set in interface ModelAdapter
Parameters:
o - The new value

getSelected

public java.lang.Object getSelected()
Gets the value of the selected item from the list.

Specified by:
getSelected in interface ModelAdapter
Returns:
the selected list item/node

setDataModel

public void setDataModel(DataModel src)
Set the adapter source

Specified by:
setDataModel in interface ModelAdapter
Parameters:
src - the model

getDataModel

public DataModel getDataModel()
Get the model being used by this adapter

Specified by:
getDataModel in interface ModelAdapter
Returns:
The model being used by this adapter

getTagName

public java.lang.String getTagName()
Gets the name of the model node

Returns:
the name

find

public int find(java.lang.String key,
                int columnIdx)
Locate a key value in the underlying data source

Parameters:
key - the key to locate
columnIdx - the index of the key column
Returns:
the row/record index taht contains the first instance of the key, or -1 if the key is not found