1
2
3
4
5
6
7
8 package org.astrogrid.registry.beans.cea;
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.astrogrid.registry.beans.resource.IdentifierType;
21 import org.exolab.castor.xml.MarshalException;
22 import org.exolab.castor.xml.Marshaller;
23 import org.exolab.castor.xml.Unmarshaller;
24 import org.exolab.castor.xml.ValidationException;
25 import org.xml.sax.ContentHandler;
26
27 /***
28 * Ths list of applications that a Common Execution Controller
29 * Manages
30 *
31 * @version $Revision: 1.21 $ $Date: 2007/01/04 16:26:36 $
32 */
33 public class ManagedApplications extends org.astrogrid.common.bean.BaseBean
34 implements java.io.Serializable
35 {
36
37
38
39
40
41
42 /***
43 * Field _applicationReferenceList
44 */
45 private java.util.ArrayList _applicationReferenceList;
46
47
48
49
50
51
52 public ManagedApplications() {
53 super();
54 _applicationReferenceList = new ArrayList();
55 }
56
57
58
59
60
61
62 /***
63 * Method addApplicationReference
64 *
65 * @param vApplicationReference
66 */
67 public void addApplicationReference(org.astrogrid.registry.beans.resource.IdentifierType vApplicationReference)
68 throws java.lang.IndexOutOfBoundsException
69 {
70 _applicationReferenceList.add(vApplicationReference);
71 }
72
73 /***
74 * Method addApplicationReference
75 *
76 * @param index
77 * @param vApplicationReference
78 */
79 public void addApplicationReference(int index, org.astrogrid.registry.beans.resource.IdentifierType vApplicationReference)
80 throws java.lang.IndexOutOfBoundsException
81 {
82 _applicationReferenceList.add(index, vApplicationReference);
83 }
84
85 /***
86 * Method clearApplicationReference
87 */
88 public void clearApplicationReference()
89 {
90 _applicationReferenceList.clear();
91 }
92
93 /***
94 * Method enumerateApplicationReference
95 */
96 public java.util.Enumeration enumerateApplicationReference()
97 {
98 return new org.exolab.castor.util.IteratorEnumeration(_applicationReferenceList.iterator());
99 }
100
101 /***
102 * Note: hashCode() has not been overriden
103 *
104 * @param obj
105 */
106 public boolean equals(java.lang.Object obj)
107 {
108 if ( this == obj )
109 return true;
110
111 if (super.equals(obj)==false)
112 return false;
113
114 if (obj instanceof ManagedApplications) {
115
116 ManagedApplications temp = (ManagedApplications)obj;
117 if (this._applicationReferenceList != null) {
118 if (temp._applicationReferenceList == null) return false;
119 else if (!(this._applicationReferenceList.equals(temp._applicationReferenceList)))
120 return false;
121 }
122 else if (temp._applicationReferenceList != null)
123 return false;
124 return true;
125 }
126 return false;
127 }
128
129 /***
130 * Method getApplicationReference
131 *
132 * @param index
133 */
134 public org.astrogrid.registry.beans.resource.IdentifierType getApplicationReference(int index)
135 throws java.lang.IndexOutOfBoundsException
136 {
137
138 if ((index < 0) || (index > _applicationReferenceList.size())) {
139 throw new IndexOutOfBoundsException();
140 }
141
142 return (org.astrogrid.registry.beans.resource.IdentifierType) _applicationReferenceList.get(index);
143 }
144
145 /***
146 * Method getApplicationReference
147 */
148 public org.astrogrid.registry.beans.resource.IdentifierType[] getApplicationReference()
149 {
150 int size = _applicationReferenceList.size();
151 org.astrogrid.registry.beans.resource.IdentifierType[] mArray = new org.astrogrid.registry.beans.resource.IdentifierType[size];
152 for (int index = 0; index < size; index++) {
153 mArray[index] = (org.astrogrid.registry.beans.resource.IdentifierType) _applicationReferenceList.get(index);
154 }
155 return mArray;
156 }
157
158 /***
159 * Method getApplicationReferenceCount
160 */
161 public int getApplicationReferenceCount()
162 {
163 return _applicationReferenceList.size();
164 }
165
166 /***
167 * Method isValid
168 */
169 public boolean isValid()
170 {
171 try {
172 validate();
173 }
174 catch (org.exolab.castor.xml.ValidationException vex) {
175 return false;
176 }
177 return true;
178 }
179
180 /***
181 * Method marshal
182 *
183 * @param out
184 */
185 public void marshal(java.io.Writer out)
186 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
187 {
188
189 Marshaller.marshal(this, out);
190 }
191
192 /***
193 * Method marshal
194 *
195 * @param handler
196 */
197 public void marshal(org.xml.sax.ContentHandler handler)
198 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
199 {
200
201 Marshaller.marshal(this, handler);
202 }
203
204 /***
205 * Method removeApplicationReference
206 *
207 * @param vApplicationReference
208 */
209 public boolean removeApplicationReference(org.astrogrid.registry.beans.resource.IdentifierType vApplicationReference)
210 {
211 boolean removed = _applicationReferenceList.remove(vApplicationReference);
212 return removed;
213 }
214
215 /***
216 * Method setApplicationReference
217 *
218 * @param index
219 * @param vApplicationReference
220 */
221 public void setApplicationReference(int index, org.astrogrid.registry.beans.resource.IdentifierType vApplicationReference)
222 throws java.lang.IndexOutOfBoundsException
223 {
224
225 if ((index < 0) || (index > _applicationReferenceList.size())) {
226 throw new IndexOutOfBoundsException();
227 }
228 _applicationReferenceList.set(index, vApplicationReference);
229 }
230
231 /***
232 * Method setApplicationReference
233 *
234 * @param applicationReferenceArray
235 */
236 public void setApplicationReference(org.astrogrid.registry.beans.resource.IdentifierType[] applicationReferenceArray)
237 {
238
239 _applicationReferenceList.clear();
240 for (int i = 0; i < applicationReferenceArray.length; i++) {
241 _applicationReferenceList.add(applicationReferenceArray[i]);
242 }
243 }
244
245 /***
246 * Method unmarshalManagedApplications
247 *
248 * @param reader
249 */
250 public static org.astrogrid.registry.beans.cea.ManagedApplications unmarshalManagedApplications(java.io.Reader reader)
251 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
252 {
253 return (org.astrogrid.registry.beans.cea.ManagedApplications) Unmarshaller.unmarshal(org.astrogrid.registry.beans.cea.ManagedApplications.class, reader);
254 }
255
256 /***
257 * Method validate
258 */
259 public void validate()
260 throws org.exolab.castor.xml.ValidationException
261 {
262 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
263 validator.validate(this);
264 }
265
266 }