proper.util
Class Cells

java.lang.Object
  extended by proper.util.Cells

public class Cells
extends java.lang.Object

Represents a simple 2-dim. Matrix. Useful for Spreadsheet-related stuff.

Version:
$Revision: 1.2 $
Author:
FracPete

Constructor Summary
Cells(int rows, int columns)
          initializes the object without any column names and the given dimensions
Cells(int rows, int columns, java.util.Collection names)
          initializes the object with the given column names and dimensions
 
Method Summary
 java.lang.Object getCellAt(int rowIndex, int columnIndex)
          returns the object at the given position, if it is an invalid position it returns NULL
 java.lang.String getCellStringAt(int rowIndex, int columnIndex)
          returns always a string, in case getCellAt(int,int) would return NULL this method returns the string 'null'.
 int getColumnCount()
          returns the number of columns in the matrix
 java.lang.String getName(int columnIndex)
          returns the name of the column, NULL if index of bounds or no names existing
 java.util.Vector getNames()
          returns the names of the columns (could be an empty vector)
 int getRowCount()
          returns the number of rows in the matrix
 boolean hasNames()
          returns whether the Matrix has any column names
 boolean hasRowNumbers()
          whether we also return row numbers (the first column)
static void main(java.lang.String[] args)
          for testing only
 void setCellAt(int rowIndex, int columnIndex, java.lang.Object value)
          sets the cell
 void setColumnCount(int columns)
          sets the number of columns in the matrix
 void setNames(java.util.Collection names)
          sets the names of the columns
 void setRowCount(int rows)
          sets the number of rows
 void setRowNumbers(boolean rowNumbers)
          sets whether to returns also a column with row numbers
 java.lang.Object[][] toArray()
          returns the matrix in a 2-dim array, the first
 java.util.Vector toCSV()
          returns the matrix in a CSV format: text-qualifier=", separator=;
 java.lang.String toString()
          returns the matrix in a string representation, i.e.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Cells

public Cells(int rows,
             int columns)
initializes the object without any column names and the given dimensions


Cells

public Cells(int rows,
             int columns,
             java.util.Collection names)
initializes the object with the given column names and dimensions

Method Detail

setNames

public void setNames(java.util.Collection names)
sets the names of the columns


getNames

public java.util.Vector getNames()
returns the names of the columns (could be an empty vector)


getName

public java.lang.String getName(int columnIndex)
returns the name of the column, NULL if index of bounds or no names existing


hasNames

public boolean hasNames()
returns whether the Matrix has any column names


setRowNumbers

public void setRowNumbers(boolean rowNumbers)
sets whether to returns also a column with row numbers


hasRowNumbers

public boolean hasRowNumbers()
whether we also return row numbers (the first column)


setColumnCount

public void setColumnCount(int columns)
sets the number of columns in the matrix


getColumnCount

public int getColumnCount()
returns the number of columns in the matrix


setRowCount

public void setRowCount(int rows)
sets the number of rows


getRowCount

public int getRowCount()
returns the number of rows in the matrix


setCellAt

public void setCellAt(int rowIndex,
                      int columnIndex,
                      java.lang.Object value)
sets the cell


getCellAt

public java.lang.Object getCellAt(int rowIndex,
                                  int columnIndex)
returns the object at the given position, if it is an invalid position it returns NULL


getCellStringAt

public java.lang.String getCellStringAt(int rowIndex,
                                        int columnIndex)
returns always a string, in case getCellAt(int,int) would return NULL this method returns the string 'null'.


toArray

public java.lang.Object[][] toArray()
returns the matrix in a 2-dim array, the first


toCSV

public java.util.Vector toCSV()
returns the matrix in a CSV format: text-qualifier=", separator=;


toString

public java.lang.String toString()
returns the matrix in a string representation, i.e. a table with the names and cell contents

Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
for testing only