Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## things.data.tables
Class Table<C>

    java.lang.Object
      things.data.tables.Table<C>

All Implemented Interfaces:
  java.lang.Iterable<java.util.ArrayList<C>>

    public class Table<C>

extends java.lang.Object
implements java.lang.Iterable<java.util.ArrayList<C>>

A table of Cell types.
NOT THREAD SAFE!!!

Version:
  1.0

  Version History

       EPG - Rewrite from another project - 18 APR 04
       EPG - Converted to use generics - 13 MAY 06

Author:
  Erich P. Gatejen

Constructor Summary
`Table()` Default constructor.

Method Summary
`void` | `append(C... items)` Append a row.
`C` | `getCell(int row, int column)` Get a cell at the specified index.
`java.util.ArrayList<java.lang.String>` | `getHeaders()` Get the headers.
`java.lang.String[]` | `getHeadersArray()` Get the headers as an array.
`int` | `getNumberColumns()` Get the number of columns.
`int` | `getNumberRows()` Get the number of rows.
`java.util.ArrayList<C>` | `getRow(int index)` Get a row at the specified index.
`C[]` | `getRowArray(int index)` Get a row at the specified index as an array.
`java.util.Iterator<java.util.ArrayList<C>>` | `iterator()` Get an iterator for the rows.
`void` | `putCell(int row, int column, C item)` Put a cell at the specified index.
`void` | `setHeaders(java.lang.String... items)` Set headers.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Table

    public Table()

  Default constructor.

Method Detail

### getNumberRows

    public int getNumberRows()

  Get the number of rows.

  Returns:
    the number of rows.

### getNumberColumns

    public int getNumberColumns()

  Get the number of columns.

  Returns:
    the number of columns.

### append

    public void append(C... items)

  Append a row.

  Parameters:
    `items` - Items in the row.

### setHeaders

    public void setHeaders(java.lang.String... items)

  Set headers.

  Parameters:
    `items` - Names for each header.

### getRowArray

    public C[] getRowArray(int index)
                    throws ThingsException

  Get a row at the specified index as an array. The count starts from 0. It will throw a ThingsException if it is out of bounds.

  Parameters:
    `index` - The index of the row.
  Returns:
    The row as an array.
  Throws:
    `ThingsException`

### iterator

    public java.util.Iterator<java.util.ArrayList<C>> iterator()

  Get an iterator for the rows.

  Specified by:
    `iterator` in interface `java.lang.Iterable<java.util.ArrayList<C>>`
  Returns:
    The an iterator for the rows.

### getRow

    public java.util.ArrayList<C> getRow(int index)
                                  throws ThingsException

  Get a row at the specified index. The count starts from 0. It will throw a ThingsException if it is out of bounds.

  Parameters:
    `index` - The index of the row.
  Returns:
    The row as an ArrayList.
  Throws:
    `ThingsException`

### getHeaders

    public java.util.ArrayList<java.lang.String> getHeaders()
                                                     throws ThingsException

  Get the headers.

  Returns:
    the headers as an ArrayList.
  Throws:
    `ThingsException`

### getHeadersArray

    public java.lang.String[] getHeadersArray()
                                       throws ThingsException

  Get the headers as an array.

  Returns:
    the headers as an Array.
  Throws:
    `ThingsException`

### getCell

    public C getCell(int row,
                     int column)
              throws ThingsException

  Get a cell at the specified index. The count starts from 0. Empty cells will be returned as a null. It will throw a ThingsException if it is out of bounds.

  Parameters:
    `row` - The row index starting from 0.
    `column` - The column index starting from 0.
  Returns:
    the object at the cell or a null if it is empty.
  Throws:
    `ThingsException`

### putCell

    public void putCell(int row,
                        int column,
                        C item)
                 throws ThingsException

  Put a cell at the specified index. The count starts from 0. It will expand the rows and columns as neccesary to put the cell. If the cell is already there, it will replace it. Techincally, only an OutOfMemory or a negative index will cause an exception in this method.

  Parameters:
    `row` - The row index starting from 0.
    `column` - The column index starting from 0.
    `item` - The item to put in the cell.
  Throws:
    `ThingsException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Things.