com.panayotis.gnuplot.dataset
Class GenericDataSet

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<ArrayList<String>>
              extended by com.panayotis.gnuplot.dataset.GenericDataSet
All Implemented Interfaces:
DataSet, Serializable, Cloneable, Iterable<ArrayList<String>>, Collection<ArrayList<String>>, List<ArrayList<String>>, RandomAccess
Direct Known Subclasses:
FileDataSet

public class GenericDataSet
extends ArrayList<ArrayList<String>>
implements DataSet

Generic data class to store data. This class stores data as a list of Strings, not numbers. Still, the user can check if the data are valid, by using a specific DataParser for this object.

In this dataset one can use any type of data, while in PointDataSet the data are stricted to numerical data only. Thus, data such as dates can be used.

Author:
teras
See Also:
DataParser, PointDataSet, Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
GenericDataSet()
          Create a new instance of GenericDataSet, with the default DataParser (DoubleDataParser)
GenericDataSet(boolean first_column_date)
          Create a new instance of GenericDataSet, with the default DataParser (DoubleDataParser), and the information that the first column is in date format.
GenericDataSet(DataParser parser)
          Create a new instance of GenericDataSet, with a given DataParser
 
Method Summary
 boolean add(ArrayList<String> point)
          Add a new point to this DataSet
 void add(int index, ArrayList<String> point)
          Add a new point to this DataSet at a specified position
 boolean addAll(Collection<? extends ArrayList<String>> pts)
          Add a collection of points to this DataSet
 boolean addAll(int index, Collection<? extends ArrayList<String>> pts)
          Add a collection of points to this DataSet starting at a specified position if there are data at the specified position, these will be shifted
 int getDimensions()
          Retrieve how many dimensions this dataset refers to.
 String getPointValue(int point, int dimension)
          Retrieve data information from a point.
 ArrayList<String> set(int index, ArrayList<String> point)
          Replace the Point at the specified position with the provided one
 
Methods inherited from class java.util.ArrayList
clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.panayotis.gnuplot.dataset.DataSet
size
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

GenericDataSet

public GenericDataSet()
Create a new instance of GenericDataSet, with the default DataParser (DoubleDataParser)

See Also:
DoubleDataParser

GenericDataSet

public GenericDataSet(boolean first_column_date)
Create a new instance of GenericDataSet, with the default DataParser (DoubleDataParser), and the information that the first column is in date format.

Parameters:
first_column_date - Whether the first column is in date format

GenericDataSet

public GenericDataSet(DataParser parser)
Create a new instance of GenericDataSet, with a given DataParser

Parameters:
parser - The DataParser to use
Method Detail

getDimensions

public int getDimensions()
Retrieve how many dimensions this dataset refers to.

Specified by:
getDimensions in interface DataSet
Returns:
the number of dimensions
See Also:
DataSet.getDimensions()

getPointValue

public String getPointValue(int point,
                            int dimension)
Retrieve data information from a point.

Specified by:
getPointValue in interface DataSet
Parameters:
point - The point number
dimension - The point dimension (or "column") to request data from
Returns:
the point data for this dimension
See Also:
DataSet.getPointValue(int,int)

add

public boolean add(ArrayList<String> point)
            throws NumberFormatException
Add a new point to this DataSet

Specified by:
add in interface Collection<ArrayList<String>>
Specified by:
add in interface List<ArrayList<String>>
Overrides:
add in class ArrayList<ArrayList<String>>
Parameters:
point - The point to add to this DataSet
Returns:
Whether the collection changed with this call
Throws:
NumberFormatException - If the given collection is not in the correct format

add

public void add(int index,
                ArrayList<String> point)
         throws NumberFormatException
Add a new point to this DataSet at a specified position

Specified by:
add in interface List<ArrayList<String>>
Overrides:
add in class ArrayList<ArrayList<String>>
Parameters:
index - Where to add this point
point - The point to add to this DataSet
Throws:
NumberFormatException - If the given collection is not in the correct format

addAll

public boolean addAll(Collection<? extends ArrayList<String>> pts)
               throws NumberFormatException
Add a collection of points to this DataSet

Specified by:
addAll in interface Collection<ArrayList<String>>
Specified by:
addAll in interface List<ArrayList<String>>
Overrides:
addAll in class ArrayList<ArrayList<String>>
Parameters:
pts - The points colelction
Returns:
Whether the collection changed with this call
Throws:
NumberFormatException - If the given collection is not in the correct format

addAll

public boolean addAll(int index,
                      Collection<? extends ArrayList<String>> pts)
               throws NumberFormatException
Add a collection of points to this DataSet starting at a specified position if there are data at the specified position, these will be shifted

Specified by:
addAll in interface List<ArrayList<String>>
Overrides:
addAll in class ArrayList<ArrayList<String>>
Parameters:
index - Where to start adding point data.
pts - The point collection to add
Returns:
Whether the collection changed with this call
Throws:
NumberFormatException - If the given collection is not in the correct format

set

public ArrayList<String> set(int index,
                             ArrayList<String> point)
                      throws NumberFormatException,
                             ArrayIndexOutOfBoundsException
Replace the Point at the specified position with the provided one

Specified by:
set in interface List<ArrayList<String>>
Overrides:
set in class ArrayList<ArrayList<String>>
Parameters:
index - The position of the point to be altered
point - The point to use
Returns:
The Point previously found in the specified position
Throws:
NumberFormatException - If the given collection is not in the correct format
ArrayIndexOutOfBoundsException


Copyright © 2013. All Rights Reserved.