1 package com.daffodilwoods.daffodildb.server.sql99.expression.numericvalueexpression; 2 3 import java.math.*; 4 5 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.*; 6 import com.daffodilwoods.daffodildb.server.serversystem.*; 7 import com.daffodilwoods.daffodildb.server.sql99.common.*; 8 import com.daffodilwoods.daffodildb.server.sql99.expression.rowvalueexpression.*; 9 import com.daffodilwoods.daffodildb.server.sql99.token.*; 10 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 11 import com.daffodilwoods.daffodildb.utils.*; 12 import com.daffodilwoods.daffodildb.utils.field.*; 13 import com.daffodilwoods.database.resource.*; 14 15 public class radiansfunction extends AbstractNumericValueFunction { 16 17 public parennumericvalueexpression _parennumericvalueexpression0; 18 public SNONRESERVEDWORD136444255 _SNONRESERVEDWORD1364442551; 19 20 protected Object getResult(int type, Object object) throws DException { 21 22 if (object == null) { 23 return new FieldLiteral(FieldUtility.NULLBUFFERRANGE, Datatype.DOUBLE); 24 } 25 switch (type) { 26 case BYTE: 27 case TINYINT: 28 return new FieldLiteral(new Double (Math.toRadians( ( (Byte ) object).doubleValue())), Datatype.DOUBLE); 29 case INTEGER: 30 case INT: 31 Integer integer = (Integer ) object; 32 return new FieldLiteral(new Double (Math.toRadians(integer.doubleValue())), Datatype.DOUBLE); 33 case REAL: 34 Float floatV = (Float ) object; 35 return new FieldLiteral(new Double (Math.toRadians(floatV.doubleValue())), Datatype.DOUBLE); 36 case DOUBLE: 37 case FLOAT: 38 case DOUBLEPRECISION: 39 Double doubleV = (Double ) object; 40 return new FieldLiteral(new Double (Math.toRadians(doubleV.doubleValue())), Datatype.DOUBLE); 41 case LONG: 42 case BIGINT: 43 Long longV = (Long ) object; 44 return new FieldLiteral(new Double (Math.toRadians(longV.doubleValue())), Datatype.DOUBLE); 45 case SHORT: 46 case SMALLINT: 47 Short shortV = (Short ) object; 48 return new FieldLiteral(new Double (Math.toRadians(shortV.doubleValue())), Datatype.DOUBLE); 49 case BIGDECIMAL: 50 case DEC: 51 case DECIMAL: 52 case NUMERIC: 53 BigDecimal bigDecimal = (BigDecimal) object; 54 return new FieldLiteral(new BigDecimal(Math.toRadians(bigDecimal.doubleValue())), Datatype.DOUBLE); 55 default: 56 throw new DException("DSE4108", new Object [] {StaticClass.getDataTypeName(type), "RADIANS"}); 57 } 58 59 } 60 61 public AbstractRowValueExpression[] getChilds() { 62 AbstractRowValueExpression[] childs = new AbstractRowValueExpression[] {_parennumericvalueexpression0}; 63 return childs; 64 } 65 66 public String getType() throws DException { 67 return (String ) _SNONRESERVEDWORD1364442551.run(null); 68 } 69 70 public String toString() { 71 StringBuffer sb = new StringBuffer (); 72 sb.append(" "); 73 sb.append(_SNONRESERVEDWORD1364442551); 74 sb.append(_parennumericvalueexpression0); 75 return sb.toString(); 76 } 77 78 public Object clone() throws CloneNotSupportedException { 79 radiansfunction tempClass = new radiansfunction(); 80 tempClass._parennumericvalueexpression0 = (parennumericvalueexpression) _parennumericvalueexpression0.clone(); 81 tempClass._SNONRESERVEDWORD1364442551 = (SNONRESERVEDWORD136444255) _SNONRESERVEDWORD1364442551.clone(); 82 return tempClass; 83 } 84 85 public ParameterInfo[] getParameterInfo() throws DException { 86 ParameterInfo[] paramInfo = super.getParameterInfo(); 87 for (int i = 0; i < paramInfo.length; i++) { 88 if (paramInfo[i].getQuestionMark()) { 89 paramInfo[i].setDataType(Datatypes.BIGDECIMAL); 90 paramInfo[i].setName("RADIANS Arg"); 91 } 92 } 93 return paramInfo; 94 } 95 96 public ByteComparison getByteComparison(Object object) throws DException { 97 ByteComparison byteComparison = new ByteComparison(false, new int[] {DOUBLE}); 98 byteComparison.setSize(getColumnSize(object)); 99 return byteComparison; 100 } 101 102 121 122 public _Reference[] checkSemantic(_ServerSession parent) throws DException { 123 _Reference[] ref = super.checkSemantic(parent); 124 if(ref!=null) { 125 return ref; 126 } 127 int type = _parennumericvalueexpression0.getByteComparison(parent).getDataTypes()[0]; 128 if (type == -1 || type <= 15) { 129 return ref; 130 } 131 throw new DException("DSE4108", new Object [] {StaticClass.getDataTypeName(type), "RADIANS"}); 132 } 133 public int getColumnSize(Object object) throws DException { 134 return Datatypes.DOUBLESIZE; 135 } 136 137 } 138 | Popular Tags |