KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sql99 > expression > numericvalueexpression > sinefunction


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 sinefunction extends AbstractNumericValueFunction {
14
15    public parennumericvalueexpression _parennumericvalueexpression0;
16    public SNONRESERVEDWORD136444255 _SNONRESERVEDWORD1364442551;
17
18    protected Object JavaDoc getResult(int type, Object JavaDoc object) throws DException {
19       if (object == null) {
20          return new FieldLiteral(FieldUtility.NULLBUFFERRANGE, Datatype.DOUBLE);
21       }
22       if (type <= 15) {
23          return new FieldLiteral(new Double JavaDoc(Math.sin( ( (Number JavaDoc) object).doubleValue())), Datatype.DOUBLE);
24       }
25       throw new DException("DSE4108", new Object JavaDoc[] {StaticClass.getDataTypeName(type), "SIN"});
26       /* switch(type){
27           case BYTE : case TINYINT :
28           case INTEGER : case INT :
29           case REAL :
30           case DOUBLE : case FLOAT : case DOUBLEPRECISION :
31           case LONG : case BIGINT :
32           case SHORT : case SMALLINT :
33           case BIGDECIMAL : case DEC : case DECIMAL : case NUMERIC :
34             return new FieldLiteral(new Double(Math.sin(((Number)object).doubleValue())),Datatype.DOUBLE);
35           default :
36           throw new DException("DSE4108",new Object[]{StaticClass.getDataTypeName(type),"SIN"});
37         }*/

38    }
39
40    /*protected Object getResult(int type,Object object) throws DException {
41      if(object == null)
42        return new FieldLiteral(FieldUtility.NULLBUFFERRANGE,Datatype.DOUBLE);
43        switch(type){
44          case BYTE : case TINYINT :
45            return new FieldLiteral(new Double(Math.sin(((Byte)object).doubleValue())),Datatype.DOUBLE);
46          case INTEGER : case INT :
47            Integer integer = (Integer)object;
48            return new FieldLiteral(new Double(Math.sin(integer.doubleValue())),Datatype.DOUBLE);
49          case REAL :
50            Float floatV = (Float)object;
51            return new FieldLiteral(new Double(Math.sin(floatV.doubleValue())),Datatype.DOUBLE);
52          case DOUBLE : case FLOAT : case DOUBLEPRECISION :
53            Double doubleV = (Double)object;
54            return new FieldLiteral(new Double(Math.sin(doubleV.doubleValue())),Datatype.DOUBLE);
55          case LONG : case BIGINT :
56            Long longV = (Long)object;
57            return new FieldLiteral(new Double(Math.sin(longV.doubleValue())),Datatype.DOUBLE);
58          case SHORT : case SMALLINT :
59            Short shortV = (Short)object;
60            return new FieldLiteral(new Double(Math.sin(shortV.doubleValue())),Datatype.DOUBLE);
61          case BIGDECIMAL : case DEC : case DECIMAL : case NUMERIC :
62            BigDecimal bigDecimal = (BigDecimal)object;
63            return new FieldLiteral(new Double(Math.sin(bigDecimal.doubleValue())),Datatype.DOUBLE);
64            default :
65                        throw new DException("DSE4108",new Object[]{StaticClass.getDataTypeName(type),"SIN"});
66        }
67         }*/

68
69    public AbstractRowValueExpression[] getChilds() {
70       AbstractRowValueExpression[] childs = new AbstractRowValueExpression[] {_parennumericvalueexpression0};
71       return childs;
72    }
73
74    public String JavaDoc getType() throws DException {
75       return (String JavaDoc) _SNONRESERVEDWORD1364442551.run(null);
76    }
77
78    public String JavaDoc toString() {
79       StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
80       sb.append(" ");
81       sb.append(_SNONRESERVEDWORD1364442551);
82       sb.append(_parennumericvalueexpression0);
83       return sb.toString();
84    }
85
86    public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
87       sinefunction tempClass = new sinefunction();
88       tempClass._parennumericvalueexpression0 = (parennumericvalueexpression) _parennumericvalueexpression0.clone();
89       tempClass._SNONRESERVEDWORD1364442551 = (SNONRESERVEDWORD136444255) _SNONRESERVEDWORD1364442551.clone();
90       return tempClass;
91    }
92
93    public ParameterInfo[] getParameterInfo() throws DException {
94      ParameterInfo[] paramInfo = super.getParameterInfo();
95      for (int i = 0; i < paramInfo.length; i++) {
96        if (paramInfo[i].getQuestionMark()) {
97          paramInfo[i].setDataType(Datatypes.DOUBLE);
98          paramInfo[i].setName("SINE Arg");
99        }
100      }
101      return paramInfo;
102    }
103
104    public ByteComparison getByteComparison(Object JavaDoc object) throws DException {
105    ByteComparison byteComparison = new ByteComparison(false, new int[] {DOUBLE});
106    byteComparison.setSize(getColumnSize(object));
107    return byteComparison;
108    }
109
110    public _Reference[] checkSemantic(_ServerSession parent) throws DException {
111       _Reference[] ref = super.checkSemantic(parent);
112       if(ref!=null) {
113         return ref;
114        }
115       int type = _parennumericvalueexpression0.getByteComparison(parent).getDataTypes()[0];
116       if (type == -1 || type <= 15) {
117          return ref;
118       }
119       throw new DException("DSE4108", new Object JavaDoc[] {StaticClass.getDataTypeName(type), "SINE"});
120    }
121    public int getColumnSize(Object JavaDoc object) throws DException {
122           return Datatypes.DOUBLESIZE;
123        }
124
125 }
126
Popular Tags