2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.binding;
23 //---------------------------------/
24 //- Imported classes and packages -/
25 //---------------------------------/
27 import jalview.util.MessageManager;
29 import org.exolab.castor.xml.Marshaller;
30 import org.exolab.castor.xml.Unmarshaller;
35 * @version $Revision$ $Date$
37 public class Pdbentry implements java.io.Serializable
40 // --------------------------/
41 // - Class/Member Variables -/
42 // --------------------------/
47 private java.lang.String _id;
52 private java.lang.String _type;
57 private java.util.Vector _items;
66 this._items = new java.util.Vector();
76 * @param vPdbentryItem
77 * @throws java.lang.IndexOutOfBoundsException
78 * if the index given is outside the bounds of the collection
80 public void addPdbentryItem(
81 final jalview.binding.PdbentryItem vPdbentryItem)
82 throws java.lang.IndexOutOfBoundsException
84 this._items.addElement(vPdbentryItem);
91 * @param vPdbentryItem
92 * @throws java.lang.IndexOutOfBoundsException
93 * if the index given is outside the bounds of the collection
95 public void addPdbentryItem(final int index,
96 final jalview.binding.PdbentryItem vPdbentryItem)
97 throws java.lang.IndexOutOfBoundsException
99 this._items.add(index, vPdbentryItem);
103 * Method enumeratePdbentryItem.
105 * @return an Enumeration over all jalview.binding.PdbentryItem elements
107 public java.util.Enumeration enumeratePdbentryItem()
109 return this._items.elements();
113 * Returns the value of field 'id'.
115 * @return the value of field 'Id'.
117 public java.lang.String getId()
123 * Method getPdbentryItem.
126 * @throws java.lang.IndexOutOfBoundsException
127 * if the index given is outside the bounds of the collection
128 * @return the value of the jalview.binding.PdbentryItem at the given index
130 public jalview.binding.PdbentryItem getPdbentryItem(final int index)
131 throws java.lang.IndexOutOfBoundsException
133 // check bounds for index
134 if (index < 0 || index >= this._items.size())
136 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
138 Integer.valueOf(index).toString(),
139 Integer.valueOf((this._items.size() - 1)).toString()
143 return (jalview.binding.PdbentryItem) _items.get(index);
147 * Method getPdbentryItem.Returns the contents of the collection in an Array.
149 * Note: Just in case the collection contents are changing in another thread,
150 * we pass a 0-length Array of the correct type into the API call. This way we
151 * <i>know</i> that the Array returned is of exactly the correct length.
153 * @return this collection as an Array
155 public jalview.binding.PdbentryItem[] getPdbentryItem()
157 jalview.binding.PdbentryItem[] array = new jalview.binding.PdbentryItem[0];
158 return (jalview.binding.PdbentryItem[]) this._items.toArray(array);
162 * Method getPdbentryItemCount.
164 * @return the size of this collection
166 public int getPdbentryItemCount()
168 return this._items.size();
172 * Returns the value of field 'type'.
174 * @return the value of field 'Type'.
176 public java.lang.String getType()
184 * @return true if this object is valid according to the schema
186 public boolean isValid()
191 } catch (org.exolab.castor.xml.ValidationException vex)
202 * @throws org.exolab.castor.xml.MarshalException
203 * if object is null or if any SAXException is thrown during
205 * @throws org.exolab.castor.xml.ValidationException
206 * if this object is an invalid instance according to the schema
208 public void marshal(final java.io.Writer out)
209 throws org.exolab.castor.xml.MarshalException,
210 org.exolab.castor.xml.ValidationException
212 Marshaller.marshal(this, out);
219 * @throws java.io.IOException
220 * if an IOException occurs during marshaling
221 * @throws org.exolab.castor.xml.ValidationException
222 * if this object is an invalid instance according to the schema
223 * @throws org.exolab.castor.xml.MarshalException
224 * if object is null or if any SAXException is thrown during
227 public void marshal(final org.xml.sax.ContentHandler handler)
228 throws java.io.IOException,
229 org.exolab.castor.xml.MarshalException,
230 org.exolab.castor.xml.ValidationException
232 Marshaller.marshal(this, handler);
237 public void removeAllPdbentryItem()
243 * Method removePdbentryItem.
245 * @param vPdbentryItem
246 * @return true if the object was removed from the collection.
248 public boolean removePdbentryItem(
249 final jalview.binding.PdbentryItem vPdbentryItem)
251 boolean removed = _items.remove(vPdbentryItem);
256 * Method removePdbentryItemAt.
259 * @return the element removed from the collection
261 public jalview.binding.PdbentryItem removePdbentryItemAt(final int index)
263 java.lang.Object obj = this._items.remove(index);
264 return (jalview.binding.PdbentryItem) obj;
268 * Sets the value of field 'id'.
271 * the value of field 'id'.
273 public void setId(final java.lang.String id)
282 * @param vPdbentryItem
283 * @throws java.lang.IndexOutOfBoundsException
284 * if the index given is outside the bounds of the collection
286 public void setPdbentryItem(final int index,
287 final jalview.binding.PdbentryItem vPdbentryItem)
288 throws java.lang.IndexOutOfBoundsException
290 // check bounds for index
291 if (index < 0 || index >= this._items.size())
293 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
295 Integer.valueOf(index).toString(),
296 Integer.valueOf((this._items.size() - 1)).toString()
300 this._items.set(index, vPdbentryItem);
306 * @param vPdbentryItemArray
308 public void setPdbentryItem(
309 final jalview.binding.PdbentryItem[] vPdbentryItemArray)
314 for (int i = 0; i < vPdbentryItemArray.length; i++)
316 this._items.add(vPdbentryItemArray[i]);
321 * Sets the value of field 'type'.
324 * the value of field 'type'.
326 public void setType(final java.lang.String type)
335 * @throws org.exolab.castor.xml.MarshalException
336 * if object is null or if any SAXException is thrown during
338 * @throws org.exolab.castor.xml.ValidationException
339 * if this object is an invalid instance according to the schema
340 * @return the unmarshaled jalview.binding.Pdbentry
342 public static jalview.binding.Pdbentry unmarshal(
343 final java.io.Reader reader)
344 throws org.exolab.castor.xml.MarshalException,
345 org.exolab.castor.xml.ValidationException
347 return (jalview.binding.Pdbentry) Unmarshaller.unmarshal(
348 jalview.binding.Pdbentry.class, reader);
354 * @throws org.exolab.castor.xml.ValidationException
355 * if this object is an invalid instance according to the schema
357 public void validate() throws org.exolab.castor.xml.ValidationException
359 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
360 validator.validate(this);