KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

72
73    public AbstractRowValueExpression[] getChilds() {
74       AbstractRowValueExpression[] childs = new AbstractRowValueExpression[] {_parennumericvalueexpression0};
75       return childs;
76    }
77
78    public String JavaDoc getType() throws DException {
79       return (String JavaDoc) _SNONRESERVEDWORD1364442551.run(null);
80    }
81
82    public String JavaDoc toString() {
83       StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
84       sb.append(" ");
85       sb.append(_SNONRESERVEDWORD1364442551);
86       sb.append(_parennumericvalueexpression0);
87       return sb.toString();
88    }
89
90    public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
91       asinfunction tempClass = new asinfunction();
92       tempClass._parennumericvalueexpression0 = (parennumericvalueexpression) _parennumericvalueexpression0.clone();
93       tempClass._SNONRESERVEDWORD1364442551 = (SNONRESERVEDWORD136444255) _SNONRESERVEDWORD1364442551.clone();
94       return tempClass;
95    }
96
97    public ParameterInfo[] getParameterInfo() throws DException {
98      ParameterInfo[] paramInfo = super.getParameterInfo();
99     for (int i = 0; i < paramInfo.length; i++) {
100     if (paramInfo[i].getQuestionMark()) {
101      paramInfo[i].setDataType(Datatypes.DOUBLE);
102      paramInfo[i].setName("ASIN Arg");
103     }
104    }
105      return paramInfo;
106    }
107
108    public ByteComparison getByteComparison(Object JavaDoc object) throws DException {
109    ByteComparison byteComparison= new ByteComparison(false, new int[] {Datatype.DOUBLE});
110    byteComparison.setSize(getColumnSize(object));
111    return byteComparison;
112    }
113
114    /*private int getDatatype(Object object) throws DException {
115      int type = getDataTypeForByte(_parennumericvalueexpression0.getByteComparison(object));
116      switch(type){
117        case BYTE : case TINYINT :
118        case INTEGER : case INT :
119        case DOUBLE : case FLOAT : case DOUBLEPRECISION :
120        case LONG : case BIGINT :
121        case SHORT : case SMALLINT :
122        case BIGDECIMAL : case DEC : case DECIMAL : case NUMERIC :
123          return DOUBLE;
124        case REAL :
125          return FLOAT;
126         default :
127            throw new DException("DSE4108",new Object[]{StaticClass.getDataTypeName(type),"ASIN"});
128      }
129     }*/

130
131    public _Reference[] checkSemantic(_ServerSession parent) throws DException {
132       _Reference[] ref = super.checkSemantic(parent);
133       if(ref!=null) {
134             return ref;
135           }
136       int type = _parennumericvalueexpression0.getByteComparison(parent).getDataTypes()[0];
137       if (type == -1 || type <= 15) {
138          return ref;
139       }
140       throw new DException("DSE4108", new Object JavaDoc[] {StaticClass.getDataTypeName(type), "ACOS"});
141    }
142
143   public int getColumnSize(Object JavaDoc object) throws DException {
144         return Datatypes.DOUBLESIZE;
145       }
146
147 }
148
Popular Tags