KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sql99 > dml > contextuallytypedrowvalueexpressionlist


1 package com.daffodilwoods.daffodildb.server.sql99.dml;
2
3 import java.util.*;
4
5 import com.daffodilwoods.daffodildb.server.serversystem.*;
6 import com.daffodilwoods.daffodildb.server.sql99.common.*;
7 import com.daffodilwoods.daffodildb.server.sql99.utils.*;
8 import com.daffodilwoods.database.resource.*;
9
10 public class contextuallytypedrowvalueexpressionlist implements com.daffodilwoods.daffodildb.utils.parser.StatementExecuter, TypeConstants {
11    public contextuallytypedrowvalueexpression[] _OptRepScomma94843605contextuallytypedrowvalueexpression0;
12
13    int cardinality = 0;
14
15    /**
16     * This method returns the Object Array of the values that have been inserted by the user.
17     * It collects the values from all the active expressions, and returns them in a group.
18     * @param obj
19     * @return Object[] values
20     * @throws com.daffodilwoods.database.resource.DException
21     */

22
23    public Object JavaDoc run(Object JavaDoc obj) throws com.daffodilwoods.database.resource.DException {
24       int length = _OptRepScomma94843605contextuallytypedrowvalueexpression0.length;
25       Object JavaDoc[] arr = new Object JavaDoc[length];
26       for (int i = 0; i < length; i++) {
27             arr[i] = _OptRepScomma94843605contextuallytypedrowvalueexpression0[i].run(obj);
28       }
29       return arr;
30    }
31
32    /**
33     * This method returns the cardinality of all the expressions...
34     * It is being taken that the cardinality of each active expression is equal.
35     * If cardinality of each expression involved is not same, an exception is thrown.
36     * @return int -- The cardinality
37     * @throws com.daffodilwoods.database.resource.DException
38     */

39
40    public int getCardinality() throws DException {
41       int len = _OptRepScomma94843605contextuallytypedrowvalueexpression0.length;
42       int cardinalityFirst = _OptRepScomma94843605contextuallytypedrowvalueexpression0[0].getCardinality();
43       if (cardinalityFirst == -1) {
44          return cardinality = cardinalityFirst;
45       }
46       int tempCardinality;
47       for (int i = 0; i < len; i++) {
48          tempCardinality = _OptRepScomma94843605contextuallytypedrowvalueexpression0[i].getCardinality();
49          if (tempCardinality == -1) {
50             continue;
51          }
52          if (cardinalityFirst != tempCardinality) {
53             throw new DException("DSE214", (Object JavaDoc[])null);
54          }
55       }
56       return cardinality = cardinalityFirst;
57    }
58
59    /**
60     * This method returns the parameters of all the expressions that are active.
61     * @param object
62     * @return Object[]
63     * @throws DException
64     */

65
66    public Object JavaDoc[] getParameters(Object JavaDoc object) throws DException {
67       int len = _OptRepScomma94843605contextuallytypedrowvalueexpression0.length;
68       ArrayList arr = new ArrayList(len);
69       for (int i = 0; i < len; i++) {
70          Object JavaDoc[] parameter = _OptRepScomma94843605contextuallytypedrowvalueexpression0[i].getParameters(object);
71          if (parameter != null) {
72             arr.addAll(Arrays.asList(parameter));
73          }
74       }
75       return arr.size() > 0 ? arr.toArray() : null;
76    }
77
78    /**
79     * This method returns the ParameterInfo of all the active constructor expressions.
80     * @return ParameterInfo[]
81     * @throws DException
82     */

83
84    public ParameterInfo[] getParameterInfo() throws DException {
85       int len = _OptRepScomma94843605contextuallytypedrowvalueexpression0.length;
86       ArrayList arr = new ArrayList(len);
87       ParameterInfo[] pInfo;
88       for (int i = 0; i < len; i++) {
89          pInfo = _OptRepScomma94843605contextuallytypedrowvalueexpression0[i].getParameterInfo();
90          if (pInfo != null) {
91             for (int j = 0; j < pInfo.length; j++) {
92               if(pInfo[j].getOridinalPosition()==-1) {
93                  pInfo[j].setOrdinalPosition(i);
94               }
95             }
96             arr.addAll(Arrays.asList(pInfo));
97          }
98       }
99       return arr.size() > 0 ? (ParameterInfo[]) arr.toArray(new ParameterInfo[0]) : null;
100    }
101
102
103
104    /**
105     * This method returns the columnDetails of all the active constructor elements.
106     * @return ColumnDetails[]
107     * @throws DException
108     */

109
110    public ColumnDetails[] getColumnDetails() throws DException {
111       int len = _OptRepScomma94843605contextuallytypedrowvalueexpression0.length;
112       ArrayList arr = new ArrayList(len);
113       ColumnDetails[] cd;
114       for (int i = 0; i < len; i++) {
115          cd = _OptRepScomma94843605contextuallytypedrowvalueexpression0[i].getColumnDetails();
116          if (cd != null) {
117             arr.addAll(Arrays.asList(cd));
118          }
119       }
120       return arr.size() > 0 ? (ColumnDetails[]) arr.toArray(new ColumnDetails[0]) : null;
121    }
122
123    public _Reference[] getReferences(TableDetails[] td) throws DException {
124       int len = _OptRepScomma94843605contextuallytypedrowvalueexpression0.length;
125       ArrayList arr = new ArrayList(len);
126       _Reference[] ref;
127       for (int i = 0; i < len; i++) {
128          ref = _OptRepScomma94843605contextuallytypedrowvalueexpression0[i].getReferences(td);
129          if (ref != null) {
130             arr.addAll(Arrays.asList(ref));
131          }
132       }
133       return arr.size() > 0 ? (_Reference[]) arr.toArray(new _Reference[0]) : null;
134    }
135
136    public _Reference[] checkSemantic(_ServerSession serverSession) throws DException {
137       int len = _OptRepScomma94843605contextuallytypedrowvalueexpression0.length;
138       ArrayList arr = new ArrayList(len);
139       _Reference[] ref;
140       for (int i = 0; i < len; i++) {
141          ref = _OptRepScomma94843605contextuallytypedrowvalueexpression0[i].checkSemantic(serverSession);
142          if (ref != null) {
143             arr.addAll(Arrays.asList(ref));
144          }
145       }
146       return arr.size() > 0 ? (_Reference[]) arr.toArray(new _Reference[0]) : null;
147    }
148
149    public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
150       return this;
151    }
152
153    public String JavaDoc toString() {
154       StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
155       sb.append(" ");
156       sb.append(_OptRepScomma94843605contextuallytypedrowvalueexpression0[0]);
157       for (int i = 1; i < _OptRepScomma94843605contextuallytypedrowvalueexpression0.length; i++) {
158          sb.append(",").append(_OptRepScomma94843605contextuallytypedrowvalueexpression0[i]);
159       }
160       return sb.toString();
161    }
162    public void getTablesIncluded(ArrayList arrayList) throws DException{
163      for(int i=0;i< _OptRepScomma94843605contextuallytypedrowvalueexpression0.length ;i++){
164        _OptRepScomma94843605contextuallytypedrowvalueexpression0[i].
165            getTablesIncluded(arrayList);
166      }
167   }
168
169 }
170
Popular Tags