KickJava   Java API By Example, From Geeks To Geeks.

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


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 cosfunction 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, DOUBLE);
21       }
22       if (type <= 15) {
23          return new FieldLiteral(new Double JavaDoc(Math.cos( ( (Number JavaDoc) object).doubleValue())), Datatype.DOUBLE);
24       }
25       throw new DException("DSE4108", new Object JavaDoc[] {StaticClass.getDataTypeName(type), "COS"});
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           Number number = (Number)object;
35           return new FieldLiteral(new Double(Math.cos(number.doubleValue())),Datatype.DOUBLE);
36         default :
37          throw new DException("DSE4108",new Object[]{StaticClass.getDataTypeName(type),"COS"});
38        }*/

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

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