com.yospace.yae.yogi
Class DefaultDataModel

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--com.yospace.yae.yogi.DefaultDataModel
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, DataModel, java.util.List, java.io.Serializable

public class DefaultDataModel
extends java.util.Vector
implements DataModel

Default implementation of the DataModel interface. Extends Vector to improve efficiency.

See Also:
Serialized Form

Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
DefaultDataModel()
          Default constructor.
DefaultDataModel(java.lang.Object[] values)
          Constructor taking an Object array of values with which the populate the DataModel.
 
Method Summary
 void addItem(java.lang.Object item)
          Adds an item to the DataModel.
 void addModelListener(AbstractTable table)
          Adds a model listener to the DataModel.
 void fireModelChanged()
          Fires an update to all model listeners that the state of the DataModel has changed.
 void fireModelChanged(int start, int end)
          Fires an update to the specified model listeners that the state of the DataModel has changed.
 java.lang.Object getItem(int index)
          Gets an item from the DataModel.
 int getSize()
          Gets the size of the DataModel.
 void insertItem(java.lang.Object item, int index)
          Inserts an item at the specified position in the DataModel.
 void removeAll()
          Removes all items from the DataModel.
 void removeItem(int index)
          Removes the item at the specified position from the DataModel.
 void removeModelListener(AbstractTable table)
          Removes the specified model listener from the DataModel.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Constructor Detail

DefaultDataModel

public DefaultDataModel()
Default constructor. Does nothing.

DefaultDataModel

public DefaultDataModel(java.lang.Object[] values)
Constructor taking an Object array of values with which the populate the DataModel.
Parameters:
values - the data.
Method Detail

getItem

public java.lang.Object getItem(int index)
Gets an item from the DataModel.
Specified by:
getItem in interface DataModel
Parameters:
index - The index of the item to get.
Returns:
the data Object at index.

addItem

public void addItem(java.lang.Object item)
Adds an item to the DataModel.
Specified by:
addItem in interface DataModel
Parameters:
item - The item to add.

insertItem

public void insertItem(java.lang.Object item,
                       int index)
Inserts an item at the specified position in the DataModel.
Specified by:
insertItem in interface DataModel
Parameters:
item - The item to add.
index - The position at which to add the item.

removeItem

public void removeItem(int index)
Removes the item at the specified position from the DataModel.
Specified by:
removeItem in interface DataModel
Parameters:
index - The position from which to remove the item.

removeAll

public void removeAll()
Removes all items from the DataModel.
Specified by:
removeAll in interface DataModel

getSize

public int getSize()
Gets the size of the DataModel.
Specified by:
getSize in interface DataModel
Returns:
the number of elements in the DataModel.

addModelListener

public void addModelListener(AbstractTable table)
Adds a model listener to the DataModel. The model listener must be the object which is using the DataModel to store its data, and is therefore a subclass of AbstractTable.
Specified by:
addModelListener in interface DataModel
Parameters:
table - the listener to add.

removeModelListener

public void removeModelListener(AbstractTable table)
Removes the specified model listener from the DataModel. The model listener must be the object which is using the DataModel to store its data, and is therefore a subclass of AbstractTable.
Specified by:
removeModelListener in interface DataModel
Parameters:
table - the listener to remove.

fireModelChanged

public void fireModelChanged()
Fires an update to all model listeners that the state of the DataModel has changed.

fireModelChanged

public void fireModelChanged(int start,
                             int end)
Fires an update to the specified model listeners that the state of the DataModel has changed. Remember they are stored in a Vector so start and end will be treated as positions in a Vector.
Parameters:
start - The first model listener to update.
end - The last model listener to update.

Copyright 2002 Yospace Holdings Ltd. All Rights Reserved.