1 package com.quadcap.sql; 2 3 40 41 import java.util.Vector ; 42 43 import java.sql.SQLException ; 44 45 import com.quadcap.sql.types.Value; 46 import com.quadcap.sql.types.ValueBoolean; 47 48 import com.quadcap.util.Debug; 49 50 58 public class HavingCursor extends FilterCursor { 59 Row row = null; 60 61 public HavingCursor(Session session, Cursor cursor) throws SQLException { 62 super(session, cursor); 63 } 64 65 public Row getRow() throws SQLException { 66 return row; 67 } 68 69 public void updateRow(Row row) throws SQLException { 70 this.row = row; 71 Row t = new Row(row.size()-1); 72 for (int i = 1; i <= row.size(); i++) { 73 t.set(i, row.item(i)); 74 } 75 cursor.updateRow(t); 76 } 77 78 public int getColumnCount() throws SQLException { 79 return cursor.getColumnCount() - 1; 80 } 81 82 public boolean next() throws SQLException { 83 final int size = cursor.getColumnCount(); 84 boolean have = false; 85 while (!have && cursor.next()) { 86 Row r = cursor.getRow(); 87 Value val = r.item(size); 88 if (val instanceof ValueBoolean && 89 ((ValueBoolean)val).isTrue()) { 90 if (this.row == null) { 91 this.row = new Row(size-1); 92 } 93 for (int i = 1; i < size; i++) row.set(i, r.item(i)); 94 have = true; 95 } 96 } 97 return have; 98 } 99 100 } 101 | Popular Tags |