KickJava   Java API By Example, From Geeks To Geeks.

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


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

42    }
43
44    /* protected Object getResult(int type,Object object) throws DException {
45         if(object == null)
46           return new FieldLiteral(FieldUtility.NULLBUFFERRANGE,Datatype.DOUBLE);
47         switch(type){
48           case BYTE : case TINYINT :
49             Byte byte1 = (Byte)object;
50             return new FieldLiteral(new Double(Math.atan(byte1.doubleValue())),Datatype.DOUBLE);
51           case INTEGER : case INT :
52             Integer integer = (Integer)object;
53             return new FieldLiteral(new Double(Math.atan(integer.doubleValue())),Datatype.DOUBLE);
54           case REAL :
55             Float floatV = (Float)object;
56             return new FieldLiteral(new Double(Math.atan(floatV.doubleValue())),Datatype.DOUBLE);
57           case DOUBLE : case FLOAT : case DOUBLEPRECISION :
58             Double doubleV = (Double)object;
59             return new FieldLiteral(new Double(Math.atan(doubleV.doubleValue())),Datatype.DOUBLE);
60           case LONG : case BIGINT :
61             Long longV = (Long)object;
62             return new FieldLiteral(new Double(Math.atan(longV.doubleValue())),Datatype.DOUBLE);
63           case SHORT : case SMALLINT :
64             Short shortV = (Short)object;
65             return new FieldLiteral(new Double(Math.atan(shortV.doubleValue())),Datatype.DOUBLE);
66           case BIGDECIMAL : case DEC : case DECIMAL : case NUMERIC :
67             BigDecimal bigDecimal = (BigDecimal)object;
68             return new FieldLiteral(new Double(Math.atan(bigDecimal.doubleValue())),Datatype.DOUBLE);
69           case CHARACTER :case VARCHAR: case CHAR: case CHARACTERVARYING:
70             String string = (String)object;
71             Double d = null;
72             try{
73               d = new Double(string);
74             }catch(Exception e){
75               throw new DException("DSE4104",new Object[]{"character string","double"});
76             }
77             return new FieldLiteral(new Double(Math.atan(d.doubleValue())),Datatype.DOUBLE);
78           default :
79             throw new DException("DSE4108",new Object[]{StaticClass.getDataTypeName(type),"ATAN"});
80         }
81       } */

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