1
2
3
4
5
6
7
8 package org.astrogrid.registry.beans.resource.dataservice;
9
10
11
12
13
14 import java.io.IOException;
15 import java.io.Reader;
16 import java.io.Serializable;
17 import java.io.Writer;
18 import java.util.ArrayList;
19 import java.util.Enumeration;
20 import org.exolab.castor.xml.MarshalException;
21 import org.exolab.castor.xml.Marshaller;
22 import org.exolab.castor.xml.Unmarshaller;
23 import org.exolab.castor.xml.ValidationException;
24 import org.xml.sax.ContentHandler;
25
26 /***
27 * Class TableType.
28 *
29 * @version $Revision: 1.14 $ $Date: 2007/01/04 16:26:08 $
30 */
31 public class TableType extends org.astrogrid.common.bean.BaseBean
32 implements java.io.Serializable
33 {
34
35
36
37
38
39
40 /***
41 * a name for the role this table plays. Recognized
42 * values include "out", indicating this table is output
43 * from a query.
44 *
45 */
46 private java.lang.String _role;
47
48 /***
49 * the name of someone or something
50 */
51 private java.lang.String _name;
52
53 /***
54 * An account of the nature of the resource
55 *
56 */
57 private java.lang.String _description;
58
59 /***
60 * a description of a table column.
61 *
62 */
63 private java.util.ArrayList _columnList;
64
65
66
67
68
69
70 public TableType() {
71 super();
72 _columnList = new ArrayList();
73 }
74
75
76
77
78
79
80 /***
81 * Method addColumn
82 *
83 * @param vColumn
84 */
85 public void addColumn(org.astrogrid.registry.beans.resource.dataservice.ParamType vColumn)
86 throws java.lang.IndexOutOfBoundsException
87 {
88 _columnList.add(vColumn);
89 }
90
91 /***
92 * Method addColumn
93 *
94 * @param index
95 * @param vColumn
96 */
97 public void addColumn(int index, org.astrogrid.registry.beans.resource.dataservice.ParamType vColumn)
98 throws java.lang.IndexOutOfBoundsException
99 {
100 _columnList.add(index, vColumn);
101 }
102
103 /***
104 * Method clearColumn
105 */
106 public void clearColumn()
107 {
108 _columnList.clear();
109 }
110
111 /***
112 * Method enumerateColumn
113 */
114 public java.util.Enumeration enumerateColumn()
115 {
116 return new org.exolab.castor.util.IteratorEnumeration(_columnList.iterator());
117 }
118
119 /***
120 * Note: hashCode() has not been overriden
121 *
122 * @param obj
123 */
124 public boolean equals(java.lang.Object obj)
125 {
126 if ( this == obj )
127 return true;
128
129 if (super.equals(obj)==false)
130 return false;
131
132 if (obj instanceof TableType) {
133
134 TableType temp = (TableType)obj;
135 if (this._role != null) {
136 if (temp._role == null) return false;
137 else if (!(this._role.equals(temp._role)))
138 return false;
139 }
140 else if (temp._role != null)
141 return false;
142 if (this._name != null) {
143 if (temp._name == null) return false;
144 else if (!(this._name.equals(temp._name)))
145 return false;
146 }
147 else if (temp._name != null)
148 return false;
149 if (this._description != null) {
150 if (temp._description == null) return false;
151 else if (!(this._description.equals(temp._description)))
152 return false;
153 }
154 else if (temp._description != null)
155 return false;
156 if (this._columnList != null) {
157 if (temp._columnList == null) return false;
158 else if (!(this._columnList.equals(temp._columnList)))
159 return false;
160 }
161 else if (temp._columnList != null)
162 return false;
163 return true;
164 }
165 return false;
166 }
167
168 /***
169 * Method getColumn
170 *
171 * @param index
172 */
173 public org.astrogrid.registry.beans.resource.dataservice.ParamType getColumn(int index)
174 throws java.lang.IndexOutOfBoundsException
175 {
176
177 if ((index < 0) || (index > _columnList.size())) {
178 throw new IndexOutOfBoundsException();
179 }
180
181 return (org.astrogrid.registry.beans.resource.dataservice.ParamType) _columnList.get(index);
182 }
183
184 /***
185 * Method getColumn
186 */
187 public org.astrogrid.registry.beans.resource.dataservice.ParamType[] getColumn()
188 {
189 int size = _columnList.size();
190 org.astrogrid.registry.beans.resource.dataservice.ParamType[] mArray = new org.astrogrid.registry.beans.resource.dataservice.ParamType[size];
191 for (int index = 0; index < size; index++) {
192 mArray[index] = (org.astrogrid.registry.beans.resource.dataservice.ParamType) _columnList.get(index);
193 }
194 return mArray;
195 }
196
197 /***
198 * Method getColumnCount
199 */
200 public int getColumnCount()
201 {
202 return _columnList.size();
203 }
204
205 /***
206 * Returns the value of field 'description'. The field
207 * 'description' has the following description: An account of
208 * the nature of the resource
209 *
210 *
211 * @return the value of field 'description'.
212 */
213 public java.lang.String getDescription()
214 {
215 return this._description;
216 }
217
218 /***
219 * Returns the value of field 'name'. The field 'name' has the
220 * following description: the name of someone or something
221 *
222 * @return the value of field 'name'.
223 */
224 public java.lang.String getName()
225 {
226 return this._name;
227 }
228
229 /***
230 * Returns the value of field 'role'. The field 'role' has the
231 * following description: a name for the role this table plays.
232 * Recognized
233 * values include "out", indicating this table is output
234 * from a query.
235 *
236 *
237 * @return the value of field 'role'.
238 */
239 public java.lang.String getRole()
240 {
241 return this._role;
242 }
243
244 /***
245 * Method isValid
246 */
247 public boolean isValid()
248 {
249 try {
250 validate();
251 }
252 catch (org.exolab.castor.xml.ValidationException vex) {
253 return false;
254 }
255 return true;
256 }
257
258 /***
259 * Method marshal
260 *
261 * @param out
262 */
263 public void marshal(java.io.Writer out)
264 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
265 {
266
267 Marshaller.marshal(this, out);
268 }
269
270 /***
271 * Method marshal
272 *
273 * @param handler
274 */
275 public void marshal(org.xml.sax.ContentHandler handler)
276 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
277 {
278
279 Marshaller.marshal(this, handler);
280 }
281
282 /***
283 * Method removeColumn
284 *
285 * @param vColumn
286 */
287 public boolean removeColumn(org.astrogrid.registry.beans.resource.dataservice.ParamType vColumn)
288 {
289 boolean removed = _columnList.remove(vColumn);
290 return removed;
291 }
292
293 /***
294 * Method setColumn
295 *
296 * @param index
297 * @param vColumn
298 */
299 public void setColumn(int index, org.astrogrid.registry.beans.resource.dataservice.ParamType vColumn)
300 throws java.lang.IndexOutOfBoundsException
301 {
302
303 if ((index < 0) || (index > _columnList.size())) {
304 throw new IndexOutOfBoundsException();
305 }
306 _columnList.set(index, vColumn);
307 }
308
309 /***
310 * Method setColumn
311 *
312 * @param columnArray
313 */
314 public void setColumn(org.astrogrid.registry.beans.resource.dataservice.ParamType[] columnArray)
315 {
316
317 _columnList.clear();
318 for (int i = 0; i < columnArray.length; i++) {
319 _columnList.add(columnArray[i]);
320 }
321 }
322
323 /***
324 * Sets the value of field 'description'. The field
325 * 'description' has the following description: An account of
326 * the nature of the resource
327 *
328 *
329 * @param description the value of field 'description'.
330 */
331 public void setDescription(java.lang.String description)
332 {
333 this._description = description;
334 }
335
336 /***
337 * Sets the value of field 'name'. The field 'name' has the
338 * following description: the name of someone or something
339 *
340 * @param name the value of field 'name'.
341 */
342 public void setName(java.lang.String name)
343 {
344 this._name = name;
345 }
346
347 /***
348 * Sets the value of field 'role'. The field 'role' has the
349 * following description: a name for the role this table plays.
350 * Recognized
351 * values include "out", indicating this table is output
352 * from a query.
353 *
354 *
355 * @param role the value of field 'role'.
356 */
357 public void setRole(java.lang.String role)
358 {
359 this._role = role;
360 }
361
362 /***
363 * Method unmarshalTableType
364 *
365 * @param reader
366 */
367 public static org.astrogrid.registry.beans.resource.dataservice.TableType unmarshalTableType(java.io.Reader reader)
368 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
369 {
370 return (org.astrogrid.registry.beans.resource.dataservice.TableType) Unmarshaller.unmarshal(org.astrogrid.registry.beans.resource.dataservice.TableType.class, reader);
371 }
372
373 /***
374 * Method validate
375 */
376 public void validate()
377 throws org.exolab.castor.xml.ValidationException
378 {
379 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
380 validator.validate(this);
381 }
382
383 }