1 21 22 package org.apache.derby.impl.sql.compile; 23 24 import org.apache.derby.iapi.services.sanity.SanityManager; 25 26 import org.apache.derby.iapi.sql.compile.Visitor; 27 import org.apache.derby.iapi.sql.compile.Visitable; 28 import org.apache.derby.iapi.error.StandardException; 29 30 import java.util.Enumeration ; 31 import java.util.Vector ; 32 33 40 41 abstract class QueryTreeNodeVector extends QueryTreeNode 42 { 43 private Vector v = new Vector (); 44 45 public final int size() 46 { 47 return v.size(); 48 } 49 50 QueryTreeNode elementAt(int index) 51 { 52 return (QueryTreeNode) v.elementAt(index); 53 } 54 55 final void addElement(QueryTreeNode qt) 56 { 57 v.addElement(qt); 58 } 59 60 final void removeElementAt(int index) 61 { 62 v.removeElementAt(index); 63 } 64 65 final void removeElement(QueryTreeNode qt) 66 { 67 v.removeElement(qt); 68 } 69 70 final Object remove(int index) 71 { 72 return((QueryTreeNode) (v.remove(index))); 73 } 74 75 final int indexOf(QueryTreeNode qt) 76 { 77 return v.indexOf(qt); 78 } 79 80 final void setElementAt(QueryTreeNode qt, int index) 81 { 82 v.setElementAt(qt, index); 83 } 84 85 void destructiveAppend(QueryTreeNodeVector qtnv) 86 { 87 nondestructiveAppend(qtnv); 88 qtnv.removeAllElements(); 89 } 90 91 void nondestructiveAppend(QueryTreeNodeVector qtnv) 92 { 93 int qtnvSize = qtnv.size(); 94 for (int index = 0; index < qtnvSize; index++) 95 { 96 v.addElement(qtnv.elementAt(index)); 97 } 98 } 99 100 final void removeAllElements() 101 { 102 v.removeAllElements(); 103 } 104 105 final void insertElementAt(QueryTreeNode qt, int index) 106 { 107 v.insertElementAt(qt, index); 108 } 109 110 119 public String toString() 120 { 121 if (SanityManager.DEBUG) 122 { 123 StringBuffer buffer = new StringBuffer (""); 124 125 for (int index = 0; index < size(); index++) 126 { 127 buffer.append(elementAt(index).toString()).append("; "); 128 } 129 130 return buffer.toString(); 131 } 132 else 133 { 134 return ""; 135 } 136 } 137 138 146 public Visitable accept(Visitor v) 147 throws StandardException 148 { 149 Visitable returnNode = v.visit(this); 150 151 if (v.skipChildren(this)) 152 { 153 return returnNode; 154 } 155 156 int size = size(); 157 for (int index = 0; index < size; index++) 158 { 159 setElementAt((QueryTreeNode)((QueryTreeNode) elementAt(index)).accept(v), index); 160 } 161 162 return returnNode; 163 } 164 } 165 | Popular Tags |