data
Class DataHandler

java.lang.Object
  extended by data.DataHandler
Direct Known Subclasses:
OptimizationDataHandler

public class DataHandler
extends java.lang.Object

A class to handle sets of input-output data.

Author:
dgorur

Field Summary
protected  DataBlock lastBlock
           
 
Constructor Summary
DataHandler()
          Default constructor.
 
Method Summary
 boolean add(DataPoint dataPoint)
          Adds the given DataPoint to the set of data.
 void addBlock(DataBlock dataBlock)
          Adds the given DataBlock to the set of data.
 void addListener(DataListener dataListener)
          Adds the given DataListener to the list of listeners.
 void clear()
          Clears all data.
 boolean contains(java.lang.Object o)
           
 DataPoint get(int index)
          Returns the DataPoint at the specified index in the data list.
 java.util.ArrayList<DataListener> getDataListeners()
          Returns the list of DataListeners.
 int indexOf(java.lang.Object o)
          Returns the index of the first DataPoint in the list that equals the given object.
 boolean isEmpty()
          Returns true if the data list is empty.
 java.util.Iterator<DataPoint> iterator()
          Returns an iterator over the DataPoints in the data.
 DataPoint remove(int index)
          Removes the DataPoint at the specified index.
 boolean remove(java.lang.Object o)
          Removes all instances of the given Object from the list of data.
 void removeLastBlock()
          Removes the last block added.
 void removeListener(DataListener dataListener)
          Removes the given DataListener from the list of listeners.
 void removeRange(int from, int to)
          Removes DataPoints with indices in the specified range.
 int size()
          Returns the number of DataPoints in the collection of data.
 void writeToFile(java.io.PrintWriter writer)
          Writes the contents of this DataHandler to the specified print writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lastBlock

protected DataBlock lastBlock
Constructor Detail

DataHandler

public DataHandler()
Default constructor.

Method Detail

add

public boolean add(DataPoint dataPoint)
Adds the given DataPoint to the set of data. Notifies DataListeners of the addition.

Parameters:
dataPoint - the given DataPoint.
See Also:
ArrayList.add(java.lang.Object)

addBlock

public void addBlock(DataBlock dataBlock)
Adds the given DataBlock to the set of data.

Parameters:
dataBlock - the given DataBlock.

addListener

public void addListener(DataListener dataListener)
Adds the given DataListener to the list of listeners.

Parameters:
dataListener - the given DataListener.

clear

public void clear()
Clears all data. Notifies its DataListeners of the change.

See Also:
ArrayList.clear()

contains

public boolean contains(java.lang.Object o)
See Also:
ArrayList.contains(Object)

get

public DataPoint get(int index)
Returns the DataPoint at the specified index in the data list.

See Also:
ArrayList.get(int)

getDataListeners

public java.util.ArrayList<DataListener> getDataListeners()
Returns the list of DataListeners.

Returns:
the list of DataListeners of this data handler.

indexOf

public int indexOf(java.lang.Object o)
Returns the index of the first DataPoint in the list that equals the given object.

See Also:
ArrayList.indexOf(Object)

isEmpty

public boolean isEmpty()
Returns true if the data list is empty.

See Also:
ArrayList.isEmpty()

iterator

public java.util.Iterator<DataPoint> iterator()
Returns an iterator over the DataPoints in the data.

See Also:
AbstractList.iterator()

remove

public DataPoint remove(int index)
Removes the DataPoint at the specified index. Notifies DataListeners.

See Also:
ArrayList.remove(int)

remove

public boolean remove(java.lang.Object o)
Removes all instances of the given Object from the list of data. This is in contrast to the definition in the Java Collections Framework.

See Also:
AbstractCollection.remove(Object)

removeLastBlock

public void removeLastBlock()
Removes the last block added. Useful for rapidly adding and removing blocks.


removeListener

public void removeListener(DataListener dataListener)
Removes the given DataListener from the list of listeners.

Parameters:
dataListener - the DataListener to remove.

removeRange

public void removeRange(int from,
                        int to)
Removes DataPoints with indices in the specified range. Note removeRange(frmo, from) does nothing.

Parameters:
from - the index of the first element to be removed.
to - the index after the last element to be removed.

size

public int size()
Returns the number of DataPoints in the collection of data.

Returns:
the size of the data set.
See Also:
ArrayList.size()

writeToFile

public void writeToFile(java.io.PrintWriter writer)
Writes the contents of this DataHandler to the specified print writer. The format is intended for straightforward input by any program that can read serialized matrix data.

Parameters:
writer - the given PrintWriter.