COM.hugin.HAPI
Class DataSet

java.lang.Object
  extended by COM.hugin.HAPI.DataSet

public class DataSet
extends java.lang.Object

The DataSet class. This class represents a data set as a "matrix" with cases as rows and variables as columns.


Constructor Summary
DataSet()
          Constructs a new (empty) DataSet.
DataSet(java.lang.String csvStringOrFileName, char separator, ParseListener parseListener)
          Constructs a DataSet from a CSV specification provided in a file or as a string.
 
Method Summary
 void delete()
          Deletes this DataSet.
 void deleteColumn(long column)
          Deletes the specified column from this DataSet.
 void deleteRow(long row)
          Deletes the specified row from this DataSet.
 java.lang.String getColumnName(long column)
          Returns the name of the specified column of this DataSet.
 java.lang.String getDataItem(long row, long column)
          Returns the data item at the specified location of this DataSet.
 long getNumberOfColumns()
          Returns the number of columns in this DataSet.
 long getNumberOfRows()
          Returns the number of rows in this DataSet.
 java.lang.Object getUserData()
          Returns the value stored within the user data slot of this DataSet.
 boolean isAlive()
          Is this DataSet object alive?
 void moveColumn(long column, long newColumn)
          Moves the specified column to a new position.
 void moveRow(long row, long newRow)
          Moves the specified row to a new position.
 long newColumn(java.lang.String name)
          Creates a new column in this DataSet.
 long newRow()
          Creates a new row in this DataSet.
 void saveAsCSV(java.lang.String fileName, char delimiter)
          Saves this DataSet in the format of a comma-separated-values (CSV) file.
 void setColumnName(long column, java.lang.String name)
          Sets the name of the specified column of this DataSet.
 void setDataItem(long row, long column, java.lang.String data)
          Sets (or deletes) the data item at the specified location of this DataSet.
 void setUserData(java.lang.Object data)
          Sets the user data field of this DataSet.
 java.lang.String toCSVString(char delimiter)
          Creates a CSV representation (as a string) of this DataSet.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSet

public DataSet()
        throws ExceptionHugin
Constructs a new (empty) DataSet.

Throws:
ExceptionHugin

DataSet

public DataSet(java.lang.String csvStringOrFileName,
               char separator,
               ParseListener parseListener)
        throws ExceptionHugin
Constructs a DataSet from a CSV specification provided in a file or as a string. Instead of a comma, a different separator character may be used.

Parameters:
csvStringOrFileName - a string containing a CSV specification or the name of a CSV file
separator - the separator character (must not be a double-quote character)
parseListener - the ParseListener used for handling parse errors.
Throws:
ExceptionHugin
Method Detail

delete

public void delete()
            throws ExceptionHugin
Deletes this DataSet.

Throws:
ExceptionHugin

getNumberOfColumns

public long getNumberOfColumns()
                        throws ExceptionHugin
Returns the number of columns in this DataSet.

Throws:
ExceptionHugin

getNumberOfRows

public long getNumberOfRows()
                     throws ExceptionHugin
Returns the number of rows in this DataSet.

Throws:
ExceptionHugin

getDataItem

public java.lang.String getDataItem(long row,
                                    long column)
                             throws ExceptionHugin
Returns the data item at the specified location of this DataSet.

Parameters:
row - the index of the row
column - the index of the column
Returns:
The data item at the specified location.
Throws:
ExceptionHugin

setDataItem

public void setDataItem(long row,
                        long column,
                        java.lang.String data)
                 throws ExceptionHugin
Sets (or deletes) the data item at the specified location of this DataSet.

Parameters:
row - the index of the row
column - the index of the column
data - the new data item (a null value causes the item to be deleted).
Throws:
ExceptionHugin

getColumnName

public java.lang.String getColumnName(long column)
                               throws ExceptionHugin
Returns the name of the specified column of this DataSet.

Parameters:
column - the index of the column
Throws:
ExceptionHugin

setColumnName

public void setColumnName(long column,
                          java.lang.String name)
                   throws ExceptionHugin
Sets the name of the specified column of this DataSet.

Parameters:
column - the index of the column
name - the new name of the column
Throws:
ExceptionHugin

isAlive

public boolean isAlive()
Is this DataSet object alive?


newColumn

public long newColumn(java.lang.String name)
               throws ExceptionHugin
Creates a new column in this DataSet.

Parameters:
name - the name of the new column
Returns:
the index of the new column
Throws:
ExceptionHugin

newRow

public long newRow()
            throws ExceptionHugin
Creates a new row in this DataSet.

Returns:
the index of the new row
Throws:
ExceptionHugin

moveColumn

public void moveColumn(long column,
                       long newColumn)
                throws ExceptionHugin
Moves the specified column to a new position. The columns between the old and the new column positions will be shifted one position to the left or to the right depending on the direction of the move.

Parameters:
column - the index of the column to be moved
newColumn - the index of the destination column
Throws:
ExceptionHugin

moveRow

public void moveRow(long row,
                    long newRow)
             throws ExceptionHugin
Moves the specified row to a new position. The rows between the old and the new row positions will be shifted one position up or down depending on the direction of the move.

Parameters:
row - the index of the row to be moved
newRow - the index of the destination row
Throws:
ExceptionHugin

deleteColumn

public void deleteColumn(long column)
                  throws ExceptionHugin
Deletes the specified column from this DataSet. Columns to the right of the deleted column will be shifted one position to the left.

Parameters:
column - the index of the column to be deleted
Throws:
ExceptionHugin

deleteRow

public void deleteRow(long row)
               throws ExceptionHugin
Deletes the specified row from this DataSet. Rows below the deleted row will be shifted one position up.

Parameters:
row - the index of the row to be deleted
Throws:
ExceptionHugin

saveAsCSV

public void saveAsCSV(java.lang.String fileName,
                      char delimiter)
               throws ExceptionHugin
Saves this DataSet in the format of a comma-separated-values (CSV) file. However, a different delimiter than a comma can be used.

Parameters:
fileName - the name of the file in which to store the data
delimiter - the delimiter character (must not be a double-quote character).
Throws:
ExceptionHugin

toCSVString

public java.lang.String toCSVString(char delimiter)
                             throws ExceptionHugin
Creates a CSV representation (as a string) of this DataSet.

Parameters:
delimiter - the delimiter character (must not be a double-quote character).
Returns:
A string containing the CSV representation.
Throws:
ExceptionHugin

getUserData

public java.lang.Object getUserData()
Returns the value stored within the user data slot of this DataSet. If the stored value is NULL, or if no value has been stored, NULL is returned.

Returns:
Object stored within the DataSet.

setUserData

public void setUserData(java.lang.Object data)
Sets the user data field of this DataSet. The Hugin API provides a slot within each DataSet for use exclusively by the user/application.

Parameters:
data - User-defined data associated with this DataSet.