KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > extractor > algebra > SqlTypeCombinedStructure


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.extractor.algebra;
24
25 import java.util.ArrayList JavaDoc;
26 import java.util.List JavaDoc;
27
28 import org.xquark.extractor.common.Debug;
29
30 public final class SqlTypeCombinedStructure extends SqlType
31 {
32     private static final String JavaDoc RCSRevision = "$Revision: 1.5 $";
33     private static final String JavaDoc RCSName = "$Name: $";
34
35     protected List JavaDoc _structures = null;;
36
37     public SqlTypeCombinedStructure()
38     {
39     }
40     /**
41     @param List structureList
42     @param structureList
43     @roseuid 3BD1968302B7
44      */

45     public SqlTypeCombinedStructure(List JavaDoc structureList)
46     {
47         setStructures(structureList);
48     }
49
50     public Object JavaDoc clone() {
51         //Trace.enter(this, "clone()");
52
try {
53             SqlTypeCombinedStructure retVal = (SqlTypeCombinedStructure)super.clone();
54             if (null != _structures) {
55                 retVal.setStructures( AlgebraTools.clone(_structures));
56             }
57             //Trace.exit(this, "clone()");
58
return retVal;
59         }
60         catch (CloneNotSupportedException JavaDoc ex) {
61             Debug.assertTrue(false, "error in implementation of clone");
62             //Trace.exit(this, "clone()");
63
return null;
64         }
65     }
66
67     /**
68     Access method for the _structures property.
69
70     @return the current value of the _structures property
71      */

72     public List JavaDoc getStructures()
73     {
74         return _structures;
75     }
76
77     /**
78     Sets the value of the _structures property.
79
80     @param aStructures the new value of the _structures property
81      */

82     public void setStructures(List JavaDoc aStructures)
83     {
84         _structures = aStructures;
85     }
86
87     public void addStructure(SqlType sqlType)
88     {
89         if (null == _structures) {
90             _structures = new ArrayList JavaDoc();
91         }
92         _structures.add(sqlType);
93
94     }
95
96     public List JavaDoc getAttributes() {
97         List JavaDoc retVal = new ArrayList JavaDoc();
98
99         for (int i = 0; i < _structures.size(); i++) {
100             SqlType type = (SqlType)_structures.get(i);
101             if (type instanceof SqlTypeAtom) {
102                 retVal.add(type);
103             }
104             else if (type instanceof SqlTypeStructure) {
105               retVal.addAll( ((SqlTypeStructure)type).getAttributes() );
106             }
107         }
108         return retVal;
109     }
110
111     /**
112     @return boolean
113     @roseuid 3BD196AA0000
114      */

115     public boolean isTuple()
116     {
117         return SqlType.ONE == _multiplicity ;
118     }
119
120     /**
121     @param type
122     @return boolean
123     @roseuid 3BD196AA0050
124      */

125     public boolean isCompatibleTo(SqlType type)
126     {
127      return true;
128     }
129
130     /**
131     @return boolean
132     @roseuid 3BD196AA0096
133      */

134     public boolean isRelation()
135     {
136         return SqlType.MANY == _multiplicity ;
137     }
138
139     /**
140     @return boolean
141     @roseuid 3BD196AA00B4
142      */

143     public boolean isAtom()
144     {
145      return false;
146     }
147
148     /**
149     @return boolean
150     @roseuid 3BD196AA00C8
151      */

152     public boolean isBoolean()
153     {
154         boolean retVal = true;
155         for (int i = 0; i < _structures.size(); i++) {
156             if (! ((SqlType)_structures.get(i)).isBoolean() ) {
157                 retVal = false;
158                 break;
159             }
160         }
161         return retVal;
162     }
163
164     /**
165     @return boolean
166     @roseuid 3BD196AA00E6
167      */

168     public boolean isNumeric()
169     {
170         boolean retVal = true;
171         for (int i = 0; i < _structures.size(); i++) {
172             if (! ((SqlType)_structures.get(i)).isNumeric() ) {
173                 retVal = false;
174                 break;
175             }
176         }
177         return retVal;
178     }
179
180     /**
181     @return boolean
182     @roseuid 3BD196AA010E
183      */

184     public boolean isInteger()
185     {
186         boolean retVal = true;
187         for (int i = 0; i < _structures.size(); i++) {
188             if (! ((SqlType)_structures.get(i)).isInteger() ) {
189                 retVal = false;
190                 break;
191             }
192         }
193         return retVal;
194     }
195
196     /**
197     @return boolean
198     @roseuid 3BD196AA0136
199      */

200     public boolean isString()
201     {
202         boolean retVal = true;
203         for (int i = 0; i < _structures.size(); i++) {
204             if (! ((SqlType)_structures.get(i)).isString() ) {
205                 retVal = false;
206                 break;
207             }
208         }
209         return retVal;
210     }
211
212     /**
213     @return boolean
214     @roseuid 3BD196AA0154
215      */

216     public boolean isDataTime()
217     {
218         boolean retVal = true;
219         for (int i = 0; i < _structures.size(); i++) {
220             if (! ((SqlType)_structures.get(i)).isDataTime() ) {
221                 retVal = false;
222                 break;
223             }
224         }
225         return retVal;
226     }
227
228     /**
229     @return String
230     @roseuid 3BD196AA017C
231      */

232     public String JavaDoc pprint()
233     {
234         StringBuffer JavaDoc retVal = new StringBuffer JavaDoc();
235         retVal.append("CombinedStructure [");
236         for (int i = 0; i < _structures.size(); i++) {
237             retVal.append(((SqlType)_structures.get(i)).pprint());
238             retVal.append("\t");
239         }
240         retVal.append("]");
241         return retVal.toString();
242     }
243
244 }
245
Popular Tags