1 2 12 package com.versant.core.jdo.query; 13 14 import com.versant.core.metadata.ClassMetaData; 15 16 import com.versant.core.common.BindingSupportImpl; 17 18 22 public class BinaryNode extends Node { 23 24 public BinaryNode() { 25 } 26 27 public BinaryNode(Node left, Node right) { 28 childList = left; 29 if (left != null) { 30 left.next = right; 31 left.parent = this; 32 } 33 if (right != null) { 34 right.parent = this; 35 } 36 } 37 38 public final Node getLeft() { 39 return childList; 40 } 41 42 public final Node getRight() { 43 return childList.next; 44 } 45 46 50 public void resolve(QueryParser comp, ClassMetaData cmd, boolean ordering) { 51 childList.resolve(comp, cmd, false); 52 childList.next.resolve(comp, cmd, false); 53 } 54 55 58 public void replaceChild(Node old, Node nw) { 59 if (childList == old) { 60 nw.next = childList.next; 61 childList = nw; 62 } else if (childList.next == old) { 63 childList.next = nw; 64 nw.next = null; 65 } else { 66 throw BindingSupportImpl.getInstance().internal("no such Node: " + old); 67 } 68 nw.parent = this; 69 } 70 71 74 public void normalizeImp() { 75 childList.normalizeImp(); 76 childList.next.normalizeImp(); 77 78 if (childList instanceof LiteralNode 80 || childList instanceof ParamNode 81 || childList instanceof ParamNodeProxy) { 82 swapLeftAndRight(); 83 } 84 } 85 86 89 protected void swapLeftAndRight() { 90 Node t = childList; 91 childList = childList.next; 92 childList.next = t; 93 t.next = null; 94 } 95 96 public Field visit(MemVisitor visitor, Object obj) { 97 return visitor.visitBinaryNode(this, obj); 98 } 99 100 public Object arrive(NodeVisitor v, Object msg) { 101 return v.arriveBinaryNode(this, msg); 102 } 103 } 104 | Popular Tags |