1 65 66 67 package org.hsqldb; 68 69 import java.io.IOException ; 70 71 import org.hsqldb.rowio.RowOutputInterface; 72 73 84 abstract class BaseMemoryNode extends Node { 85 86 protected Node nLeft; 87 protected Node nRight; 88 protected Node nParent; 89 90 void delete() { 91 iBalance = -2; 92 nLeft = nRight = nParent = null; 93 } 94 95 Node getLeft() throws HsqlException { 96 97 if (Trace.DOASSERT) { 98 Trace.doAssert(iBalance != -2); 99 } 100 101 return nLeft; 102 } 103 104 void setLeft(Node n) throws HsqlException { 105 106 if (Trace.DOASSERT) { 107 Trace.doAssert(iBalance != -2); 108 } 109 110 nLeft = n; 111 } 112 113 boolean isLeft(Node node) throws HsqlException { 114 return nLeft == node; 115 } 116 117 boolean isRight(Node node) throws HsqlException { 118 return nRight == node; 119 } 120 121 Node getRight() throws HsqlException { 122 123 if (Trace.DOASSERT) { 124 Trace.doAssert(iBalance != -2); 125 } 126 127 return nRight; 128 } 129 130 void setRight(Node n) throws HsqlException { 131 132 if (Trace.DOASSERT) { 133 Trace.doAssert(iBalance != -2); 134 } 135 136 nRight = n; 137 } 138 139 Node getParent() throws HsqlException { 140 141 if (Trace.DOASSERT) { 142 Trace.doAssert(iBalance != -2); 143 } 144 145 return nParent; 146 } 147 148 boolean isRoot() { 149 return nParent == null; 150 } 151 152 void setParent(Node n) throws HsqlException { 153 154 if (Trace.DOASSERT) { 155 Trace.doAssert(iBalance != -2); 156 } 157 158 nParent = n; 159 } 160 161 void setBalance(int b) throws HsqlException { 162 163 if (Trace.DOASSERT) { 164 Trace.doAssert(iBalance != -2); 165 } 166 167 iBalance = b; 168 } 169 170 boolean isFromLeft() throws HsqlException { 171 172 if (this.isRoot()) { 173 return true; 174 } 175 176 Node parent = getParent(); 177 178 if (Trace.DOASSERT) { 179 Trace.doAssert(parent != null); 180 } 181 182 return equals(parent.getLeft()); 183 } 184 185 boolean equals(Node n) { 186 return n == this; 187 } 188 189 void write(RowOutputInterface out) throws IOException {} 190 } 191 | Popular Tags |