1 package com.daffodilwoods.daffodildb.server.sql99.expression.stringvalueexpression; 2 3 import com.daffodilwoods.daffodildb.server.serversystem.*; 4 import com.daffodilwoods.daffodildb.server.sql99.common.*; 5 import com.daffodilwoods.daffodildb.server.sql99.expression.rowvalueexpression.*; 6 import com.daffodilwoods.daffodildb.server.sql99.token.*; 7 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 8 import com.daffodilwoods.daffodildb.utils.*; 9 import com.daffodilwoods.daffodildb.utils.field.*; 10 import com.daffodilwoods.database.resource.*; 11 import in.co.daffodil.db.jdbc.DatabaseProperties; 12 13 public class ucasefunction extends AbstractStringValueExpression implements charactervaluefunction, Datatypes, TypeConstants { 14 15 public Srightparen_1874859514 _Srightparen_18748595140; 16 public charactervalueexpression _charactervalueexpression1; 17 public Sleftparen653880241 _Sleftparen6538802412; 18 public SNONRESERVEDWORD136444255 _SNONRESERVEDWORD1364442553; 19 20 21 public Object run(Object object) throws com.daffodilwoods.database.resource. 22 DException { 23 FieldBase result = (FieldBase) _charactervalueexpression1.run(object); 24 if (result.isNull()) { 25 return new FieldStringLiteral(FieldUtility.NULLBUFFERRANGE, CHARACTER); 26 } 27 return getResult(getDataType(result), result.getObject()); 28 } 29 30 public ColumnDetails[] getChildColumnDetails() throws DException { 31 return columnDetails; 32 } 33 34 protected String getNameOfColumn(ColumnDetails[] columnDetails) throws 35 DException { 36 String nameOfColumn = ""; 37 for (int i = 0; i < columnDetails.length; ++i) { 38 nameOfColumn += columnDetails[i].getColumn(); 39 } 40 return nameOfColumn; 41 } 42 43 public String getType() throws DException { 44 return (String ) _SNONRESERVEDWORD1364442553.run(null); 45 } 46 47 public ParameterInfo[] getParameterInfo() throws DException { 48 ParameterInfo[] param =_charactervalueexpression1.getParameterInfo(); 49 for (int i = 0; i < param.length; i++) { 50 if (param[i].getQuestionMark()) { 51 param[i].setDataType(Datatypes.CHARACTER); 52 param[i].setName("UCASE Arg"); 53 return param; 54 } 55 } 56 return getThisParameterInfo(); 57 } 58 59 protected ParameterInfo[] getThisParameterInfo() throws DException { 60 ParameterInfo parameterInfo = new ParameterInfo(); 61 parameterInfo.setName(toString()); 62 parameterInfo.setDataType(Datatypes.CHARACTER); 63 return new ParameterInfo[] { 64 parameterInfo}; 65 } 66 67 68 88 89 private Object getResult(int type, Object object) throws DException { 90 switch (type) { 91 case BYTE: 92 case TINYINT: 93 case INTEGER: 94 case INT: 95 case REAL: 96 case DOUBLE: 97 case FLOAT: 98 case DOUBLEPRECISION: 99 case LONG: 100 case BIGINT: 101 case SHORT: 102 case SMALLINT: 103 case BIGDECIMAL: 104 case DEC: 105 case DECIMAL: 106 case NUMERIC: 107 Number operand = (Number ) object; 108 return toUpperCase(operand.toString()); 109 case CHARACTER: 110 case VARCHAR: 111 case CHAR: 112 case CHARACTERVARYING: 113 String string = (String ) object; 114 return toUpperCase(string); 115 default: 116 throw new DException("DSE514", new Object [] {StaticClass.getDataTypeName(type)}); 117 } 118 } 119 120 149 150 private Object toUpperCase(String string) throws DException { 151 return new FieldStringLiteral(string.toUpperCase(), CHARACTER); 152 } 153 154 155 public AbstractRowValueExpression[] getChilds() { 156 AbstractRowValueExpression[] childs = new AbstractRowValueExpression[] { 157 (AbstractRowValueExpression) (_charactervalueexpression1)}; 158 return childs; 159 160 } 161 162 public String toString() { 163 StringBuffer sb = new StringBuffer (); 164 sb.append(" "); 165 sb.append(_SNONRESERVEDWORD1364442553); 166 sb.append(" "); 167 sb.append(_Sleftparen6538802412); 168 sb.append(" "); 169 sb.append(_charactervalueexpression1); 170 sb.append(" "); 171 sb.append(_Srightparen_18748595140); 172 return sb.toString(); 173 } 174 175 public Object clone() throws CloneNotSupportedException { 176 ucasefunction tempClass = new ucasefunction(); 177 tempClass._Srightparen_18748595140 = (Srightparen_1874859514) 178 _Srightparen_18748595140.clone(); 179 tempClass._charactervalueexpression1 = (charactervalueexpression) 180 _charactervalueexpression1.clone(); 181 tempClass._Sleftparen6538802412 = (Sleftparen653880241) 182 _Sleftparen6538802412.clone(); 183 tempClass._SNONRESERVEDWORD1364442553 = (SNONRESERVEDWORD136444255) 184 _SNONRESERVEDWORD1364442553.clone(); 185 return tempClass; 186 } 187 public ByteComparison getByteComparison(Object object) throws DException { 188 ByteComparison byteComparison =new ByteComparison(false, new int[] {CHARACTER}); 189 int columnSize= getColumnSize(object); 190 byteComparison.setSize(columnSize); 191 return byteComparison; 192 } 193 194 217 218 public _Reference[] checkSemantic(_ServerSession parent) throws DException { 219 _Reference[] ref = super.checkSemantic(parent); 220 if(ref!=null) { 221 return ref; 222 } 223 int type = _charactervalueexpression1.getByteComparison(parent). 224 getDataTypes()[0]; 225 switch (type) { 226 case -1: 227 case BYTE: 228 case TINYINT: 229 case INTEGER: 230 case INT: 231 case REAL: 232 case DOUBLE: 233 case FLOAT: 234 case DOUBLEPRECISION: 235 case LONG: 236 case BIGINT: 237 case SHORT: 238 case SMALLINT: 239 case BIGDECIMAL: 240 case DEC: 241 case DECIMAL: 242 case NUMERIC: 243 case CHARACTER: 244 case VARCHAR: 245 case CHAR: 246 case CHARACTERVARYING: 247 return ref; 248 default: 249 throw new DException("DSE514", 250 new Object [] {StaticClass.getDataTypeName(type), 251 "UCASE"}); 252 } 253 } 254 255 public int getColumnSize(Object object) throws DException { 256 ColumnDetails[] columnDetails = getChildColumnDetails(); 257 if (columnDetails[0].getQuestion()) { 258 return DatabaseProperties.maxCharLiteralLength; 259 } 260 else if (columnDetails[0].getType() != TypeConstants.CONSTANT || 261 columnDetails[0].getSize() != -5) { 262 return columnDetails[0].getSize(); 263 } else { 264 FieldBase field = (FieldBase) _charactervalueexpression1.run(object); 265 field.setDatatype(columnDetails[0].getDatatype()); 266 return field.getLength(); 267 } 268 269 } 270 271 272 } 273 | Popular Tags |