1 5 package org.h2.test.synth; 6 7 import java.sql.*; 8 9 class Row implements Comparable { 10 private Value[] data; 11 12 public Row(TestSynth config, ResultSet rs, int len) throws SQLException { 13 data = new Value[len]; 14 for(int i = 0; i<len; i++) { 15 data[i] = Value.read(config, rs, i+1); 16 } 17 } 18 19 public String toString() { 20 String s = ""; 21 for(int i = 0; i<data.length; i++) { 22 Object o = data[i]; 23 s += o==null ? "NULL" : o.toString(); 24 s += "; "; 25 } 26 return s; 27 } 28 29 public int compareTo(Object o) { 30 Row r2 = (Row)o; 31 int result = 0; 32 for(int i=0; i<data.length && result==0; i++) { 33 Object o1 = data[i]; 34 Object o2 = r2.data[i]; 35 if(o1==null) { 36 result = (o2==null) ? 0 : -1; 37 } else if(o2==null) { 38 result = 1; 39 } else { 40 result = o1.toString().compareTo(o2.toString()); 41 } 42 } 43 return result; 44 } 45 46 } 47 | Popular Tags |