View Javadoc

1   /*
2    * This class was automatically generated with 
3    * <a href="http://www.castor.org">Castor 0.9.4.3</a>, using an XML
4    * Schema.
5    * $Id: Registry.java,v 1.2 2007/01/04 16:26:34 clq2 Exp $
6    */
7   
8   package org.astrogrid.registry.beans.v10.resource.registry;
9   
10    //---------------------------------/
11   //- Imported classes and packages -/
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   * a service that provides access to descriptions of resources.
28   *  
29   * 
30   * @version $Revision: 1.2 $ $Date: 2007/01/04 16:26:34 $
31   */
32  public class Registry extends org.astrogrid.registry.beans.v10.resource.Service 
33  implements java.io.Serializable
34  {
35  
36  
37        //--------------------------/
38       //- Class/Member Variables -/
39      //--------------------------/
40  
41      /***
42       * an authority identifier managed by a registry.
43       *  
44       */
45      private java.util.ArrayList _managedAuthorityList;
46  
47  
48        //----------------/
49       //- Constructors -/
50      //----------------/
51  
52      public Registry() {
53          super();
54          _managedAuthorityList = new ArrayList();
55      } //-- org.astrogrid.registry.beans.v10.resource.registry.Registry()
56  
57  
58        //-----------/
59       //- Methods -/
60      //-----------/
61  
62      /***
63       * Method addManagedAuthority
64       * 
65       * @param vManagedAuthority
66       */
67      public void addManagedAuthority(java.lang.String vManagedAuthority)
68          throws java.lang.IndexOutOfBoundsException
69      {
70          _managedAuthorityList.add(vManagedAuthority);
71      } //-- void addManagedAuthority(java.lang.String) 
72  
73      /***
74       * Method addManagedAuthority
75       * 
76       * @param index
77       * @param vManagedAuthority
78       */
79      public void addManagedAuthority(int index, java.lang.String vManagedAuthority)
80          throws java.lang.IndexOutOfBoundsException
81      {
82          _managedAuthorityList.add(index, vManagedAuthority);
83      } //-- void addManagedAuthority(int, java.lang.String) 
84  
85      /***
86       * Method clearManagedAuthority
87       */
88      public void clearManagedAuthority()
89      {
90          _managedAuthorityList.clear();
91      } //-- void clearManagedAuthority() 
92  
93      /***
94       * Method enumerateManagedAuthority
95       */
96      public java.util.Enumeration enumerateManagedAuthority()
97      {
98          return new org.exolab.castor.util.IteratorEnumeration(_managedAuthorityList.iterator());
99      } //-- java.util.Enumeration enumerateManagedAuthority() 
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 Registry) {
115         
116             Registry temp = (Registry)obj;
117             if (this._managedAuthorityList != null) {
118                 if (temp._managedAuthorityList == null) return false;
119                 else if (!(this._managedAuthorityList.equals(temp._managedAuthorityList))) 
120                     return false;
121             }
122             else if (temp._managedAuthorityList != null)
123                 return false;
124             return true;
125         }
126         return false;
127     } //-- boolean equals(java.lang.Object) 
128 
129     /***
130      * Method getManagedAuthority
131      * 
132      * @param index
133      */
134     public java.lang.String getManagedAuthority(int index)
135         throws java.lang.IndexOutOfBoundsException
136     {
137         //-- check bounds for index
138         if ((index < 0) || (index > _managedAuthorityList.size())) {
139             throw new IndexOutOfBoundsException();
140         }
141         
142         return (String)_managedAuthorityList.get(index);
143     } //-- java.lang.String getManagedAuthority(int) 
144 
145     /***
146      * Method getManagedAuthority
147      */
148     public java.lang.String[] getManagedAuthority()
149     {
150         int size = _managedAuthorityList.size();
151         java.lang.String[] mArray = new java.lang.String[size];
152         for (int index = 0; index < size; index++) {
153             mArray[index] = (String)_managedAuthorityList.get(index);
154         }
155         return mArray;
156     } //-- java.lang.String[] getManagedAuthority() 
157 
158     /***
159      * Method getManagedAuthorityCount
160      */
161     public int getManagedAuthorityCount()
162     {
163         return _managedAuthorityList.size();
164     } //-- int getManagedAuthorityCount() 
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     } //-- boolean isValid() 
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     } //-- void marshal(java.io.Writer) 
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     } //-- void marshal(org.xml.sax.ContentHandler) 
203 
204     /***
205      * Method removeManagedAuthority
206      * 
207      * @param vManagedAuthority
208      */
209     public boolean removeManagedAuthority(java.lang.String vManagedAuthority)
210     {
211         boolean removed = _managedAuthorityList.remove(vManagedAuthority);
212         return removed;
213     } //-- boolean removeManagedAuthority(java.lang.String) 
214 
215     /***
216      * Method setManagedAuthority
217      * 
218      * @param index
219      * @param vManagedAuthority
220      */
221     public void setManagedAuthority(int index, java.lang.String vManagedAuthority)
222         throws java.lang.IndexOutOfBoundsException
223     {
224         //-- check bounds for index
225         if ((index < 0) || (index > _managedAuthorityList.size())) {
226             throw new IndexOutOfBoundsException();
227         }
228         _managedAuthorityList.set(index, vManagedAuthority);
229     } //-- void setManagedAuthority(int, java.lang.String) 
230 
231     /***
232      * Method setManagedAuthority
233      * 
234      * @param managedAuthorityArray
235      */
236     public void setManagedAuthority(java.lang.String[] managedAuthorityArray)
237     {
238         //-- copy array
239         _managedAuthorityList.clear();
240         for (int i = 0; i < managedAuthorityArray.length; i++) {
241             _managedAuthorityList.add(managedAuthorityArray[i]);
242         }
243     } //-- void setManagedAuthority(java.lang.String) 
244 
245     /***
246      * Method unmarshalRegistry
247      * 
248      * @param reader
249      */
250     public static org.astrogrid.registry.beans.v10.resource.registry.Registry unmarshalRegistry(java.io.Reader reader)
251         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
252     {
253         return (org.astrogrid.registry.beans.v10.resource.registry.Registry) Unmarshaller.unmarshal(org.astrogrid.registry.beans.v10.resource.registry.Registry.class, reader);
254     } //-- org.astrogrid.registry.beans.v10.resource.registry.Registry unmarshalRegistry(java.io.Reader) 
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     } //-- void validate() 
265 
266 }