1 34 package smallsql.database; 35 36 41 final class NoFromResult extends RowSource { 42 43 private int rowPos; 45 46 final boolean isScrollable(){ 47 return true; 48 } 49 50 51 final void beforeFirst(){ 52 rowPos = 0; 53 } 54 55 final boolean isBeforeFirst(){ 56 return rowPos <= 0; 57 } 58 59 final boolean isFirst(){ 60 return rowPos == 1; 61 } 62 63 final boolean first(){ 64 rowPos = 1; 65 return true; 66 } 67 68 final boolean previous(){ 69 rowPos--; 70 return rowPos == 1; 71 } 72 73 74 final boolean next(){ 75 rowPos++; 76 return rowPos == 1; 77 } 78 79 final boolean last(){ 80 rowPos = 1; 81 return true; 82 } 83 84 final boolean isLast(){ 85 return rowPos == 1; 86 } 87 88 final boolean isAfterLast(){ 89 return rowPos > 1; 90 } 91 92 final void afterLast(){ 93 rowPos = 2; 94 } 95 96 final boolean absolute(int row){ 97 rowPos = (row > 0) ? 98 Math.min( row, 1 ) : 99 Math.min( row +1, -1 ); 100 return rowPos == 1; 101 } 102 103 final boolean relative(int rows){ 104 if(rows == 0) return rowPos == 1; 105 rowPos = Math.min( Math.max( rowPos + rows, -1), 1); 106 return rowPos == 1; 107 } 108 109 final int getRow(){ 110 return rowPos == 1 ? 1 : 0; 111 } 112 113 final long getRowPosition() { 114 return rowPos; 115 } 116 117 118 final void setRowPosition(long rowPosition){ 119 rowPos = (int)rowPosition; 120 } 121 122 123 final boolean rowInserted(){ 124 return false; 125 } 126 127 128 final boolean rowDeleted(){ 129 return false; 130 } 131 132 133 final void nullRow() { 134 throw new Error (); 135 } 136 137 138 final void noRow() { 139 throw new Error (); 140 } 141 142 143 final void execute() throws Exception {} 144 } 145 | Popular Tags |