001package gudusoft.gsqlparser.nodes; 002 003import gudusoft.gsqlparser.EDbObjectType; 004 005/** 006 * List of TObjectName 007*/ 008public class TObjectNameList extends TParseTreeNodeList <TObjectName>{ 009 010 public void setObjectType(int objectType) { 011 this.objectType = objectType; 012 } 013 014 /** 015 * 016 * @return type of all objects in this list. if more than one types 017 * saved in this list, then object type is set to ttobjMixed. 018 */ 019 public int getObjectType() { 020 021 return objectType; 022 } 023 024 private int objectType = TObjectName.ttobjUnknown; 025 026 public TObjectNameList() 027 { 028 } 029 030 public void addObjectName(TObjectName objectReference){ 031 addObjectName(objectReference,false); 032 } 033 034 035 public void addObjectName(TObjectName objectReference, boolean checkExistence) 036 { 037 boolean b = false; 038 if ((checkExistence) && (indexOf(objectReference) >=0)) return; 039 040 if ((this.objectType != TObjectName.ttobjUnknown) 041 // && (this.objectType != TObjectName.ttobjMixed) 042 &&(objectReference.getObjectType() == TObjectName.ttobjUnknown) 043 &&(objectReference.getDbObjectType() == EDbObjectType.unknown) 044 ){ 045 objectReference.setObjectType(this.objectType); 046 } 047 048 addElement(objectReference); 049 } 050 051 public TObjectName getObjectName(int position) 052 { 053 if (position < size()) 054 { 055 return (TObjectName)elementAt(position); 056 }else{ 057 return null; 058 } 059 } 060 061 void addParseTreeNode(Object arg1){ 062 addObjectName((TObjectName)arg1); 063 } 064 065 public int searchColumnReference(TObjectName cr){ 066 int ret = -1; 067 for (int i=0;i<size();i++){ 068 if (getObjectName(i).toString().compareToIgnoreCase(cr.toString()) == 0){ 069 ret = i; 070 break; 071 } 072 } 073 return ret; 074 } 075 076 public void accept(TParseTreeVisitor v){ 077 v.preVisit(this); 078 v.postVisit(this); 079 } 080// 081// public void acceptChildren(TParseTreeVisitor v){ 082// v.preVisit(this); 083// for(int i=0;i<size();i++){ 084// this.getObjectName(i).acceptChildren(v); 085// } 086// v.postVisit(this); 087// } 088 089 /** 090 * Returns a string representation of all TObjectName elements in this list 091 * separated by commas. 092 * @return a comma-separated string of all elements 093 */ 094// @Override 095// public String toString() { 096// if (size() == 0) { 097// return ""; 098// } 099// 100// StringBuilder sb = new StringBuilder(); 101// for (int i = 0; i < size(); i++) { 102// if (i > 0) { 103// sb.append(", "); 104// } 105// sb.append(getObjectName(i).toString()); 106// } 107// return sb.toString(); 108// } 109}