1 65 66 67 package org.hsqldb; 68 69 import java.io.IOException ; 70 71 import org.hsqldb.rowio.RowInputInterface; 72 import org.hsqldb.rowio.RowOutputInterface; 73 74 79 93 abstract class Node { 94 95 static final int NO_POS = CachedRow.NO_POS; 96 int iBalance; Node nNext; 99 static final Node newNode(Row r, int id, Table t) { 100 101 switch (t.getIndexType()) { 102 103 case Index.MEMORY_INDEX : 104 return new MemoryNode(r); 105 106 case Index.POINTER_INDEX : 107 return new PointerNode((CachedRow) r, id); 108 109 case Index.DISK_INDEX : 110 default : 111 return new DiskNode((CachedRow) r, id); 112 } 113 } 114 115 static final Node newNode(Row r, RowInputInterface in, int id, 116 Table t) throws IOException , HsqlException { 117 118 switch (t.getIndexType()) { 119 120 case Index.MEMORY_INDEX : 121 return new MemoryNode(r); 122 123 case Index.POINTER_INDEX : 124 return new PointerNode((CachedRow) r, id); 125 126 case Index.DISK_INDEX : 127 default : 128 return new DiskNode((CachedRow) r, in, id); 129 } 130 } 131 132 138 abstract void delete(); 139 140 143 abstract int getKey(); 144 145 148 abstract Row getRow() throws HsqlException; 149 150 153 abstract boolean isLeft(Node node) throws HsqlException; 154 155 abstract boolean isRight(Node node) throws HsqlException; 156 157 abstract Node getLeft() throws HsqlException; 158 159 abstract void setLeft(Node n) throws HsqlException; 160 161 abstract Node getRight() throws HsqlException; 162 163 abstract void setRight(Node n) throws HsqlException; 164 165 abstract Node getParent() throws HsqlException; 166 167 abstract void setParent(Node n) throws HsqlException; 168 169 final int getBalance() throws HsqlException { 170 171 if (Trace.DOASSERT) { 172 Trace.doAssert(iBalance != -2); 173 } 174 175 return iBalance; 176 } 177 178 abstract void setBalance(int b) throws HsqlException; 179 180 abstract boolean isRoot(); 181 182 abstract boolean isFromLeft() throws HsqlException; 183 184 188 abstract Object [] getData() throws HsqlException; 189 190 abstract boolean equals(Node n); 191 192 201 Node getUpdatedNode() throws HsqlException { 202 return this; 203 } 204 205 208 abstract void write(RowOutputInterface out) throws IOException ; 209 210 boolean isDeleted() { 211 return iBalance == -2; 212 } 213 } 214 | Popular Tags |