KickJava   Java API By Example, From Geeks To Geeks.

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


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 acosfunction 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 number = (Number JavaDoc) object;
24          return new FieldLiteral(new Double JavaDoc(Math.acos(number.doubleValue())), Datatype.DOUBLE);
25       }
26       throw new DException("DSE4108", new Object JavaDoc[] {StaticClass.getDataTypeName(type), "ACOS"});
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(Math.acos(number.doubleValue())),Datatype.DOUBLE);
37             default :
38                 throw new DException("DSE4108", new Object[]{StaticClass.getDataTypeName(type) ,"ACOS"});
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          switch(type){
46            case BYTE : case TINYINT :
47                  Byte byte1 = (Byte)object;
48                  return new FieldLiteral(new Double(Math.acos(byte1.doubleValue())),Datatype.DOUBLE);
49                case INTEGER : case INT :
50                  Integer integer = (Integer)object;
51                  return new FieldLiteral(new Double(Math.acos(integer.doubleValue())),Datatype.DOUBLE);
52              case REAL :
53                  Float floatV = (Float)object;
54                  return new FieldLiteral(new Double(Math.acos(floatV.doubleValue())),Datatype.DOUBLE);
55                case DOUBLE : case FLOAT : case DOUBLEPRECISION :
56                  Double doubleV = (Double)object;
57                  return new FieldLiteral(new Double(Math.acos(doubleV.doubleValue())),Datatype.DOUBLE);
58                case LONG : case BIGINT :
59                  Long longV = (Long)object;
60                  return new FieldLiteral(new Double(Math.acos(longV.doubleValue())),Datatype.DOUBLE);
61                case SHORT : case SMALLINT :
62                  Short shortV = (Short)object;
63                  return new FieldLiteral(new Double(Math.acos(shortV.doubleValue())),Datatype.DOUBLE);
64                case BIGDECIMAL : case DEC : case DECIMAL : case NUMERIC :
65                  BigDecimal bigDecimal = (BigDecimal)object;
66                  return new FieldLiteral(new Double(Math.acos(bigDecimal.doubleValue())),Datatype.DOUBLE);
67              default :
68                  throw new DException("DSE4108", new Object[]{StaticClass.getDataTypeName(type) ,"ACOS"});
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       acosfunction tempClass = new acosfunction();
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("ACOS Arg");
102     }
103    }
104      return paramInfo;
105    }
106    public ByteComparison getByteComparison(Object JavaDoc object) throws DException {
107      ByteComparison byteComparison = new ByteComparison(false, new int[] {DOUBLE});
108      byteComparison.setSize(getColumnSize(object));
109      return byteComparison;
110    }
111
112    public _Reference[] checkSemantic(_ServerSession parent) throws DException {
113       _Reference[] ref = super.checkSemantic(parent);
114       if(ref!=null) {
115             return ref;
116           }
117       int type = _parennumericvalueexpression0.getByteComparison(parent).getDataTypes()[0];
118       if (type == -1 || type <= 15) {
119          return ref;
120       }
121       throw new DException("DSE4108", new Object JavaDoc[] {StaticClass.getDataTypeName(type), "ACOS"});
122
123    }
124
125    public int getColumnSize(Object JavaDoc object) throws DException {
126       return Datatypes.DOUBLESIZE;
127     }
128 }
129
Popular Tags