org.dspace.storage.rdbms
Class TableRow

java.lang.Object
  extended by org.dspace.storage.rdbms.TableRow

public class TableRow
extends Object

Represents a database row.

Version:
$Revision: 4316 $
Author:
Peter Breton

Constructor Summary
TableRow(String table, List columns)
          Constructor
 
Method Summary
 boolean equals(Object obj)
          Return true if this object equals obj, false otherwise.
 boolean getBooleanColumn(String column)
          Return the boolean value of column.
 Date getDateColumn(String column)
          Return the date value of column.
 double getDoubleColumn(String column)
          Return the double value of column.
 int getIntColumn(String column)
          Return the integer value of column.
 long getLongColumn(String column)
          Return the long value of column.
 String getStringColumn(String column)
          Return the String value of column.
 String getTable()
          Return the name of the table containing this row, or null if this row is not associated with a database table.
 boolean hasColumn(String column)
          Return true if this row contains a column with this name.
 boolean hasColumnChanged(String column)
          Return true if this row contains this column and the value has been updated.
 int hashCode()
          Return a hash code for this object.
 boolean isColumnNull(String column)
          Return true if the column is an SQL NULL.
 void setColumn(String column, boolean b)
          Set column to the boolean b.
 void setColumn(String column, Date d)
          Set column to the date d.
 void setColumn(String column, double d)
          Set column to the double d.
 void setColumn(String column, int i)
          Set column to the integer i.
 void setColumn(String column, long l)
          Set column to the long l.
 void setColumn(String column, String s)
          Set column to the String s.
 void setColumnNull(String column)
          Set column to an SQL NULL.
 String toString()
          Return a String representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TableRow

public TableRow(String table,
                List columns)
Constructor

Parameters:
table - The name of the database table containing this row.
columns - A list of column names. Each member of the List is a String. After construction, the list of columns is fixed; attempting to access a column not in the list will cause an IllegalArgumentException to be thrown.
Method Detail

getTable

public String getTable()
Return the name of the table containing this row, or null if this row is not associated with a database table.

Returns:
The name of the table containing this row

hasColumn

public boolean hasColumn(String column)
Return true if this row contains a column with this name.

Parameters:
column - The column name (case-insensitive)
Returns:
True if this row contains a column with this name.

hasColumnChanged

public boolean hasColumnChanged(String column)
Return true if this row contains this column and the value has been updated.

Parameters:
column - The column name (case-insensitive)
Returns:
True if this row contains a column with this name.

isColumnNull

public boolean isColumnNull(String column)
Return true if the column is an SQL NULL.

Parameters:
column - The column name (case-insensitive)
Returns:
True if the column is an SQL NULL

getIntColumn

public int getIntColumn(String column)
Return the integer value of column. If the column's type is not an integer, or the column does not exist, an IllegalArgumentException is thrown.

Parameters:
column - The column name (case-insensitive)
Returns:
The integer value of the column, or -1 if the column is an SQL null.

getLongColumn

public long getLongColumn(String column)
Return the long value of column. If the column's type is not an long, or the column does not exist, an IllegalArgumentException is thrown.

Parameters:
column - The column name (case-insensitive)
Returns:
The long value of the column, or -1 if the column is an SQL null.

getDoubleColumn

public double getDoubleColumn(String column)
Return the double value of column. If the column's type is not an float, or the column does not exist, an IllegalArgumentException is thrown.

Parameters:
column - The column name (case-insensitive)
Returns:
The double value of the column, or -1 if the column is an SQL null.

getStringColumn

public String getStringColumn(String column)
Return the String value of column. If the column's type is not a String, or the column does not exist, an IllegalArgumentException is thrown.

Parameters:
column - The column name (case-insensitive)
Returns:
The String value of the column, or null if the column is an SQL null.

getBooleanColumn

public boolean getBooleanColumn(String column)
Return the boolean value of column. If the column's type is not a boolean, or the column does not exist, an IllegalArgumentException is thrown.

Parameters:
column - The column name (case-insensitive)
Returns:
The boolean value of the column, or false if the column is an SQL null.

getDateColumn

public Date getDateColumn(String column)
Return the date value of column. If the column's type is not a date, or the column does not exist, an IllegalArgumentException is thrown.

Parameters:
column - The column name (case-insensitive)
Returns:
- The date value of the column, or null if the column is an SQL null.

setColumnNull

public void setColumnNull(String column)
Set column to an SQL NULL. If the column does not exist, an IllegalArgumentException is thrown.

Parameters:
column - The column name (case-insensitive)

setColumn

public void setColumn(String column,
                      boolean b)
Set column to the boolean b. If the column does not exist, an IllegalArgumentException is thrown.

Parameters:
column - The column name (case-insensitive)
b - The boolean value

setColumn

public void setColumn(String column,
                      String s)
Set column to the String s. If s is null, the column is set to null. If the column does not exist, an IllegalArgumentException is thrown.

Parameters:
column - The column name (case-insensitive)
s - The String value

setColumn

public void setColumn(String column,
                      int i)
Set column to the integer i. If the column does not exist, an IllegalArgumentException is thrown.

Parameters:
column - The column name (case-insensitive)
i - The integer value

setColumn

public void setColumn(String column,
                      long l)
Set column to the long l. If the column does not exist, an IllegalArgumentException is thrown.

Parameters:
column - The column name (case-insensitive)
l - The long value

setColumn

public void setColumn(String column,
                      double d)
Set column to the double d. If the column does not exist, an IllegalArgumentException is thrown.

Parameters:
column - The column name (case-insensitive)
l - The double value

setColumn

public void setColumn(String column,
                      Date d)
Set column to the date d. If the date is null, the column is set to NULL as well. If the column does not exist, an IllegalArgumentException is thrown.

Parameters:
column - The column name (case-insensitive)
d - The date value

toString

public String toString()
Return a String representation of this object.

Overrides:
toString in class Object
Returns:
String representaton

hashCode

public int hashCode()
Return a hash code for this object.

Overrides:
hashCode in class Object
Returns:
int hash of object

equals

public boolean equals(Object obj)
Return true if this object equals obj, false otherwise.

Overrides:
equals in class Object
Parameters:
obj -
Returns:
true if TableRow objects are equal


Copyright © 2010 DuraSpace. All Rights Reserved.