Support long datatype (getLongColumn, setColumn)

git-svn-id: http://scm.dspace.org/svn/repo/trunk@56 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Peter Breton
2002-05-30 15:53:38 +00:00
parent 54ddd5583e
commit 21a56e8b3c

View File

@@ -150,6 +150,36 @@ public class TableRow
return ((Integer) value).intValue();
}
/**
* 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.
*
* @param - The name of the column.
* @return - the long value of the column, or -1 if the column
* is an SQL null.
*/
public long getLongColumn(String column)
{
if (! hasColumn(column))
throw new IllegalArgumentException("No such column " + column);
String name = canonicalize(column);
if (isColumnNull(name))
return -1;
Object value = data.get(name);
if (value == null)
throw new IllegalArgumentException("Column " + column + " not present");
if (!(value instanceof Long))
throw new IllegalArgumentException("Value is not an long");
return ((Long) value).longValue();
}
/**
* Return the String value of column.
*
@@ -304,6 +334,22 @@ public class TableRow
data.put(canonicalize(column), new Integer(i));
}
/**
* Set COLUMN to the long l.
*
* If the column does not exist, an IllegalArgumentException is thrown.
*
* @param column - The name of the column.
* @param l - The long value
*/
public void setColumn(String column, long l)
{
if (! hasColumn(column))
throw new IllegalArgumentException("No such column " + column);
data.put(canonicalize(column), new Long(l));
}
/**
* Set COLUMN to the date d. If the date is null, the column is
* set to NULL as well.