Jalview 2.6 source licence
[jalview.git] / src / jalview / schemabinding / version2 / PdbentryItem.java
1 /*\r
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)\r
3  * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle\r
4  * \r
5  * This file is part of Jalview.\r
6  * \r
7  * Jalview is free software: you can redistribute it and/or\r
8  * modify it under the terms of the GNU General Public License \r
9  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\r
10  * \r
11  * Jalview is distributed in the hope that it will be useful, but \r
12  * WITHOUT ANY WARRANTY; without even the implied warranty \r
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR \r
14  * PURPOSE.  See the GNU General Public License for more details.\r
15  * \r
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.\r
17  */\r
18 package jalview.schemabinding.version2;\r
19 \r
20 /**\r
21  * Class PdbentryItem.\r
22  * \r
23  * @version $Revision$ $Date$\r
24  */\r
25 public class PdbentryItem implements java.io.Serializable\r
26 {\r
27 \r
28   // --------------------------/\r
29   // - Class/Member Variables -/\r
30   // --------------------------/\r
31 \r
32   /**\r
33    * Field _propertyList.\r
34    */\r
35   private java.util.Vector _propertyList;\r
36 \r
37   // ----------------/\r
38   // - Constructors -/\r
39   // ----------------/\r
40 \r
41   public PdbentryItem()\r
42   {\r
43     super();\r
44     this._propertyList = new java.util.Vector();\r
45   }\r
46 \r
47   // -----------/\r
48   // - Methods -/\r
49   // -----------/\r
50 \r
51   /**\r
52    * \r
53    * \r
54    * @param vProperty\r
55    * @throws java.lang.IndexOutOfBoundsException\r
56    *           if the index given is outside the bounds of the collection\r
57    */\r
58   public void addProperty(\r
59           final jalview.schemabinding.version2.Property vProperty)\r
60           throws java.lang.IndexOutOfBoundsException\r
61   {\r
62     this._propertyList.addElement(vProperty);\r
63   }\r
64 \r
65   /**\r
66    * \r
67    * \r
68    * @param index\r
69    * @param vProperty\r
70    * @throws java.lang.IndexOutOfBoundsException\r
71    *           if the index given is outside the bounds of the collection\r
72    */\r
73   public void addProperty(final int index,\r
74           final jalview.schemabinding.version2.Property vProperty)\r
75           throws java.lang.IndexOutOfBoundsException\r
76   {\r
77     this._propertyList.add(index, vProperty);\r
78   }\r
79 \r
80   /**\r
81    * Method enumerateProperty.\r
82    * \r
83    * @return an Enumeration over all jalview.schemabinding.version2.Property\r
84    *         elements\r
85    */\r
86   public java.util.Enumeration enumerateProperty()\r
87   {\r
88     return this._propertyList.elements();\r
89   }\r
90 \r
91   /**\r
92    * Method getProperty.\r
93    * \r
94    * @param index\r
95    * @throws java.lang.IndexOutOfBoundsException\r
96    *           if the index given is outside the bounds of the collection\r
97    * @return the value of the jalview.schemabinding.version2.Property at the\r
98    *         given index\r
99    */\r
100   public jalview.schemabinding.version2.Property getProperty(final int index)\r
101           throws java.lang.IndexOutOfBoundsException\r
102   {\r
103     // check bounds for index\r
104     if (index < 0 || index >= this._propertyList.size())\r
105     {\r
106       throw new IndexOutOfBoundsException("getProperty: Index value '"\r
107               + index + "' not in range [0.."\r
108               + (this._propertyList.size() - 1) + "]");\r
109     }\r
110 \r
111     return (jalview.schemabinding.version2.Property) _propertyList\r
112             .get(index);\r
113   }\r
114 \r
115   /**\r
116    * Method getProperty.Returns the contents of the collection in an Array.\r
117    * <p>\r
118    * Note: Just in case the collection contents are changing in another thread,\r
119    * we pass a 0-length Array of the correct type into the API call. This way we\r
120    * <i>know</i> that the Array returned is of exactly the correct length.\r
121    * \r
122    * @return this collection as an Array\r
123    */\r
124   public jalview.schemabinding.version2.Property[] getProperty()\r
125   {\r
126     jalview.schemabinding.version2.Property[] array = new jalview.schemabinding.version2.Property[0];\r
127     return (jalview.schemabinding.version2.Property[]) this._propertyList\r
128             .toArray(array);\r
129   }\r
130 \r
131   /**\r
132    * Method getPropertyCount.\r
133    * \r
134    * @return the size of this collection\r
135    */\r
136   public int getPropertyCount()\r
137   {\r
138     return this._propertyList.size();\r
139   }\r
140 \r
141   /**\r
142      */\r
143   public void removeAllProperty()\r
144   {\r
145     this._propertyList.clear();\r
146   }\r
147 \r
148   /**\r
149    * Method removeProperty.\r
150    * \r
151    * @param vProperty\r
152    * @return true if the object was removed from the collection.\r
153    */\r
154   public boolean removeProperty(\r
155           final jalview.schemabinding.version2.Property vProperty)\r
156   {\r
157     boolean removed = _propertyList.remove(vProperty);\r
158     return removed;\r
159   }\r
160 \r
161   /**\r
162    * Method removePropertyAt.\r
163    * \r
164    * @param index\r
165    * @return the element removed from the collection\r
166    */\r
167   public jalview.schemabinding.version2.Property removePropertyAt(\r
168           final int index)\r
169   {\r
170     java.lang.Object obj = this._propertyList.remove(index);\r
171     return (jalview.schemabinding.version2.Property) obj;\r
172   }\r
173 \r
174   /**\r
175    * \r
176    * \r
177    * @param index\r
178    * @param vProperty\r
179    * @throws java.lang.IndexOutOfBoundsException\r
180    *           if the index given is outside the bounds of the collection\r
181    */\r
182   public void setProperty(final int index,\r
183           final jalview.schemabinding.version2.Property vProperty)\r
184           throws java.lang.IndexOutOfBoundsException\r
185   {\r
186     // check bounds for index\r
187     if (index < 0 || index >= this._propertyList.size())\r
188     {\r
189       throw new IndexOutOfBoundsException("setProperty: Index value '"\r
190               + index + "' not in range [0.."\r
191               + (this._propertyList.size() - 1) + "]");\r
192     }\r
193 \r
194     this._propertyList.set(index, vProperty);\r
195   }\r
196 \r
197   /**\r
198    * \r
199    * \r
200    * @param vPropertyArray\r
201    */\r
202   public void setProperty(\r
203           final jalview.schemabinding.version2.Property[] vPropertyArray)\r
204   {\r
205     // -- copy array\r
206     _propertyList.clear();\r
207 \r
208     for (int i = 0; i < vPropertyArray.length; i++)\r
209     {\r
210       this._propertyList.add(vPropertyArray[i]);\r
211     }\r
212   }\r
213 \r
214 }\r