KickJava   Java API By Example, From Geeks To Geeks.

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


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 expfunction 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.exp( ( (Number JavaDoc) object).doubleValue())), Datatype.DOUBLE);
24       }
25       throw new DException("DSE4108", new Object JavaDoc[] {StaticClass.getDataTypeName(type), "EXP"});
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 operand=(Number)object;
35              return new FieldLiteral(new Double(Math.exp(operand.doubleValue())),Datatype.DOUBLE);
36            default :
37              throw new DException("DSE4108",new Object[]{StaticClass.getDataTypeName(type),"EXP"});
38          }*/

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

70
71    public AbstractRowValueExpression[] getChilds() {
72       AbstractRowValueExpression[] childs = new AbstractRowValueExpression[] {_parennumericvalueexpression0};
73       return childs;
74    }
75
76    public String JavaDoc getType() throws DException {
77       return (String JavaDoc) _SNONRESERVEDWORD1364442551.run(null);
78    }
79
80    public String JavaDoc toString() {
81       StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
82       sb.append(" ");
83       sb.append(_SNONRESERVEDWORD1364442551);
84       sb.append(_parennumericvalueexpression0);
85       return sb.toString();
86    }
87
88    public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
89       expfunction tempClass = new expfunction();
90       tempClass._parennumericvalueexpression0 = (parennumericvalueexpression) _parennumericvalueexpression0.clone();
91       tempClass._SNONRESERVEDWORD1364442551 = (SNONRESERVEDWORD136444255) _SNONRESERVEDWORD1364442551.clone();
92       return tempClass;
93    }
94
95    public ParameterInfo[] getParameterInfo() throws DException {
96      ParameterInfo[] paramInfo = super.getParameterInfo();
97      for (int i = 0; i < paramInfo.length; i++) {
98        if (paramInfo[i].getQuestionMark()) {
99          paramInfo[i].setDataType(Datatypes.DOUBLE);
100          paramInfo[i].setName("EXP Arg");
101        }
102      }
103      return paramInfo;
104    }
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), "EXP"});
122    }
123   public int getColumnSize(Object JavaDoc object) throws DException {
124         return Datatypes.DOUBLESIZE;
125       }
126
127 }
128
Popular Tags