1 package com.daffodilwoods.daffodildb.server.sql99.expression.numericvalueexpression; 2 3 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.*; 4 import com.daffodilwoods.daffodildb.server.serversystem.*; 5 import com.daffodilwoods.daffodildb.server.sql99.common.*; 6 import com.daffodilwoods.daffodildb.server.sql99.expression.rowvalueexpression.*; 7 import com.daffodilwoods.daffodildb.server.sql99.token.*; 8 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 9 import com.daffodilwoods.daffodildb.utils.*; 10 import com.daffodilwoods.daffodildb.utils.field.*; 11 import com.daffodilwoods.database.resource.*; 12 import com.daffodilwoods.database.utility.P; 13 14 public class powerfunction extends AbstractNumericValueFunction { 15 16 public parencommanumericvalueexpression _parencommanumericvalueexpression0; 17 public SNONRESERVEDWORD136444255 _SNONRESERVEDWORD1364442551; 18 19 public Object run(Object object) throws com.daffodilwoods.database.resource.DException { 20 FieldBase[] res = GeneralPurposeStaticClass.changeIntoFieldBase( (Object []) _parencommanumericvalueexpression0.run(object)); 21 FieldBase result1 = res[0]; 22 FieldBase result2 = res[1]; 23 if (result1.isNull() || result2.isNull()) { 24 return new FieldLiteral(FieldUtility.NULLBUFFERRANGE, DOUBLE); 25 } 26 return getResult(getDataType(result1), getDataType(result2), 27 result1.getObject(), result2.getObject()); 28 } 29 30 public ColumnDetails[] getExistingColumnDetails() throws DException { 31 return columnDetails; 32 } 33 34 public ParameterInfo[] getParameterInfo() throws DException { 35 ParameterInfo[] paramInfo = super.getParameterInfo(); 36 for (int i = 0; i < paramInfo.length; i++) { 37 if (paramInfo[i].getQuestionMark()) { 38 paramInfo[i].setDataType(Datatypes.DOUBLE); 39 paramInfo[i].setName("POWER Arg"); 40 41 } 42 } 43 return paramInfo; 44 } 45 46 47 private Object getResult(int type1, int type2, Object result1, Object result2) throws DException { 48 if (type1 <= 15) { 49 if (type2 <= 15) { 50 return power( ( (Number ) result1).doubleValue(), 51 ( (Number ) result2).doubleValue()); 52 } 53 throw new DException("DSE4108", new Object [] {StaticClass.getDataTypeName(type2), "POWER"}); 54 } 55 throw new DException("DSE4108", new Object [] {StaticClass.getDataTypeName(type1), "POWER"}); 56 80 } 81 82 228 229 private Object power(double value1, double value2) throws DException { 230 return new FieldLiteral(new Double (Math.pow(value1, value2)), Datatype.DOUBLE); 231 } 232 233 public AbstractRowValueExpression[] getChilds() { 234 AbstractRowValueExpression[] childs = new AbstractRowValueExpression[] {_parencommanumericvalueexpression0}; 235 return childs; 236 } 237 238 public String getType() throws DException { 239 return (String ) _SNONRESERVEDWORD1364442551.run(null); 240 } 241 242 public String toString() { 243 StringBuffer sb = new StringBuffer (); 244 sb.append(" "); 245 sb.append(_SNONRESERVEDWORD1364442551); 246 sb.append(_parencommanumericvalueexpression0); 247 return sb.toString(); 248 } 249 250 public Object clone() throws CloneNotSupportedException { 251 powerfunction tempClass = new powerfunction(); 252 tempClass._parencommanumericvalueexpression0 = (parencommanumericvalueexpression) _parencommanumericvalueexpression0.clone(); 253 tempClass._SNONRESERVEDWORD1364442551 = (SNONRESERVEDWORD136444255) _SNONRESERVEDWORD1364442551.clone(); 254 return tempClass; 255 } 256 257 protected ParameterInfo[] getThisParameterInfo() throws DException { 258 ParameterInfo parameterInfo = new ParameterInfo(); 259 parameterInfo.setName(toString()); 260 parameterInfo.setDataType(Datatypes.DOUBLE); 261 return new ParameterInfo[] { 262 parameterInfo}; 263 } 264 265 public ByteComparison getByteComparison(Object object) throws DException { 266 ByteComparison byteComparison = new ByteComparison(false, new int[] {DOUBLE}); 267 byteComparison.setSize(getColumnSize(object)); 268 return byteComparison; 269 } 270 271 362 public _Reference[] checkSemantic(_ServerSession parent) throws DException { 363 _Reference[] ref = super.checkSemantic(parent); 364 if(ref!=null) { 365 return ref; 366 } 367 int type[] = _parencommanumericvalueexpression0.getByteComparison(parent).getDataTypes(); 368 if (type[0] == -1 || type[0] <= 15) { 369 if (type[1] == -1 || type[1] <= 15) { 370 return ref; 371 } 372 throw new DException("DSE4108", 373 new Object [] {StaticClass.getDataTypeName(type[1]), 374 "POWER"}); 375 } 376 throw new DException("DSE4108", 377 new Object [] {StaticClass.getDataTypeName(type[0]), 378 "POWER"}); 379 380 } 381 public int getColumnSize(Object object) throws DException { 382 return Datatypes.DOUBLESIZE; 383 } 384 385 } 386 | Popular Tags |