001package gudusoft.gsqlparser.nodes; 002 003/* 004 * Date: 11-5-18 005 */ 006 007import gudusoft.gsqlparser.ESqlClause; 008import gudusoft.gsqlparser.TCustomSqlStatement; 009import gudusoft.gsqlparser.TSourceToken; 010 011import java.util.Vector; 012 013public class TPTNodeList <E> extends TParseTreeNode { 014 015 public void TPTNodeList(){ 016 017 } 018 019 private Vector v = new Vector<E>() ; 020 021 public final int size() 022 { 023 return v.size(); 024 } 025 026 public E elementAt (int index) 027 { 028 return (E)v.elementAt(index); 029 } 030 031 public final void addElement(E ptn) 032 { 033 v.addElement(ptn); 034 } 035 036 public final void removeElementAt(int index) 037 { 038 v.removeElementAt(index); 039 } 040 041 public final void removeElement(E ptn) 042 { 043 v.removeElement(ptn); 044 } 045 046 final E remove(int index) 047 { 048 return((E) (v.remove(index))); 049 } 050 051 final int indexOf(E ptn) 052 { 053 return v.indexOf(ptn); 054 } 055 056 final void setElementAt(E ptn, int index) 057 { 058 v.setElementAt(ptn, index); 059 } 060 061 062 final void removeAllElements() 063 { 064 v.removeAllElements(); 065 } 066 067 public final void insertElementAt(E ptn, int index) 068 { 069 v.insertElementAt(ptn, index); 070 } 071 072 public void init(Object arg1) 073 { 074 if (arg1 != null){ 075 addParseTreeNode((E)arg1); 076 } 077 } 078 079 void addParseTreeNode(E arg1){ 080 addElement((E)arg1); 081 } 082 083 public void addNode(E arg1){ 084 addParseTreeNode((E)arg1); 085 } 086 087 public E getElement(int index){ 088 return elementAt(index); 089 } 090 091 public void appendList(TPTNodeList <E> pList){ 092 for(int i=0;i< pList.size();i++){ 093 addElement(pList.getElement(i)); 094 } 095 } 096 /** 097 * analyze this node 098 */ 099 public void doParse(TCustomSqlStatement psql, ESqlClause plocation){ 100 for(int i=0; i<size();i++){ 101 if (elementAt(i) != null){ 102 ((TParseTreeNode)elementAt(i)).doParse(psql,plocation); 103 } 104 } 105 } 106 107 108 public TSourceToken getStartToken() { 109 if (size() == 0){ 110 return null; 111 }else{ 112 return ((TParseTreeNode)elementAt(0)).getStartToken(); 113 } 114 } 115 116 public TSourceToken getEndToken() { 117 if (size() == 0){ 118 return null; 119 }else{ 120 return ((TParseTreeNode)elementAt(size()-1)).getEndToken(); 121 } 122 } 123 124 public void accept(TParseTreeVisitor v){ 125 v.preVisit(this); 126// for(int i=0; i<size();i++){ 127// if (elementAt(i) != null){ 128// ((TParseTreeNode)elementAt(i)).accept(v); 129// } 130// } 131 v.postVisit(this); 132 } 133 134 public void acceptChildren(TParseTreeVisitor v){ 135 v.preVisit(this); 136 for(int i=0; i<size();i++){ 137 if (elementAt(i) != null){ 138 ((TParseTreeNode)elementAt(i)).acceptChildren(v); 139 } 140 } 141 v.postVisit(this); 142 } 143}