(Finally) reach the point where we have some useful, if basic, functionality.
[cfb.git] / prod / net / jaekl / cfb / db / Row.java
index fa3de9948ebb721a18da45230caaadd0131fc02b..35bf1215c28da38aac5b237b815e5e6c8d5136c0 100644 (file)
@@ -26,24 +26,37 @@ public class Row {
                return num.intValue();
        }
        
-       public long getLong(int index) throws TypeMismatchException
+       public Long getLong(int index) throws TypeMismatchException
        {
                checkType(index, Column.Type.INTEGER);
+               if (null == m_values[index]) {
+                       return null;
+               }
+               
                Number num = (Number)m_values[index];
                return num.longValue();
        }
        
        public java.util.Date getDate(int index) throws TypeMismatchException
        {
-               checkType(index, Column.Type.INTEGER);
-               long milliseconds = (Long)m_values[index];
-               java.util.Date date = new java.util.Date(milliseconds);
-               return date;
+               checkType(index, Column.Type.TIMESTAMPTZ);
+               return (java.util.Date)m_values[index];
        }
        
        protected void checkType(int index, Column.Type type) throws TypeMismatchException {
                Column column = m_columns[index];
-               if (column.getType().equals(type)) {
+               Column.Type columnType = column.getType();
+               
+               if (columnType.equals(Column.Type.TIMESTAMPTZ)) {
+                       // Special case:  TIMESTAMPTZ is stored as an INTEGER
+                       if (   Column.Type.TIMESTAMPTZ.equals(type)
+                               || Column.Type.INTEGER.equals(type)     )
+                       {
+                               return;
+                       }
+               }
+               
+               if (columnType.equals(type)) {
                        return;
                }