Table of Contents
Dataset references
The DatasetRef class is used not only to create a reference to a dataset but also to initially create a dataset.
Creation
A DatasetRef can be initialized as a class with the name of the dataset a parameter, or using the rgg library function dataset(“DS_name”). If no dataset with this name exists an empty one is created.
Cleaning
To delete all data from a dataset using rgg:
dataset("DS_name").clear();
Adding data
Adding data to the referenced dataset can be done in two different ways, either by using java functions or with overloaded operators.
With java a row is added with addRow and then the data for the cells is defined with set(<columnNr>, value):
dataset("DS_name").addRow().set(0,11.4).set(1,23.5); dataset("DS_name").addRow().set(0,18.2).set(1,2.73);
Additionally with getRow(<rowNumber>) an already added row can be found to add or update cells.
The other way to do this would be to use the « operator to push data in to the dataset:
dataset("DS_name") << 11.4 << 23.5; dataset("DS_name") << 18.2 << 2.73;
In this way the first pushed value is added to the first column and so on.
Add several values to one cell
To add more values(up to three) to one cell the set function can be used with more values: set(<cloumnNr>,<xValue>,<yValue>) or set(<cloumnNr>,<xValue>,<yValue>,<zValue>).
Or using the operator:
dataset("DS_name") << new doulbe[]{11.4,23.5};
Exporting
Using rgg datasets can only be exported to csv like formats using the export function:
dataset("DS_name").export(new FileWriter(fileName));
By default this creates a file with white spaces as separators, if another separator are needed it can be defined as a second parameter dataset(“DS_name”).export(new FileWriter(fileName), “,”);.
An additional version of the two function exists with a StringBuffer as a first parameter.
