Source code: org/biomage/BioAssayData/ReporterDimension.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 ReporterDimension
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.HasReporters;
63 import org.biomage.DesignElement.Reporter;
64
65 /**
66 * Specialized DesignElementDimension to hold Reporters.
67 *
68 */
69 public
70 class ReporterDimension
71 extends DesignElementDimension
72 implements Serializable,
73 HasReporters
74 {
75 /**
76 * The reporters for this dimension.
77 *
78 */
79 private Reporters_list reporters = new Reporters_list();
80
81 /**
82 * Default constructor.
83 *
84 */
85 public
86 ReporterDimension()
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 ReporterDimension(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("<ReporterDimension");
122 writeAttributes(out);
123 out.write(">");
124 writeAssociations(out);
125 out.write("</ReporterDimension>");
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 ( reporters.size() > 0 ){
161 out.write("<Reporters_assnreflist>");
162 for ( int i = 0; i < reporters.size(); i++) {
163 out.write("<Reporter_ref identifier=\"" + ((Reporter)reporters.elementAt(i)).getIdentifier() + "\"/>");
164 }
165 out.write("</Reporters_assnreflist>");
166 }
167 }
168
169 /**
170 * Set method for reporters
171 * <p>
172 * @param value to set
173 * <p>
174 *
175 */
176 public
177 void
178 setReporters(
179 Reporters_list reporters
180 )
181 {
182 ((List)this.reporters).addAll((List)reporters);
183 }
184
185 /**
186 * Get method for reporters
187 * <p>
188 * @return value of the attribute
189 * <p>
190 *
191 */
192 public
193 Reporters_list
194 getReporters()
195 {
196 return reporters;
197 }
198
199 /**
200 * Method to add Reporter to Reporters_list
201 *
202 */
203 public
204 void
205 addToReporters(
206 Reporter reporter
207 )
208 {
209 this.reporters.add(reporter);
210 }
211
212 /**
213 * Method to add Reporter at position to Reporters_list
214 *
215 */
216 public
217 void
218 addToReporters(
219 int position,
220 Reporter reporter
221 )
222 {
223 this.reporters.add(position, reporter);
224 }
225
226 /**
227 * Method to get Reporter from Reporters_list
228 *
229 */
230 public
231 Reporter
232 getFromReporters(
233 int position
234 )
235 {
236 return (Reporter) this.reporters.get(position);
237 }
238
239 /**
240 * Method to remove by position from Reporters_list
241 *
242 */
243 public
244 void
245 removeElementAtFromReporters(
246 int position
247 )
248 {
249 this.reporters.removeElementAt(position);
250 }
251
252 /**
253 * Method to remove first Reporter from Reporters_list
254 *
255 */
256 public
257 void
258 removeFromReporters(
259 Reporter reporter
260 )
261 {
262 this.reporters.remove(reporter);
263 }
264
265 }