KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sql99 > token > unsignedinteger


1 package com.daffodilwoods.daffodildb.server.sql99.token;
2
3 import java.math.*;
4 import java.util.*;
5
6 import com.daffodilwoods.daffodildb.server.sql99.common.*;
7 import com.daffodilwoods.daffodildb.server.sql99.dcl.sqlcontrolstatement.*;
8 import com.daffodilwoods.daffodildb.server.sql99.expression.*;
9 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.*;
10 import com.daffodilwoods.daffodildb.server.sql99.expression.rowvalueexpression.*;
11 import com.daffodilwoods.daffodildb.server.sql99.utils.*;
12 import com.daffodilwoods.daffodildb.utils.byteconverter.*;
13 import com.daffodilwoods.daffodildb.utils.field.*;
14 import com.daffodilwoods.database.resource.*;
15 import com.daffodilwoods.daffodildb.utils.FieldUtility;
16
17 public class unsignedinteger extends AbstractValueExpression implements com.daffodilwoods.daffodildb.utils.parser.StatementExecuter, largeobjectlength, exactnumericliteral, Datatypes, assignmentsource {
18    public digit[] _unsignedinteger0;
19    ColumnDetails cd;
20
21    byte[] returningBytes = null;
22
23    private BigDecimal identifier;
24    private FieldBase fieldBase;
25
26    public Object JavaDoc run(Object JavaDoc object) throws com.daffodilwoods.database.resource.DException {
27       if (fieldBase == null) {
28          String JavaDoc unsignedInteger = "";
29          for (int i = 0; i < _unsignedinteger0.length; i++) {
30             String JavaDoc aa = (String JavaDoc) _unsignedinteger0[i].run(object);
31             unsignedInteger += aa.trim();
32          }
33          fieldBase = new FieldLiteral(unsignedInteger, -1);
34       }
35       return fieldBase;
36
37    }
38
39    public ColumnDetails[] getColumnDetails() throws DException {
40       if (columnDetails == null) {
41          ColumnDetails columnD = new ColumnDetails();
42          columnD.setType(CONSTANT);
43          String JavaDoc name = "";
44          for (int i = 0; i < _unsignedinteger0.length; i++) {
45             String JavaDoc aa = (String JavaDoc) _unsignedinteger0[i].run(null);
46             name += aa.trim();
47          }
48          columnD.setColumnName(new String JavaDoc[] {name});
49          columnD.setObject(this);
50
51          cd = columnD;
52          columnDetails = new ColumnDetails[] {columnD};
53       }
54       return columnDetails;
55    }
56
57    public Object JavaDoc[] getParameters(Object JavaDoc object) throws DException {
58       return null;
59    }
60
61    public int getType() {
62       return _TOKEN.OTHERS;
63    }
64
65    private byte[] getAppropriateBytes() throws DException {
66       int datatype = cd.getDatatype();
67       switch (datatype) {
68          case BOOLEAN:
69             return CCzufDpowfsufs.getBytes(new Boolean JavaDoc(identifier.intValue() == 1));
70          case INT:
71             return CCzufDpowfsufs.getBytes(new Integer JavaDoc(identifier.intValue()));
72          case TINYINT:
73             return CCzufDpowfsufs.getBytes(new Integer JavaDoc(identifier.intValue()));
74          case INTEGER:
75             return CCzufDpowfsufs.getBytes(new Integer JavaDoc(identifier.intValue()));
76          case LONG:
77             return CCzufDpowfsufs.getBytes(new Long JavaDoc(identifier.longValue()));
78          case SHORT:
79             return CCzufDpowfsufs.getBytes(new Short JavaDoc(identifier.shortValue()));
80          case SMALLINT:
81             return CCzufDpowfsufs.getBytes(new Short JavaDoc(identifier.shortValue()));
82          case BYTE:
83             return new byte[] {identifier.byteValue()};
84          case FLOAT:
85             return CCzufDpowfsufs.getBytes(new Float JavaDoc(identifier.floatValue()));
86          case DOUBLE:
87             return CCzufDpowfsufs.getBytes(new Double JavaDoc(identifier.doubleValue()));
88          case BIGDECIMAL:
89          case NUMERIC:
90          case DEC:
91          case DECIMAL:
92             return CCzufDpowfsufs.getBytes(identifier);
93          default:
94             throw new DException("DSE4113", new Object JavaDoc[] {StaticClass.getDataTypeName(datatype)});
95       }
96    }
97
98    public int getCardinality() throws DException {
99       return 1;
100    }
101
102    public AbstractRowValueExpression[] getChilds() {
103       AbstractRowValueExpression[] childs = new AbstractRowValueExpression[] {};
104       return childs;
105
106    }
107
108    public String JavaDoc toString() {
109       StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
110       sb.append(" ");
111       for (int i = 0; i < _unsignedinteger0.length; i++) {
112          sb.append(_unsignedinteger0[i]);
113       }
114       return sb.toString();
115    }
116
117    public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
118       unsignedinteger tempClass = new unsignedinteger();
119       digit[] temp_unsignedinteger0 = new digit[_unsignedinteger0.length];
120       for (int i = 0; i < _unsignedinteger0.length; i++) {
121          temp_unsignedinteger0[i] = (digit) _unsignedinteger0[i].clone();
122       }
123       tempClass._unsignedinteger0 = temp_unsignedinteger0;
124       return tempClass;
125    }
126
127    public void getColumnsIncluded(ArrayList aList) throws DException {
128    }
129
130    public void getTablesIncluded(ArrayList aList) throws DException {
131    }
132
133    public ParameterInfo[] getParameterInfo() throws DException {
134       ParameterInfo parameterInfo = new ParameterInfo();
135       parameterInfo.setDataType(cd.getDatatype());
136       return new ParameterInfo[] {parameterInfo};
137    }
138
139    public ByteComparison getByteComparison(Object JavaDoc object) throws DException {
140       return new ByteComparison(true, new int[] {cd.getDatatype()});
141    }
142
143    public void releaseResource() throws DException {
144    }
145 }
146
Popular Tags