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;
24 * @version $Revision$ $Date$
26 public class PdbentryItem implements java.io.Serializable
29 // --------------------------/
30 // - Class/Member Variables -/
31 // --------------------------/
34 * Field _propertyList.
36 private java.util.Vector _propertyList;
45 this._propertyList = new java.util.Vector();
56 * @throws java.lang.IndexOutOfBoundsException
57 * if the index given is outside the bounds of the collection
59 public void addProperty(final jalview.binding.Property vProperty)
60 throws java.lang.IndexOutOfBoundsException
62 this._propertyList.addElement(vProperty);
70 * @throws java.lang.IndexOutOfBoundsException
71 * if the index given is outside the bounds of the collection
73 public void addProperty(final int index,
74 final jalview.binding.Property vProperty)
75 throws java.lang.IndexOutOfBoundsException
77 this._propertyList.add(index, vProperty);
81 * Method enumerateProperty.
83 * @return an Enumeration over all jalview.binding.Property elements
85 public java.util.Enumeration enumerateProperty()
87 return this._propertyList.elements();
94 * @throws java.lang.IndexOutOfBoundsException
95 * if the index given is outside the bounds of the collection
96 * @return the value of the jalview.binding.Property at the given index
98 public jalview.binding.Property getProperty(final int index)
99 throws java.lang.IndexOutOfBoundsException
101 // check bounds for index
102 if (index < 0 || index >= this._propertyList.size())
104 throw new IndexOutOfBoundsException("getProperty: Index value '"
105 + index + "' not in range [0.."
106 + (this._propertyList.size() - 1) + "]");
109 return (jalview.binding.Property) _propertyList.get(index);
113 * Method getProperty.Returns the contents of the collection in an Array.
115 * Note: Just in case the collection contents are changing in another thread,
116 * we pass a 0-length Array of the correct type into the API call. This way we
117 * <i>know</i> that the Array returned is of exactly the correct length.
119 * @return this collection as an Array
121 public jalview.binding.Property[] getProperty()
123 jalview.binding.Property[] array = new jalview.binding.Property[0];
124 return (jalview.binding.Property[]) this._propertyList.toArray(array);
128 * Method getPropertyCount.
130 * @return the size of this collection
132 public int getPropertyCount()
134 return this._propertyList.size();
139 public void removeAllProperty()
141 this._propertyList.clear();
145 * Method removeProperty.
148 * @return true if the object was removed from the collection.
150 public boolean removeProperty(final jalview.binding.Property vProperty)
152 boolean removed = _propertyList.remove(vProperty);
157 * Method removePropertyAt.
160 * @return the element removed from the collection
162 public jalview.binding.Property removePropertyAt(final int index)
164 java.lang.Object obj = this._propertyList.remove(index);
165 return (jalview.binding.Property) obj;
173 * @throws java.lang.IndexOutOfBoundsException
174 * if the index given is outside the bounds of the collection
176 public void setProperty(final int index,
177 final jalview.binding.Property vProperty)
178 throws java.lang.IndexOutOfBoundsException
180 // check bounds for index
181 if (index < 0 || index >= this._propertyList.size())
183 throw new IndexOutOfBoundsException("setProperty: Index value '"
184 + index + "' not in range [0.."
185 + (this._propertyList.size() - 1) + "]");
188 this._propertyList.set(index, vProperty);
194 * @param vPropertyArray
196 public void setProperty(final jalview.binding.Property[] vPropertyArray)
199 _propertyList.clear();
201 for (int i = 0; i < vPropertyArray.length; i++)
203 this._propertyList.add(vPropertyArray[i]);