apply gpl development license
[jalview.git] / src / jalview / binding / PdbentryItem.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3  * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
4  * 
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
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       //----------------/
40      //- Constructors -/
41     //----------------/
42
43     public PdbentryItem() {
44         super();
45         this._propertyList = new java.util.Vector();
46     }
47
48
49       //-----------/
50      //- Methods -/
51     //-----------/
52
53     /**
54      * 
55      * 
56      * @param vProperty
57      * @throws java.lang.IndexOutOfBoundsException if the index
58      * given is outside the bounds of the collection
59      */
60     public void addProperty(
61             final jalview.binding.Property vProperty)
62     throws java.lang.IndexOutOfBoundsException {
63         this._propertyList.addElement(vProperty);
64     }
65
66     /**
67      * 
68      * 
69      * @param index
70      * @param vProperty
71      * @throws java.lang.IndexOutOfBoundsException if the index
72      * given is outside the bounds of the collection
73      */
74     public void addProperty(
75             final int index,
76             final jalview.binding.Property vProperty)
77     throws java.lang.IndexOutOfBoundsException {
78         this._propertyList.add(index, vProperty);
79     }
80
81     /**
82      * Method enumerateProperty.
83      * 
84      * @return an Enumeration over all jalview.binding.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 if the index
97      * given is outside the bounds of the collection
98      * @return the value of the jalview.binding.Property at the
99      * given index
100      */
101     public jalview.binding.Property getProperty(
102             final int index)
103     throws java.lang.IndexOutOfBoundsException {
104         // check bounds for index
105         if (index < 0 || index >= this._propertyList.size()) {
106             throw new IndexOutOfBoundsException("getProperty: Index value '" + index + "' not in range [0.." + (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
114      * an Array.  <p>Note:  Just in case the collection contents
115      * are changing in another thread, we pass a 0-length Array of
116      * the correct type into the API call.  This way we <i>know</i>
117      * 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(
151             final jalview.binding.Property vProperty) {
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(
163             final int index) {
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 if the index
174      * given is outside the bounds of the collection
175      */
176     public void setProperty(
177             final int index,
178             final jalview.binding.Property vProperty)
179     throws java.lang.IndexOutOfBoundsException {
180         // check bounds for index
181         if (index < 0 || index >= this._propertyList.size()) {
182             throw new IndexOutOfBoundsException("setProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]");
183         }
184         
185         this._propertyList.set(index, vProperty);
186     }
187
188     /**
189      * 
190      * 
191      * @param vPropertyArray
192      */
193     public void setProperty(
194             final jalview.binding.Property[] vPropertyArray) {
195         //-- copy array
196         _propertyList.clear();
197         
198         for (int i = 0; i < vPropertyArray.length; i++) {
199                 this._propertyList.add(vPropertyArray[i]);
200         }
201     }
202
203 }