|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jcckit.data.DataContainer
Abstract superclass of all data containers. A data container holds an
ordered list of DataElements
of the same type.
Data elements can be added, inserted, removed, or replaced.
Such an action leads to a DataEvent
which will be delivered to
all DataListeners
observing this
DataContainer
. If this data container also implements
DataEvent
(as DataCurve
does) also the listeners
registrated at the data container containg this container will be notified.
As a consequence a DataListener must only be registered at the
DataPlot
instance and it will automatically also received events
caused by manipulating one of its DataCurves.
Concrete subclasses have to implement isValid(jcckit.data.DataElement)
which
checks whether the added or inserted DataElement is of the right
type. This is an application of the Template Method Design Pattern.
Constructor Summary | |
DataContainer()
|
Method Summary | |
void |
addDataListener(DataListener listener)
Adds a DataListener . |
void |
addElement(DataElement element)
Adds a DataElement . |
DataElement |
getElement(int index)
Returns the element for the specified index. |
int |
getIndexOf(DataElement element)
Returns the index of the specified element. |
int |
getNumberOfElements()
Returns the number of elements of this container. |
void |
insertElementAt(int index,
DataElement element)
Inserts a DataElement at the specified index.
|
protected abstract boolean |
isValid(DataElement element)
Returns true if the specified DataElement has the
correct type. |
void |
removeDataListener(DataListener listener)
Removes a DataListener . |
void |
removeElementAt(int index)
Removes a DataElement at the specified index.
|
void |
replaceElementAt(int index,
DataElement element)
Replaces the DataElement at the specified index.
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DataContainer()
Method Detail |
public void addDataListener(DataListener listener)
DataListener
. Does nothing if already added.
public void removeDataListener(DataListener listener)
DataListener
. Does nothing if already removed.
public int getNumberOfElements()
public DataElement getElement(int index)
public int getIndexOf(DataElement element)
element
- Element to be looked for.
public void addElement(DataElement element)
DataElement
. After the element has been successfully
added all DataListeners
will be informed.
element
- DataElement to be added.
java.lang.IllegalArgumentException
- if element is not of the correct
type which will be checked by the method isValid(jcckit.data.DataElement)
.public void insertElementAt(int index, DataElement element)
DataElement
at the specified index.
After the element has been successfully inserted
all DataListeners
will be informed.
index
- Index at which element will be inserted.
All elements with an index >= index will be shifted.element
- DataElement to be added.
java.lang.IllegalArgumentException
- if element is not of the correct
type which will be checked by the method isValid(jcckit.data.DataElement)
.public void removeElementAt(int index)
DataElement
at the specified index.
After the element has been successfully removed
all DataListeners
will be informed.
index
- Index of the element which will be removed.
All elements with an index > index will be shifted.public void replaceElementAt(int index, DataElement element)
DataElement
at the specified index.
After the element has been successfully replaced
all DataListeners
will be informed.
index
- Index of the element which will be replaced by
element.element
- The new DataElement.
java.lang.IllegalArgumentException
- if element is not of the correct
type which will be checked by the method isValid(jcckit.data.DataElement)
.protected abstract boolean isValid(DataElement element)
DataElement
has the
correct type. Concrete subclasses have to implement this method.
element
- DataElement to be checked.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |