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