1
2
3
4
5
6
7
8 package org.astrogrid.registry.beans.resource.votable;
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 AnyTEXT.
28 *
29 * @version $Revision: 1.14 $ $Date: 2007/01/04 16:26:13 $
30 */
31 public class AnyTEXT extends org.astrogrid.common.bean.BaseBean
32 implements java.io.Serializable
33 {
34
35
36
37
38
39
40 /***
41 * internal content storage
42 */
43 private java.lang.String _content = "";
44
45 /***
46 * Field _anyObject
47 */
48 private java.util.ArrayList _anyObject;
49
50
51
52
53
54
55 public AnyTEXT() {
56 super();
57 setContent("");
58 _anyObject = new ArrayList();
59 }
60
61
62
63
64
65
66 /***
67 * Method addAnyObject
68 *
69 * @param vAnyObject
70 */
71 public void addAnyObject(java.lang.Object vAnyObject)
72 throws java.lang.IndexOutOfBoundsException
73 {
74 _anyObject.add(vAnyObject);
75 }
76
77 /***
78 * Method addAnyObject
79 *
80 * @param index
81 * @param vAnyObject
82 */
83 public void addAnyObject(int index, java.lang.Object vAnyObject)
84 throws java.lang.IndexOutOfBoundsException
85 {
86 _anyObject.add(index, vAnyObject);
87 }
88
89 /***
90 * Method clearAnyObject
91 */
92 public void clearAnyObject()
93 {
94 _anyObject.clear();
95 }
96
97 /***
98 * Method enumerateAnyObject
99 */
100 public java.util.Enumeration enumerateAnyObject()
101 {
102 return new org.exolab.castor.util.IteratorEnumeration(_anyObject.iterator());
103 }
104
105 /***
106 * Note: hashCode() has not been overriden
107 *
108 * @param obj
109 */
110 public boolean equals(java.lang.Object obj)
111 {
112 if ( this == obj )
113 return true;
114
115 if (super.equals(obj)==false)
116 return false;
117
118 if (obj instanceof AnyTEXT) {
119
120 AnyTEXT temp = (AnyTEXT)obj;
121 if (this._content != null) {
122 if (temp._content == null) return false;
123 else if (!(this._content.equals(temp._content)))
124 return false;
125 }
126 else if (temp._content != null)
127 return false;
128 if (this._anyObject != null) {
129 if (temp._anyObject == null) return false;
130 else if (!(this._anyObject.equals(temp._anyObject)))
131 return false;
132 }
133 else if (temp._anyObject != null)
134 return false;
135 return true;
136 }
137 return false;
138 }
139
140 /***
141 * Method getAnyObject
142 *
143 * @param index
144 */
145 public java.lang.Object getAnyObject(int index)
146 throws java.lang.IndexOutOfBoundsException
147 {
148
149 if ((index < 0) || (index > _anyObject.size())) {
150 throw new IndexOutOfBoundsException();
151 }
152
153 return (java.lang.Object) _anyObject.get(index);
154 }
155
156 /***
157 * Method getAnyObject
158 */
159 public java.lang.Object[] getAnyObject()
160 {
161 int size = _anyObject.size();
162 java.lang.Object[] mArray = new java.lang.Object[size];
163 for (int index = 0; index < size; index++) {
164 mArray[index] = (java.lang.Object) _anyObject.get(index);
165 }
166 return mArray;
167 }
168
169 /***
170 * Method getAnyObjectCount
171 */
172 public int getAnyObjectCount()
173 {
174 return _anyObject.size();
175 }
176
177 /***
178 * Returns the value of field 'content'. The field 'content'
179 * has the following description: internal content storage
180 *
181 * @return the value of field 'content'.
182 */
183 public java.lang.String getContent()
184 {
185 return this._content;
186 }
187
188 /***
189 * Method isValid
190 */
191 public boolean isValid()
192 {
193 try {
194 validate();
195 }
196 catch (org.exolab.castor.xml.ValidationException vex) {
197 return false;
198 }
199 return true;
200 }
201
202 /***
203 * Method marshal
204 *
205 * @param out
206 */
207 public void marshal(java.io.Writer out)
208 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
209 {
210
211 Marshaller.marshal(this, out);
212 }
213
214 /***
215 * Method marshal
216 *
217 * @param handler
218 */
219 public void marshal(org.xml.sax.ContentHandler handler)
220 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
221 {
222
223 Marshaller.marshal(this, handler);
224 }
225
226 /***
227 * Method removeAnyObject
228 *
229 * @param vAnyObject
230 */
231 public boolean removeAnyObject(java.lang.Object vAnyObject)
232 {
233 boolean removed = _anyObject.remove(vAnyObject);
234 return removed;
235 }
236
237 /***
238 * Method setAnyObject
239 *
240 * @param index
241 * @param vAnyObject
242 */
243 public void setAnyObject(int index, java.lang.Object vAnyObject)
244 throws java.lang.IndexOutOfBoundsException
245 {
246
247 if ((index < 0) || (index > _anyObject.size())) {
248 throw new IndexOutOfBoundsException();
249 }
250 _anyObject.set(index, vAnyObject);
251 }
252
253 /***
254 * Method setAnyObject
255 *
256 * @param anyObjectArray
257 */
258 public void setAnyObject(java.lang.Object[] anyObjectArray)
259 {
260
261 _anyObject.clear();
262 for (int i = 0; i < anyObjectArray.length; i++) {
263 _anyObject.add(anyObjectArray[i]);
264 }
265 }
266
267 /***
268 * Sets the value of field 'content'. The field 'content' has
269 * the following description: internal content storage
270 *
271 * @param content the value of field 'content'.
272 */
273 public void setContent(java.lang.String content)
274 {
275 this._content = content;
276 }
277
278 /***
279 * Method unmarshalAnyTEXT
280 *
281 * @param reader
282 */
283 public static org.astrogrid.registry.beans.resource.votable.AnyTEXT unmarshalAnyTEXT(java.io.Reader reader)
284 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
285 {
286 return (org.astrogrid.registry.beans.resource.votable.AnyTEXT) Unmarshaller.unmarshal(org.astrogrid.registry.beans.resource.votable.AnyTEXT.class, reader);
287 }
288
289 /***
290 * Method validate
291 */
292 public void validate()
293 throws org.exolab.castor.xml.ValidationException
294 {
295 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
296 validator.validate(this);
297 }
298
299 }