JAL-1432 updated copyright notices
[jalview.git] / src / jalview / binding / 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.binding;
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(final jalview.binding.Property vProperty)
60           throws java.lang.IndexOutOfBoundsException
61   {
62     this._propertyList.addElement(vProperty);
63   }
64
65   /**
66    * 
67    * 
68    * @param index
69    * @param vProperty
70    * @throws java.lang.IndexOutOfBoundsException
71    *           if the index given is outside the bounds of the collection
72    */
73   public void addProperty(final int index,
74           final jalview.binding.Property vProperty)
75           throws java.lang.IndexOutOfBoundsException
76   {
77     this._propertyList.add(index, vProperty);
78   }
79
80   /**
81    * Method enumerateProperty.
82    * 
83    * @return an Enumeration over all jalview.binding.Property elements
84    */
85   public java.util.Enumeration enumerateProperty()
86   {
87     return this._propertyList.elements();
88   }
89
90   /**
91    * Method getProperty.
92    * 
93    * @param index
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
97    */
98   public jalview.binding.Property getProperty(final int index)
99           throws java.lang.IndexOutOfBoundsException
100   {
101     // check bounds for index
102     if (index < 0 || index >= this._propertyList.size())
103     {
104       throw new IndexOutOfBoundsException("getProperty: Index value '"
105               + index + "' not in range [0.."
106               + (this._propertyList.size() - 1) + "]");
107     }
108
109     return (jalview.binding.Property) _propertyList.get(index);
110   }
111
112   /**
113    * Method getProperty.Returns the contents of the collection in an Array.
114    * <p>
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.
118    * 
119    * @return this collection as an Array
120    */
121   public jalview.binding.Property[] getProperty()
122   {
123     jalview.binding.Property[] array = new jalview.binding.Property[0];
124     return (jalview.binding.Property[]) this._propertyList.toArray(array);
125   }
126
127   /**
128    * Method getPropertyCount.
129    * 
130    * @return the size of this collection
131    */
132   public int getPropertyCount()
133   {
134     return this._propertyList.size();
135   }
136
137   /**
138      */
139   public void removeAllProperty()
140   {
141     this._propertyList.clear();
142   }
143
144   /**
145    * Method removeProperty.
146    * 
147    * @param vProperty
148    * @return true if the object was removed from the collection.
149    */
150   public boolean removeProperty(final jalview.binding.Property vProperty)
151   {
152     boolean removed = _propertyList.remove(vProperty);
153     return removed;
154   }
155
156   /**
157    * Method removePropertyAt.
158    * 
159    * @param index
160    * @return the element removed from the collection
161    */
162   public jalview.binding.Property removePropertyAt(final int index)
163   {
164     java.lang.Object obj = this._propertyList.remove(index);
165     return (jalview.binding.Property) obj;
166   }
167
168   /**
169    * 
170    * 
171    * @param index
172    * @param vProperty
173    * @throws java.lang.IndexOutOfBoundsException
174    *           if the index given is outside the bounds of the collection
175    */
176   public void setProperty(final int index,
177           final jalview.binding.Property vProperty)
178           throws java.lang.IndexOutOfBoundsException
179   {
180     // check bounds for index
181     if (index < 0 || index >= this._propertyList.size())
182     {
183       throw new IndexOutOfBoundsException("setProperty: Index value '"
184               + index + "' not in range [0.."
185               + (this._propertyList.size() - 1) + "]");
186     }
187
188     this._propertyList.set(index, vProperty);
189   }
190
191   /**
192    * 
193    * 
194    * @param vPropertyArray
195    */
196   public void setProperty(final jalview.binding.Property[] vPropertyArray)
197   {
198     // -- copy array
199     _propertyList.clear();
200
201     for (int i = 0; i < vPropertyArray.length; i++)
202     {
203       this._propertyList.add(vPropertyArray[i]);
204     }
205   }
206
207 }