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 13 public class atan2function extends AbstractNumericValueFunction { 14 15 public parencommanumericvalueexpression _parencommanumericvalueexpression0; 16 public SNONRESERVEDWORD136444255 _SNONRESERVEDWORD1364442551; 17 18 public Object run(Object object) throws com.daffodilwoods.database.resource.DException { 19 FieldBase[] res = GeneralPurposeStaticClass.changeIntoFieldBase( (Object []) _parencommanumericvalueexpression0.run(object)); 20 FieldBase result1 = res[0]; 21 FieldBase result2 = res[1]; 22 if (result1.isNull() || result2.isNull()) { 23 return new FieldLiteral(FieldUtility.NULLBUFFERRANGE, DOUBLE); 24 } 25 return getResult(getDataType(result1), getDataType(result2), result1.getObject(), result2.getObject()); 26 } 27 28 public ColumnDetails[] getExistingColumnDetails() throws DException { 29 return columnDetails; 30 } 31 32 public ParameterInfo[] getParameterInfo() throws DException { 33 ParameterInfo[] paramInfo = super.getParameterInfo(); 34 for (int i = 0; i < paramInfo.length; i++) { 35 if (paramInfo[i].getQuestionMark()) { 36 paramInfo[i].setDataType(Datatypes.DOUBLE); 37 paramInfo[i].setName("ATAN2 Arg"); 38 } 39 } 40 return paramInfo; 41 } 42 43 private Object getResult(int type1, int type2, Object result1, Object result2) throws DException { 44 if (type1 <= 15) { 45 double operand1 = ( (Number ) result1).doubleValue(); 46 if (type2 <= 15) { 47 double operand2 = ( (Number ) result2).doubleValue(); 48 return new FieldLiteral(new Double (Math.atan2(operand1, operand2)), Datatype.DOUBLE); 49 } else { 50 throw new DException("DSE4108", new Object [] {StaticClass.getDataTypeName(type2), "ATAN2"}); 51 } 52 } else { 53 throw new DException("DSE4108", new Object [] {StaticClass.getDataTypeName(type1), "ATAN2"}); 54 } 55 80 } 81 82 276 277 public AbstractRowValueExpression[] getChilds() { 278 AbstractRowValueExpression[] childs = new AbstractRowValueExpression[] {_parencommanumericvalueexpression0}; 279 return childs; 280 } 281 282 public String getType() throws DException { 283 return (String ) _SNONRESERVEDWORD1364442551.run(null); 284 } 285 286 public String toString() { 287 StringBuffer sb = new StringBuffer (); 288 sb.append(" "); 289 sb.append(_SNONRESERVEDWORD1364442551); 290 sb.append(_parencommanumericvalueexpression0); 291 return sb.toString(); 292 } 293 294 public Object clone() throws CloneNotSupportedException { 295 atan2function tempClass = new atan2function(); 296 tempClass._parencommanumericvalueexpression0 = (parencommanumericvalueexpression) _parencommanumericvalueexpression0.clone(); 297 tempClass._SNONRESERVEDWORD1364442551 = (SNONRESERVEDWORD136444255) _SNONRESERVEDWORD1364442551.clone(); 298 return tempClass; 299 } 300 301 public ByteComparison getByteComparison(Object object) throws DException { 302 ByteComparison byteComparison =new ByteComparison(false, new int[] {DOUBLE}); 303 byteComparison.setSize(getColumnSize(object)); 304 return byteComparison; 305 } 306 307 public _Reference[] checkSemantic(_ServerSession parent) throws DException { 308 _Reference[] ref = super.checkSemantic(parent); 309 if(ref!=null) { 310 return ref; 311 } 312 int[] type = _parencommanumericvalueexpression0.getByteComparison(parent).getDataTypes(); 313 if (type[0] <= 15 || type[0] == -1) { 314 if (type[1] <= 15 || type[1] == -1) { 315 return ref; 316 } 317 throw new DException("DSE4108", 318 new Object [] {StaticClass.getDataTypeName(type[1]), 319 "ATAN2"}); 320 } 321 throw new DException("DSE4108", 322 new Object [] {StaticClass.getDataTypeName(type[0]), 323 "ATAN2"}); 324 325 } 326 public int getColumnSize(Object object) throws DException { 327 return Datatypes.DOUBLESIZE; 328 } 329 330 } 331 | Popular Tags |