1 2 12 package com.versant.core.jdo.query; 13 14 import com.versant.core.metadata.ClassMetaData; 15 import com.versant.core.metadata.FieldMetaData; 16 import com.versant.core.common.Debug; 17 import com.versant.core.common.CmdBitSet; 18 19 22 public class VarNode extends LeafNode implements VarNodeIF { 23 24 private String type; 25 private String identifier; 26 private Class cls; 27 private ClassMetaData cmd; 28 private Object storeExtent; 29 private FieldMetaData fmd; 30 private Object fieldExtent; 31 public boolean bound; 32 33 36 private boolean usedInProjection; 37 38 public VarNode() { 39 } 40 41 public Object accept(NodeVisitor visitor, Object [] results) { 42 return visitor.visitVarNode(this, results); 43 } 44 45 public String toString() { 46 StringBuffer s = new StringBuffer (); 47 s.append(super.toString()); 48 s.append(' '); 49 if (cls != null) s.append(cls); 50 else s.append(type); 51 s.append(' '); 52 s.append(identifier); 53 s.append(' '); 54 s.append(bound ? "bound" : "unbound"); 55 return s.toString(); 56 } 57 58 public Field visit(MemVisitor visitor, Object obj) { 59 return visitor.visitVarNode(this, obj); 60 } 61 62 public String getType() { 63 return type; 64 } 65 66 public void setType(String type) { 67 this.type = type; 68 } 69 70 public String getIdentifier() { 71 return identifier; 72 } 73 74 public void setIdentifier(String identifier) { 75 this.identifier = identifier; 76 } 77 78 public Class getCls() { 79 return cls; 80 } 81 82 public void setCls(Class cls) { 83 this.cls = cls; 84 } 85 86 public ClassMetaData getCmd() { 87 return cmd; 88 } 89 90 public void setCmd(ClassMetaData cmd) { 91 this.cmd = cmd; 92 } 93 94 public void resolve(QueryParser comp) { 95 cls = comp.resolveVarType(type); 96 cmd = comp.getCMD(cls); 97 } 98 99 public Object getStoreExtent() { 100 return storeExtent; 101 } 102 103 public void setStoreExtent(Object storeExtent) { 104 this.storeExtent = storeExtent; 105 } 106 107 public void setFieldExtent(Object fieldExtent) { 108 this.fieldExtent = fieldExtent; 109 } 110 111 public void setFmd(FieldMetaData fmd) { 112 this.fmd = fmd; 113 } 114 115 121 public void insertVarBindingNode(Node sibling) { 122 if (sibling.parent.getClass() == AndNode.class) { 125 AndNode and = (AndNode)sibling.parent; 126 and.insertChildBefore(sibling, new VarBindingNode(this)); 127 } else { 128 AndNode and = new AndNode(); 129 sibling.parent.replaceChild(sibling, and); 130 and.childList = new VarBindingNode(this); 131 and.childList.parent = and; 132 and.childList.next = sibling; 133 sibling.parent = and; 134 } 135 bound = true; 136 if (Debug.DEBUG) { 137 System.out.println("### Added VarBindingNode for " + this); 138 } 139 } 140 141 147 public void updateEvictionDependency(CmdBitSet bitSet) { 148 if (cmd == null) return; 149 bitSet.addPlus(cmd); 150 } 151 152 public void setUsedInProjection(boolean usedInProjection) { 153 this.usedInProjection = usedInProjection; 154 } 155 156 public boolean isUsedInProjection() { 157 return usedInProjection; 158 } 159 160 public VarNode getVarNode() { 161 return this; 162 } 163 164 public Object getFieldExtent() { 165 return fieldExtent; 166 } 167 168 public FieldMetaData getFmd() { 169 return fmd; 170 } 171 172 public Object arrive(NodeVisitor v, Object msg) { 173 return v.arriveVarNode(this, msg); 174 } 175 } 176 | Popular Tags |