1 package com.daffodilwoods.daffodildb.server.sql99.dql.queryexpression. 2 queryspecification; 3 4 import java.util.*; 5 import com.daffodilwoods.daffodildb.server.serversystem.*; 6 import com.daffodilwoods.daffodildb.server.sql99.common.*; import com.daffodilwoods.daffodildb.server.sql99.utils.*; 8 import com.daffodilwoods.database.resource.*; 9 import com.daffodilwoods.database.utility.P; 10 11 21 public class selectlist 22 implements com.daffodilwoods.daffodildb.utils.parser.StatementExecuter, 23 TypeConstants { 24 27 public selectsublist[] _OptRepScomma94843605selectsublist0; 28 31 private ColumnDetails[] columnDetails; 32 38 public _Reference[] getReferences(TableDetails[] tableDetails) throws 39 DException { 40 if (_OptRepScomma94843605selectsublist0 == null) { 41 return null; 42 } 43 int length = _OptRepScomma94843605selectsublist0.length; 44 _Reference[] ref = null; 45 for (int i = 0; i < length; i++) { 46 ref = GeneralPurposeStaticClass.getJointReferences(ref, 47 _OptRepScomma94843605selectsublist0[i].getReferences(tableDetails)); 48 } 49 return ref; 50 } 51 52 public Object [] getParameters(Object object) throws DException { 53 ArrayList result = new ArrayList(); 54 if (_OptRepScomma94843605selectsublist0 == null) { 55 return null; 56 } 57 for (int i = 0; i < _OptRepScomma94843605selectsublist0.length; i++) { 58 Object [] param = _OptRepScomma94843605selectsublist0[i].getParameters(object); 59 if (param != null) { 60 result.addAll(Arrays.asList(param)); 61 } 62 } 63 return result.size() == 0 ? null : result.toArray(new Object [0]); 64 } 65 66 67 public ColumnDetails[] getColumnDetails() throws DException { 68 if (columnDetails == null) { 69 ArrayList aList = new ArrayList(5); 70 for (int i = 0; i < _OptRepScomma94843605selectsublist0.length; i++) { 71 aList.addAll(Arrays.asList(_OptRepScomma94843605selectsublist0[i]. 72 getColumnDetails())); 73 } 74 columnDetails = (ColumnDetails[]) aList.toArray(new ColumnDetails[0]); 75 for (int i = 0; i < columnDetails.length; i++) { 76 columnDetails[i].setAsSelectListColumn(); 77 } 78 } 79 return columnDetails; 80 } 81 82 public ParameterInfo[] getParameterInfo() throws DException { 83 if (_OptRepScomma94843605selectsublist0 == null) { 84 return null; 85 } 86 87 int length = _OptRepScomma94843605selectsublist0.length; 88 ParameterInfo[] p1 = null; 89 ArrayList a1 = new ArrayList(); 90 for (int i = 0; i < length; i++) { 91 p1 = _OptRepScomma94843605selectsublist0[i].getParameterInfo(); 92 93 if(p1 != null){ 94 for (int j = 0; j < p1.length; j++) { 95 if (p1[j].getQuestionMark()) { 96 if (p1[j].getDataType() == -1) 97 p1[j].setDataType(Datatypes.VARCHAR); 98 } 99 a1.add(p1[j]); 100 } 101 102 } 103 } 104 105 return (ParameterInfo[]) a1.toArray(new ParameterInfo[0]); 106 107 } 108 109 public _Reference[] checkSemantic(_ServerSession parent) throws DException { 110 _Reference[] refArray = null; 111 for (int i = 0; i < _OptRepScomma94843605selectsublist0.length; i++) { 112 refArray = GeneralPurposeStaticClass.getJointReferences(refArray, 113 _OptRepScomma94843605selectsublist0[i].checkSemantic(parent)); 114 } 115 116 117 if (refArray != null) { 118 ArrayList arr = new ArrayList(); 119 for (int i = 0; i < refArray.length; i++) { 120 if (refArray[i].getReferenceType() != SimpleConstants.SEQUENCE) { 121 arr.add(refArray[i]); 122 } 123 } 124 return (_Reference[]) arr.toArray(new _Reference[0]); 125 } 126 return null; 127 128 } 129 130 public void getColumnsIncluded(ArrayList aList) throws DException { 131 for (int i = 0; i < _OptRepScomma94843605selectsublist0.length; i++) { 132 _OptRepScomma94843605selectsublist0[i].getColumnsIncluded(aList); 133 } 134 } 135 136 public Object run(Object object) throws com.daffodilwoods.database.resource. 137 DException { 138 ArrayList aList = new ArrayList(); 139 for (int i = 0; i < _OptRepScomma94843605selectsublist0.length; i++) { 140 Object result = _OptRepScomma94843605selectsublist0[i].run(object); 141 if (result != null) { 142 if (result instanceof Object []) { 143 aList.addAll(Arrays.asList( (Object []) result)); 144 } 145 else { 146 aList.add(result); 147 } 148 } 149 } 150 return (Object []) aList.toArray(new Object [0]); 151 } 152 153 160 161 public ColumnDetails[] getDerivedColumnDetails() throws DException { 162 int length = _OptRepScomma94843605selectsublist0.length; 163 ArrayList list = new ArrayList(); 164 for (int i = 0; i < length; i++) { 165 ColumnDetails[] cd = null; 166 try { 167 cd = _OptRepScomma94843605selectsublist0[i].getDerivedColumnDetails(); 168 } 169 catch (DException ex) { 170 if (ex.getDseCode().equalsIgnoreCase("DSE3574")) { 171 continue; 172 } 173 else { 174 throw ex; 175 } 176 } 177 for (int j = 0; j < cd.length; j++) { 178 if (cd[j].getQuestion()) { 179 cd[j].setDatatype(Datatypes.VARCHAR); 180 cd[j].setSize(256); } 182 cd[j].setAsSelectListColumn(); 183 list.add(cd[j]); 184 } 185 } 186 return (ColumnDetails[]) list.toArray(new ColumnDetails[list.size()]); 187 } 188 189 public String toString() { 190 StringBuffer sb = new StringBuffer (); 191 sb.append(" "); 192 sb.append(_OptRepScomma94843605selectsublist0[0]); 193 for (int i = 1; i < _OptRepScomma94843605selectsublist0.length; i++) { 194 sb.append(",").append(_OptRepScomma94843605selectsublist0[i]); 195 } 196 return sb.toString(); 197 } 198 199 public Object clone() throws CloneNotSupportedException { 200 selectlist tempClass = new selectlist(); 201 if (_OptRepScomma94843605selectsublist0 != null) { 202 selectsublist[] temp_OptRepScomma94843605selectsublist0 = new 203 selectsublist[_OptRepScomma94843605selectsublist0.length]; 204 for (int i = 0; i < _OptRepScomma94843605selectsublist0.length; i++) { 205 temp_OptRepScomma94843605selectsublist0[i] = (selectsublist) 206 _OptRepScomma94843605selectsublist0[i].clone(); 207 } 208 tempClass._OptRepScomma94843605selectsublist0 = 209 temp_OptRepScomma94843605selectsublist0; 210 } 211 return tempClass; 212 } 213 214 } 215 | Popular Tags |