KickJava   Java API By Example, From Geeks To Geeks.

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


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 cotfunction 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       Double JavaDoc numerator = new Double JavaDoc("1");
23       if (type <= 15) {
24          return new FieldLiteral(new Double JavaDoc(numerator.doubleValue() / Math.tan( ( (Number JavaDoc) object).doubleValue())), Datatype.DOUBLE);
25       }
26       throw new DException("DSE4108", new Object JavaDoc[] {StaticClass.getDataTypeName(type), "COT"});
27       /* switch(type){
28          case BYTE : case TINYINT :
29          case INTEGER : case INT :
30          case REAL :
31          case DOUBLE : case FLOAT : case DOUBLEPRECISION :
32          case LONG : case BIGINT :
33          case SHORT : case SMALLINT :
34          case BIGDECIMAL : case DEC : case DECIMAL : case NUMERIC :
35          Number number = (Number)object;
36           return new FieldLiteral(new Double(numerator.doubleValue()/ Math.tan(number.doubleValue())),Datatype.DOUBLE);
37          default :
38            throw new DException("DSE4108",new Object[]{StaticClass.getDataTypeName(type),"COT"});
39        }*/

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

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