1 package net.jaekl.cfb.db;
8 public Row(Column[] columns, Object[] values)
10 m_columns = columns.clone();
11 m_values = values.clone();
14 public int getNumColumns() { return m_columns.length; }
16 public String getString(int index) throws TypeMismatchException {
17 checkType(index, Column.Type.VARCHAR);
18 return (String)m_values[index];
21 public int getInt(int index) throws TypeMismatchException
23 checkType(index, Column.Type.INTEGER);
24 Number num = (Number)m_values[index];
25 return num.intValue();
28 public long getLong(int index) throws TypeMismatchException
30 checkType(index, Column.Type.INTEGER);
31 Number num = (Number)m_values[index];
32 return num.longValue();
35 public java.util.Date getDate(int index) throws TypeMismatchException
37 checkType(index, Column.Type.INTEGER);
38 long milliseconds = (Long)m_values[index];
39 java.util.Date date = new java.util.Date(milliseconds);
43 protected void checkType(int index, Column.Type type) throws TypeMismatchException {
44 Column column = m_columns[index];
45 if (column.getType().equals(type)) {
49 String msg = "Column " + column.getName()
50 + " is of type " + column.getType().name()
51 + " which cannot be coerced to type " + type.name() + ".";
52 throw new TypeMismatchException(msg);