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