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