Source code: org/biomage/BioAssayData/FeatureDimension.java
1 /***************************************************************************
2 * *
3 * C O P Y R I G H T N O T I C E *
4 * Copyright (c) 2001 by: *
5 * * The MicroArray Gene Expression Database group (MGED) *
6 * * Rosetta Inpharmatics *
7 * *
8 * All Rights Reserved. *
9 * *
10 * Permission is hereby granted, free of charge, to any person *
11 * obtaining a copy of this software and associated documentation files *
12 * (the "Software"), to deal in the Software without restriction, *
13 * including without limitation the rights to use, copy, modify, merge, *
14 * publish, distribute, sublicense, and/or sell copies of the Software, *
15 * and to permit persons to whom the Software is furnished to do so, *
16 * subject to the following conditions: *
17 * *
18 * The above copyright notice and this permission notice shall be *
19 * included in all copies or substantial portions of the Software. *
20 * *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *
25 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *
26 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *
28 * SOFTWARE. *
29 ***************************************************************************
30 * *
31 * Created by the create_mage_java_classes java program based on the *
32 * information in the xmi file created from the MAGE-OM UML model, *
33 * copyright European Bioinformatics Institute (EBI) for MGED and Rosetta *
34 * Informatics. *
35 * *
36 * The ideas and work are built on the previous work in perl of Jason *
37 * Stewart, Open Informatics, and Robert M. Hubley, Institute for Systems *
38 * Biology *
39 * *
40 * @author Michael Miller, Rosetta Inpharmatics *
41 * @version Revision: 1.0 *
42 * @date Thu, Feb 21, 2002 10:46:25 AM *
43 * *
44 ***************************************************************************
45 */
46
47 /**
48 * org.biomage.BioAssayData
49 *
50 */
51 package org.biomage.BioAssayData;
52
53 /**
54 * Import list for FeatureDimension
55 *
56 */
57 import java.io.Serializable;
58 import java.util.*;
59 import org.xml.sax.Attributes;
60 import java.io.Writer;
61 import java.io.IOException;
62 import org.biomage.Interface.HasContainedFeatures;
63 import org.biomage.DesignElement.Feature;
64
65 /**
66 * Specialized DesignElementDimension to hold Features.
67 *
68 */
69 public
70 class FeatureDimension
71 extends DesignElementDimension
72 implements Serializable,
73 HasContainedFeatures
74 {
75 /**
76 * The features for this dimension.
77 *
78 */
79 private ContainedFeatures_list containedFeatures = new ContainedFeatures_list();
80
81 /**
82 * Default constructor.
83 *
84 */
85 public
86 FeatureDimension()
87 {
88 super();
89 }
90
91 /**
92 * Attribute constructor.
93 *
94 * Looks up the attributes in the parameter and casts them from strings
95 * appropriately
96 * @param atts: the attribute list.
97 *
98 */
99 // TODO Work in progress (attribute constructor).
100 public
101 FeatureDimension(Attributes atts)
102 {
103 super(atts);
104
105 }
106
107 /**
108 * writeMAGEML
109 * <p>
110 * This method is responsible for assembling the attribute and
111 * association data into XML. It creates the object tag and then calls
112 * the writeAttributes and writeAssociation methods.
113 * <p>
114 *
115 */
116 public
117 void
118 writeMAGEML(Writer out)
119 throws IOException
120 {
121 out.write("<FeatureDimension");
122 writeAttributes(out);
123 out.write(">");
124 writeAssociations(out);
125 out.write("</FeatureDimension>");
126 }
127
128 /**
129 * writeAttributes
130 * <p>
131 * This method is responsible for assembling the attribute data into
132 * XML. It calls the super method to write out all attributes of this
133 * class and it's ancestors.
134 * <p>
135 *
136 */
137 public
138 void
139 writeAttributes(Writer out)
140 throws IOException
141 {
142 super.writeAttributes(out);
143 }
144
145 /**
146 * writeAssociations
147 * <p>
148 * This method is responsible for assembling the association data
149 * into XML. It calls the super method to write out all associations of
150 * this class's ancestors.
151 * <p>
152 *
153 */
154 public
155 void
156 writeAssociations(Writer out)
157 throws IOException
158 {
159 super.writeAssociations(out);
160 if ( containedFeatures.size() > 0 ){
161 out.write("<ContainedFeatures_assnreflist>");
162 for ( int i = 0; i < containedFeatures.size(); i++) {
163 out.write("<Feature_ref identifier=\"" + ((Feature)containedFeatures.elementAt(i)).getIdentifier() + "\"/>");
164 }
165 out.write("</ContainedFeatures_assnreflist>");
166 }
167 }
168
169 /**
170 * Set method for containedFeatures
171 * <p>
172 * @param value to set
173 * <p>
174 *
175 */
176 public
177 void
178 setContainedFeatures(
179 ContainedFeatures_list containedFeatures
180 )
181 {
182 ((List)this.containedFeatures).addAll((List)containedFeatures);
183 }
184
185 /**
186 * Get method for containedFeatures
187 * <p>
188 * @return value of the attribute
189 * <p>
190 *
191 */
192 public
193 ContainedFeatures_list
194 getContainedFeatures()
195 {
196 return containedFeatures;
197 }
198
199 /**
200 * Method to add Feature to ContainedFeatures_list
201 *
202 */
203 public
204 void
205 addToContainedFeatures(
206 Feature feature
207 )
208 {
209 this.containedFeatures.add(feature);
210 }
211
212 /**
213 * Method to add Feature at position to ContainedFeatures_list
214 *
215 */
216 public
217 void
218 addToContainedFeatures(
219 int position,
220 Feature feature
221 )
222 {
223 this.containedFeatures.add(position, feature);
224 }
225
226 /**
227 * Method to get Feature from ContainedFeatures_list
228 *
229 */
230 public
231 Feature
232 getFromContainedFeatures(
233 int position
234 )
235 {
236 return (Feature) this.containedFeatures.get(position);
237 }
238
239 /**
240 * Method to remove by position from ContainedFeatures_list
241 *
242 */
243 public
244 void
245 removeElementAtFromContainedFeatures(
246 int position
247 )
248 {
249 this.containedFeatures.removeElementAt(position);
250 }
251
252 /**
253 * Method to remove first Feature from ContainedFeatures_list
254 *
255 */
256 public
257 void
258 removeFromContainedFeatures(
259 Feature feature
260 )
261 {
262 this.containedFeatures.remove(feature);
263 }
264
265 }