net.sf.imageCave.database
Class DataTable

java.lang.Object
  |
  +--net.sf.imageCave.database.DataTable

public class DataTable
extends java.lang.Object

An object that represents a table in the Database. Each instance can have several DataRows.

Since:
13 March, 2004
Version:
%I%, %G%
Author:
Stuart T. Tett, disc0stu@sf.net
See Also:
Database, DataRow, DataTableBuilder

Field Summary
 java.util.Collection dataRows
          Holds all the DataRow instances that belong to this DataTable.
 java.lang.String[] fieldNames
          Array of the names of the fields
 
Constructor Summary
DataTable(java.lang.String name)
          Constructor
 
Method Summary
 void addField(java.lang.String f)
          Add a new field to the list of fields in this DataTable.
 boolean contains(DataRow dr)
           
 boolean delete(DataRow rowToDelete)
          Delete row in this DataTable using rowToDelete to filter which row should be affected.
 boolean delete(DataTable rowsToDelete)
          Delete rows in this DataTable using rowsToDelete to filter which rows should be affected.
 int fieldIndex(java.lang.String fieldName)
           
 java.lang.String[] getFields()
           
 java.lang.String getName()
           
 boolean insert(DataRow row)
          Insert a new DataRow into this DataTable.
 boolean isEmpty()
           
 java.util.Iterator iterator()
           
 DataTable select(java.lang.String filter)
          To select rows, either just to grab information, or to select rows to update, or delete, a filter is used for which rows to select.
 void setFieldNames(java.lang.String[] f)
           
 int size()
           
 boolean update(DataTable rowsToUpdate, java.lang.String[] fieldsToUpdate, java.lang.String[] newValues)
          Update rows in this DataTable using rowsToUpdate to filter which rows should be affected.
 int width()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataRows

public java.util.Collection dataRows
Holds all the DataRow instances that belong to this DataTable.


fieldNames

public java.lang.String[] fieldNames
Array of the names of the fields

Constructor Detail

DataTable

public DataTable(java.lang.String name)
Constructor

Method Detail

setFieldNames

public void setFieldNames(java.lang.String[] f)

select

public DataTable select(java.lang.String filter)

To select rows, either just to grab information, or to select rows to update, or delete, a filter is used for which rows to select.

Each string in the array should be of the format: "field=value" the "=" can be replaced with any of these "<",">","!=","<=",">="

Parameters:
filter - a string of boolean logical statements of fields and their values.
Returns:
a tempory table that holds only the selected rows which meet the filter..

fieldIndex

public int fieldIndex(java.lang.String fieldName)

update

public boolean update(DataTable rowsToUpdate,
                      java.lang.String[] fieldsToUpdate,
                      java.lang.String[] newValues)

Update rows in this DataTable using rowsToUpdate to filter which rows should be affected. String arrays of field names and their new values should line up, repectively.

Parameters:
rowsToUpdate -
fieldsToUpdate -
newValues -
Returns:
true if successful, false otherwise

delete

public boolean delete(DataTable rowsToDelete)

Delete rows in this DataTable using rowsToDelete to filter which rows should be affected.

Parameters:
rowsToDelete -
Returns:
true if successful, false otherwis

delete

public boolean delete(DataRow rowToDelete)

Delete row in this DataTable using rowToDelete to filter which row should be affected.

Parameters:
rowToDelete -
Returns:
true if successful, false otherwis

insert

public boolean insert(DataRow row)

Insert a new DataRow into this DataTable.

Parameters:
row -
Returns:
true if successful, false otherwis

addField

public void addField(java.lang.String f)

Add a new field to the list of fields in this DataTable.

Parameters:
f - the name of the new field to add.

contains

public boolean contains(DataRow dr)

size

public int size()

width

public int width()

isEmpty

public boolean isEmpty()

iterator

public java.util.Iterator iterator()

getName

public java.lang.String getName()

getFields

public java.lang.String[] getFields()


Copyright 2004 Brian Lund, Justin Rasmussen, & Stuart Tett. All Rights Reserved.