1 package com.daffodilwoods.daffodildb.server.sql99.dql.tableexpression.groupbyclause; 2 3 import java.util.*; 4 import com.daffodilwoods.daffodildb.server.sql99.common.*; 5 import com.daffodilwoods.daffodildb.server.sql99.dql.common.*; 6 import com.daffodilwoods.daffodildb.server.sql99.dql.semanticchecker.*; 7 import com.daffodilwoods.daffodildb.server.sql99.token.*; 8 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 9 import com.daffodilwoods.database.resource.*; 10 import com.daffodilwoods.database.sqlinitiator.*; 11 12 23 public class groupbyclause implements com.daffodilwoods.daffodildb.utils.parser.StatementExecuter, TypeConstants, TableExpressionConstants { 24 25 28 public groupingspecification _groupingspecification0; 29 30 33 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439221; 34 35 38 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439222; 39 40 43 private _Order groupOrder; 44 45 52 public Object run(Object object) throws com.daffodilwoods.database.resource.DException { 53 Object obj = _groupingspecification0.run(object); 54 return obj instanceof Object [] ? obj : new Object []{obj}; 55 } 56 57 public ColumnDetails[] getColumnDetails() throws DException { 58 return _groupingspecification0.getColumnDetails(); 59 } 60 61 public void getColumnsIncluded(ArrayList aList) throws DException { 62 _groupingspecification0.getColumnsIncluded(aList); 63 } 64 65 public void getTablesIncluded(ArrayList aList) throws DException { 66 67 } 68 public ParameterInfo[] getParameterInfo() throws DException { 69 return null; 70 } 71 public _Reference[] getReferences(TableDetails[] tableDetails) throws DException { 72 return _groupingspecification0.getReferences(tableDetails); 73 } 74 75 76 77 85 public _Order getOrder(_QueryColumns queryCols) throws DException { 86 if (groupOrder == null) { 87 ColumnDetails[] cols = getColumnDetails(); 88 89 91 int length=cols.length; 92 ColumnDetails[] cloned = new ColumnDetails[cols.length]; 93 for (int i = 0; i < length; i++) { 94 if(cols[i].getUnderLyingReference()){ 95 cloned[i]=cols[i]; 96 continue; 97 } 98 try { 99 cloned[i]=(ColumnDetails)cols[i].clone(); 100 } 101 catch (CloneNotSupportedException ex) { 102 throw new DException("DSE0", new Object [] {"Clone Not Supported"}); 103 } 104 } 105 groupOrder = new SelectOrder(cloned); 106 addColumnsInHashMap(groupOrder.getColumnDetails(), queryCols.getQueryColsHashMap()); 107 } 108 return groupOrder; 109 } 110 111 117 private void addColumnsInHashMap(ColumnDetails[] columnDetails, HashMap mappingOfTableColumns) throws DException { 118 if (columnDetails == null) { 119 return; 120 } 121 for (int i = 0, length = columnDetails.length; i < length; i++) { 122 TableDetails td = columnDetails[i].getTableDetails(); 123 ColumnDetails[] existing = (ColumnDetails[]) mappingOfTableColumns.get(td); 124 ColumnDetails[] result = addInArray(existing, columnDetails[i]); 125 mappingOfTableColumns.put(td, result); 126 } 127 } 128 129 137 private ColumnDetails[] addInArray(ColumnDetails[] source, ColumnDetails toAdd) throws DException { 138 if (source == null) { 139 return new ColumnDetails[] {toAdd}; 140 } 141 int length = source.length; 142 ColumnDetails[] result = new ColumnDetails[length + 1]; 143 System.arraycopy(source, 0, result, 0, length); 144 result[length] = toAdd; 145 return result; 146 } 147 148 public String toString() { 149 StringBuffer sb = new StringBuffer (); 150 sb.append(" "); 151 sb.append(_SRESERVEDWORD12065439222); 152 sb.append(" "); 153 sb.append(_SRESERVEDWORD12065439221); 154 sb.append(" "); 155 sb.append(_groupingspecification0); 156 return sb.toString(); 157 } 158 159 public Object clone() throws CloneNotSupportedException { 160 groupbyclause tempClass = new groupbyclause(); 161 tempClass._groupingspecification0 = (groupingspecification) _groupingspecification0.clone(); 162 tempClass._SRESERVEDWORD12065439221 = (SRESERVEDWORD1206543922) _SRESERVEDWORD12065439221.clone(); 163 tempClass._SRESERVEDWORD12065439222 = (SRESERVEDWORD1206543922) _SRESERVEDWORD12065439222.clone(); 164 return tempClass; 165 } 166 167 168 } 169 | Popular Tags |