2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3 * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
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
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 package jalview.binding;
21 // ---------------------------------/
22 // - Imported classes and packages -/
23 // ---------------------------------/
25 import org.exolab.castor.xml.Marshaller;
26 import org.exolab.castor.xml.Unmarshaller;
31 * @version $Revision$ $Date$
33 public class Pdbentry implements java.io.Serializable
36 // --------------------------/
37 // - Class/Member Variables -/
38 // --------------------------/
43 private java.lang.String _id;
48 private java.lang.String _type;
53 private java.util.Vector _items;
62 this._items = new java.util.Vector();
72 * @param vPdbentryItem
73 * @throws java.lang.IndexOutOfBoundsException
74 * if the index given is outside the bounds of the collection
76 public void addPdbentryItem(
77 final jalview.binding.PdbentryItem vPdbentryItem)
78 throws java.lang.IndexOutOfBoundsException
80 this._items.addElement(vPdbentryItem);
87 * @param vPdbentryItem
88 * @throws java.lang.IndexOutOfBoundsException
89 * if the index given is outside the bounds of the collection
91 public void addPdbentryItem(final int index,
92 final jalview.binding.PdbentryItem vPdbentryItem)
93 throws java.lang.IndexOutOfBoundsException
95 this._items.add(index, vPdbentryItem);
99 * Method enumeratePdbentryItem.
101 * @return an Enumeration over all jalview.binding.PdbentryItem elements
103 public java.util.Enumeration enumeratePdbentryItem()
105 return this._items.elements();
109 * Returns the value of field 'id'.
111 * @return the value of field 'Id'.
113 public java.lang.String getId()
119 * Method getPdbentryItem.
122 * @throws java.lang.IndexOutOfBoundsException
123 * if the index given is outside the bounds of the collection
124 * @return the value of the jalview.binding.PdbentryItem at the given index
126 public jalview.binding.PdbentryItem getPdbentryItem(final int index)
127 throws java.lang.IndexOutOfBoundsException
129 // check bounds for index
130 if (index < 0 || index >= this._items.size())
132 throw new IndexOutOfBoundsException("getPdbentryItem: Index value '"
133 + index + "' not in range [0.." + (this._items.size() - 1)
137 return (jalview.binding.PdbentryItem) _items.get(index);
141 * Method getPdbentryItem.Returns the contents of the collection in an Array.
143 * Note: Just in case the collection contents are changing in another thread,
144 * we pass a 0-length Array of the correct type into the API call. This way we
145 * <i>know</i> that the Array returned is of exactly the correct length.
147 * @return this collection as an Array
149 public jalview.binding.PdbentryItem[] getPdbentryItem()
151 jalview.binding.PdbentryItem[] array = new jalview.binding.PdbentryItem[0];
152 return (jalview.binding.PdbentryItem[]) this._items.toArray(array);
156 * Method getPdbentryItemCount.
158 * @return the size of this collection
160 public int getPdbentryItemCount()
162 return this._items.size();
166 * Returns the value of field 'type'.
168 * @return the value of field 'Type'.
170 public java.lang.String getType()
178 * @return true if this object is valid according to the schema
180 public boolean isValid()
185 } catch (org.exolab.castor.xml.ValidationException vex)
196 * @throws org.exolab.castor.xml.MarshalException
197 * if object is null or if any SAXException is thrown during
199 * @throws org.exolab.castor.xml.ValidationException
200 * if this object is an invalid instance according to the
203 public void marshal(final java.io.Writer out)
204 throws org.exolab.castor.xml.MarshalException,
205 org.exolab.castor.xml.ValidationException
207 Marshaller.marshal(this, out);
214 * @throws java.io.IOException
215 * if an IOException occurs during marshaling
216 * @throws org.exolab.castor.xml.ValidationException
217 * if this object is an invalid instance according to the
219 * @throws org.exolab.castor.xml.MarshalException
220 * if object is null or if any SAXException is thrown during
223 public void marshal(final org.xml.sax.ContentHandler handler)
224 throws java.io.IOException,
225 org.exolab.castor.xml.MarshalException,
226 org.exolab.castor.xml.ValidationException
228 Marshaller.marshal(this, handler);
233 public void removeAllPdbentryItem()
239 * Method removePdbentryItem.
241 * @param vPdbentryItem
242 * @return true if the object was removed from the collection.
244 public boolean removePdbentryItem(
245 final jalview.binding.PdbentryItem vPdbentryItem)
247 boolean removed = _items.remove(vPdbentryItem);
252 * Method removePdbentryItemAt.
255 * @return the element removed from the collection
257 public jalview.binding.PdbentryItem removePdbentryItemAt(final int index)
259 java.lang.Object obj = this._items.remove(index);
260 return (jalview.binding.PdbentryItem) obj;
264 * Sets the value of field 'id'.
267 * the value of field 'id'.
269 public void setId(final java.lang.String id)
278 * @param vPdbentryItem
279 * @throws java.lang.IndexOutOfBoundsException
280 * if the index given is outside the bounds of the collection
282 public void setPdbentryItem(final int index,
283 final jalview.binding.PdbentryItem vPdbentryItem)
284 throws java.lang.IndexOutOfBoundsException
286 // check bounds for index
287 if (index < 0 || index >= this._items.size())
289 throw new IndexOutOfBoundsException("setPdbentryItem: Index value '"
290 + index + "' not in range [0.." + (this._items.size() - 1)
294 this._items.set(index, vPdbentryItem);
300 * @param vPdbentryItemArray
302 public void setPdbentryItem(
303 final jalview.binding.PdbentryItem[] vPdbentryItemArray)
308 for (int i = 0; i < vPdbentryItemArray.length; i++)
310 this._items.add(vPdbentryItemArray[i]);
315 * Sets the value of field 'type'.
318 * the value of field 'type'.
320 public void setType(final java.lang.String type)
329 * @throws org.exolab.castor.xml.MarshalException
330 * if object is null or if any SAXException is thrown during
332 * @throws org.exolab.castor.xml.ValidationException
333 * if this object is an invalid instance according to the
335 * @return the unmarshaled jalview.binding.Pdbentry
337 public static jalview.binding.Pdbentry unmarshal(
338 final java.io.Reader reader)
339 throws org.exolab.castor.xml.MarshalException,
340 org.exolab.castor.xml.ValidationException
342 return (jalview.binding.Pdbentry) Unmarshaller.unmarshal(
343 jalview.binding.Pdbentry.class, reader);
349 * @throws org.exolab.castor.xml.ValidationException
350 * if this object is an invalid instance according to the
353 public void validate() throws org.exolab.castor.xml.ValidationException
355 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
356 validator.validate(this);