1 2 12 package com.versant.core.jdo.query; 13 14 import com.versant.core.metadata.ClassMetaData; 15 16 20 public class ResultNode extends Node { 21 public static final int[] EMPTY_INT_ARRAY = new int[0]; 22 23 private boolean distinct; 24 private int containsVarNodes = 0; 25 private int size; 26 27 28 public ResultNode(Node child) { 29 childList = child; 30 } 31 32 public boolean isDistinct() { 33 return distinct; 34 } 35 36 public void setDistinct(boolean distinct) { 37 this.distinct = distinct; 38 } 39 40 public String toString() { 41 return super.toString() + " distinct = " + distinct; 42 } 43 44 48 public void resolve(QueryParser comp, ClassMetaData cmd, boolean ordering) { 49 for (Node n = childList; n != null; n = n.next) { 50 n.resolve(comp, cmd, ordering); 51 size++; 52 } 53 } 54 55 public int getResultSize() { 56 return size; 57 } 58 59 62 public Field visit(MemVisitor visitor, Object obj) { 63 return null; } 65 66 public boolean processForVarNodes() { 67 if (containsVarNodes == 0) { 68 if (containsVarNodeImp(this)) { 69 containsVarNodes = 1; 70 } else { 71 containsVarNodes = -1; 72 } 73 } 74 return (containsVarNodes == 1); 75 } 76 77 private boolean containsVarNodeImp(Node n) { 78 if (n == null) return false; 79 if (n instanceof VarNodeIF) { 80 ((VarNodeIF)n).setUsedInProjection(true); 81 return true; 82 } 83 if (n instanceof FieldNavNode) { 84 if (((FieldNavNode)n).var != null) { 85 ((FieldNavNode)n).var.setUsedInProjection(true); 86 return true; 87 } 88 } 89 90 if (n.childList != null) { 91 if (containsVarNodeImp(n.childList)) { 92 return true; 93 } 94 } 95 for (Node nn = n.next; nn != null; nn = nn.next) { 96 if (containsVarNodeImp(nn)) return true; 97 } 98 return false; 99 } 100 101 public Object accept(NodeVisitor visitor, Object [] results) { 102 return visitor.visitResultNode(this, results); 103 } 104 105 public Object arrive(NodeVisitor v, Object msg) { 106 return v.arriveResultNode(this, msg); 107 } 108 } 109 | Popular Tags |