mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
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:
@@ -150,6 +150,36 @@ public class TableRow
|
|||||||
return ((Integer) value).intValue();
|
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.
|
* Return the String value of column.
|
||||||
*
|
*
|
||||||
@@ -304,6 +334,22 @@ public class TableRow
|
|||||||
data.put(canonicalize(column), new Integer(i));
|
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 COLUMN to the date d. If the date is null, the column is
|
||||||
* set to NULL as well.
|
* set to NULL as well.
|
||||||
|
Reference in New Issue
Block a user