JAL-1620 version bump and release notes
[jalview.git] / src / jalview / schemabinding / version2 / PdbentryItem.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1)
3  * Copyright (C) 2014 The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
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.
11  *  
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.
16  * 
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.
20  */
21 package jalview.schemabinding.version2;
22
23 import jalview.util.MessageManager;
24
25 /**
26  * Class PdbentryItem.
27  * 
28  * @version $Revision$ $Date$
29  */
30 public class PdbentryItem implements java.io.Serializable
31 {
32
33   // --------------------------/
34   // - Class/Member Variables -/
35   // --------------------------/
36
37   /**
38    * Field _propertyList.
39    */
40   private java.util.Vector _propertyList;
41
42   // ----------------/
43   // - Constructors -/
44   // ----------------/
45
46   public PdbentryItem()
47   {
48     super();
49     this._propertyList = new java.util.Vector();
50   }
51
52   // -----------/
53   // - Methods -/
54   // -----------/
55
56   /**
57    * 
58    * 
59    * @param vProperty
60    * @throws java.lang.IndexOutOfBoundsException
61    *           if the index given is outside the bounds of the collection
62    */
63   public void addProperty(
64           final jalview.schemabinding.version2.Property vProperty)
65           throws java.lang.IndexOutOfBoundsException
66   {
67     this._propertyList.addElement(vProperty);
68   }
69
70   /**
71    * 
72    * 
73    * @param index
74    * @param vProperty
75    * @throws java.lang.IndexOutOfBoundsException
76    *           if the index given is outside the bounds of the collection
77    */
78   public void addProperty(final int index,
79           final jalview.schemabinding.version2.Property vProperty)
80           throws java.lang.IndexOutOfBoundsException
81   {
82     this._propertyList.add(index, vProperty);
83   }
84
85   /**
86    * Method enumerateProperty.
87    * 
88    * @return an Enumeration over all jalview.schemabinding.version2.Property
89    *         elements
90    */
91   public java.util.Enumeration enumerateProperty()
92   {
93     return this._propertyList.elements();
94   }
95
96   /**
97    * Method getProperty.
98    * 
99    * @param index
100    * @throws java.lang.IndexOutOfBoundsException
101    *           if the index given is outside the bounds of the collection
102    * @return the value of the jalview.schemabinding.version2.Property at the
103    *         given index
104    */
105   public jalview.schemabinding.version2.Property getProperty(final int index)
106           throws java.lang.IndexOutOfBoundsException
107   {
108     // check bounds for index
109     if (index < 0 || index >= this._propertyList.size())
110     {
111         throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
112                           "getProperty",
113                           Integer.valueOf(index).toString(),
114                           Integer.valueOf((this._propertyList.size() - 1)).toString()
115           })); 
116     }
117
118     return (jalview.schemabinding.version2.Property) _propertyList
119             .get(index);
120   }
121
122   /**
123    * Method getProperty.Returns the contents of the collection in an Array.
124    * <p>
125    * Note: Just in case the collection contents are changing in another thread,
126    * we pass a 0-length Array of the correct type into the API call. This way we
127    * <i>know</i> that the Array returned is of exactly the correct length.
128    * 
129    * @return this collection as an Array
130    */
131   public jalview.schemabinding.version2.Property[] getProperty()
132   {
133     jalview.schemabinding.version2.Property[] array = new jalview.schemabinding.version2.Property[0];
134     return (jalview.schemabinding.version2.Property[]) this._propertyList
135             .toArray(array);
136   }
137
138   /**
139    * Method getPropertyCount.
140    * 
141    * @return the size of this collection
142    */
143   public int getPropertyCount()
144   {
145     return this._propertyList.size();
146   }
147
148   /**
149      */
150   public void removeAllProperty()
151   {
152     this._propertyList.clear();
153   }
154
155   /**
156    * Method removeProperty.
157    * 
158    * @param vProperty
159    * @return true if the object was removed from the collection.
160    */
161   public boolean removeProperty(
162           final jalview.schemabinding.version2.Property vProperty)
163   {
164     boolean removed = _propertyList.remove(vProperty);
165     return removed;
166   }
167
168   /**
169    * Method removePropertyAt.
170    * 
171    * @param index
172    * @return the element removed from the collection
173    */
174   public jalview.schemabinding.version2.Property removePropertyAt(
175           final int index)
176   {
177     java.lang.Object obj = this._propertyList.remove(index);
178     return (jalview.schemabinding.version2.Property) obj;
179   }
180
181   /**
182    * 
183    * 
184    * @param index
185    * @param vProperty
186    * @throws java.lang.IndexOutOfBoundsException
187    *           if the index given is outside the bounds of the collection
188    */
189   public void setProperty(final int index,
190           final jalview.schemabinding.version2.Property vProperty)
191           throws java.lang.IndexOutOfBoundsException
192   {
193     // check bounds for index
194     if (index < 0 || index >= this._propertyList.size())
195     {
196         throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
197                   "setProperty",
198                   Integer.valueOf(index).toString(),
199                   Integer.valueOf((this._propertyList.size() - 1)).toString()
200         })); 
201     }
202
203     this._propertyList.set(index, vProperty);
204   }
205
206   /**
207    * 
208    * 
209    * @param vPropertyArray
210    */
211   public void setProperty(
212           final jalview.schemabinding.version2.Property[] vPropertyArray)
213   {
214     // -- copy array
215     _propertyList.clear();
216
217     for (int i = 0; i < vPropertyArray.length; i++)
218     {
219       this._propertyList.add(vPropertyArray[i]);
220     }
221   }
222
223 }