1 package com.daffodilwoods.daffodildb.server.sql99.dql.queryexpression. 2 orderbyclause; 3 4 import java.util.*; 5 import com.daffodilwoods.daffodildb.server.sql99.common.*; 6 import com.daffodilwoods.daffodildb.server.sql99.expression.expressionprimary.*; 7 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 8 import com.daffodilwoods.daffodildb.utils.field.*; 9 import com.daffodilwoods.database.resource.*; 10 import com.daffodilwoods.database.utility.P; 11 12 21 public class sortkey 22 implements com.daffodilwoods.daffodildb.utils.parser.StatementExecuter, 23 TypeConstants, Datatypes, _sortspecificationAndselectSubList { 24 27 public valueexpressionwithoutboolean _sortkey0; 28 29 34 protected ColumnDetails[] columnDetails; 35 36 40 private ColumnDetails[] keyColumnDetails; 41 42 public void setDefaultValues(_VariableValueOperations variableValueOperation) throws 43 DException { 44 } 45 46 52 public _Reference[] getReferences(TableDetails[] tableDetails) throws 53 DException { 54 return _sortkey0.getReferences(tableDetails); 55 } 56 57 public com.daffodilwoods.daffodildb.server.sql99.utils._Reference[] 58 checkSemantic(com.daffodilwoods.daffodildb.server.serversystem. 59 _ServerSession parent) throws DException { 60 61 62 _Reference[] ref = _sortkey0.checkSemantic(parent); 63 if (_sortkey0.getCardinality() > 1) 64 throw new DException("DSE0",new Object [] {"Multi Column Predicate is not Supported in Order by List."}); 65 return ref; 66 } 67 68 public Object run(Object object) throws com.daffodilwoods.database.resource. 69 DException { 70 return _sortkey0.run(object); 71 } 72 73 80 81 public ColumnDetails[] getKeyColumnDetails() throws DException { 82 if (keyColumnDetails == null) { 83 keyColumnDetails = modifyKeyColumnDetails(getColumnDetails()); 84 } 85 return keyColumnDetails; 86 } 87 88 95 96 private ColumnDetails[] modifyKeyColumnDetails(ColumnDetails[] columnDetails) throws 97 DException { 98 int length = columnDetails.length; 99 100 if (length == 1 && !columnDetails[0].checkNegativeValueFlag()) { 101 return columnDetails; 102 } 103 if (length == 0) { 104 throw new DException("DSE6009", null); 105 } 106 107 ColumnDetails columnDetail = new ColumnDetails(); 108 columnDetail.setColumn(new String [] {toString()}); 109 columnDetail.setType(FUNCTIONAL); 110 columnDetail.setObject(this); 111 return new ColumnDetails[] { 112 columnDetail}; 113 } 114 115 121 122 public ColumnDetails[] getColumnDetails() throws DException { 123 if (columnDetails == null) { 124 columnDetails = _sortkey0.getColumnDetails(); 125 126 if (columnDetails.length == 1 && columnDetails[0].getType() == CONSTANT && 127 ! (columnDetails[0].getTypeForSequence() == SEQUENCETYPE)) { 128 if (columnDetails[0].getQuestion() || 129 columnDetails[0].getDatatype() == CHARACTER) { 130 columnDetails[0].setObject(this); 131 } 132 else { 133 FieldBase fBase = (FieldBase) _sortkey0.run(null); 134 columnDetails[0].setObject(fBase); } 136 } 137 } 138 return columnDetails; 139 } 140 141 146 public void getColumnsIncluded(ArrayList aList) throws DException { 147 _sortkey0.getColumnsIncluded(aList); 148 } 149 150 public void getTablesIncluded(ArrayList aList) throws DException { 151 } 152 153 public String toString() { 154 StringBuffer sb = new StringBuffer (); 155 sb.append(" "); 156 sb.append(_sortkey0); 157 return sb.toString(); 158 } 159 160 public Object clone() throws CloneNotSupportedException { 161 sortkey tempClass = new sortkey(); 162 tempClass._sortkey0 = (valueexpressionwithoutboolean) _sortkey0.clone(); 163 return tempClass; 164 } 165 166 170 171 public ByteComparison getByteComparison(Object object) throws DException { 172 return _sortkey0.getByteComparison(object); 173 } 174 175 public ColumnDetails[] getChildColumnDetails() throws DException { 176 return getColumnDetails(); 177 } 178 179 180 public ParameterInfo[] getParameterInfo() throws DException { 181 return _sortkey0.getParameterInfo(); 182 } 183 184 public Object [] getParameters(Object object) throws DException { 185 return _sortkey0.getParameters(object); 186 } 187 } 188 | Popular Tags |