Source code: org/biomage/BioAssayData/BioDataTuples.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:20 AM *
43 * *
44 ***************************************************************************
45 */
46
47 /**
48 * org.biomage.BioAssayData
49 *
50 */
51 package org.biomage.BioAssayData;
52
53 /**
54 * Import list for BioDataTuples
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.HasBioAssayTupleData;
63
64 /**
65 * A relational, tuple representation of the data.
66 *
67 */
68 public
69 class BioDataTuples
70 extends BioDataValues
71 implements Serializable,
72 HasBioAssayTupleData
73 {
74 /**
75 * The collection of BioAssayData tuples.
76 *
77 */
78 private BioAssayTupleData_list bioAssayTupleData = new BioAssayTupleData_list();
79
80 /**
81 * Default constructor.
82 *
83 */
84 public
85 BioDataTuples()
86 {
87 super();
88 }
89
90 /**
91 * Attribute constructor.
92 *
93 * Looks up the attributes in the parameter and casts them from strings
94 * appropriately
95 * @param atts: the attribute list.
96 *
97 */
98 // TODO Work in progress (attribute constructor).
99 public
100 BioDataTuples(Attributes atts)
101 {
102 super(atts);
103
104 }
105
106 /**
107 * writeMAGEML
108 * <p>
109 * This method is responsible for assembling the attribute and
110 * association data into XML. It creates the object tag and then calls
111 * the writeAttributes and writeAssociation methods.
112 * <p>
113 *
114 */
115 public
116 void
117 writeMAGEML(Writer out)
118 throws IOException
119 {
120 out.write("<BioDataTuples");
121 writeAttributes(out);
122 out.write(">");
123 writeAssociations(out);
124 out.write("</BioDataTuples>");
125 }
126
127 /**
128 * writeAttributes
129 * <p>
130 * This method is responsible for assembling the attribute data into
131 * XML. It calls the super method to write out all attributes of this
132 * class and it's ancestors.
133 * <p>
134 *
135 */
136 public
137 void
138 writeAttributes(Writer out)
139 throws IOException
140 {
141 super.writeAttributes(out);
142 }
143
144 /**
145 * writeAssociations
146 * <p>
147 * This method is responsible for assembling the association data
148 * into XML. It calls the super method to write out all associations of
149 * this class's ancestors.
150 * <p>
151 *
152 */
153 public
154 void
155 writeAssociations(Writer out)
156 throws IOException
157 {
158 super.writeAssociations(out);
159 if ( bioAssayTupleData.size() > 0 ){
160 out.write("<BioAssayTupleData_assnlist>");
161 for ( int i = 0; i < bioAssayTupleData.size(); i++) {
162 ((BioAssayDatum)bioAssayTupleData.elementAt(i)).writeMAGEML(out);
163 }
164 out.write("</BioAssayTupleData_assnlist>");
165 }
166 }
167
168 /**
169 * Set method for bioAssayTupleData
170 * <p>
171 * @param value to set
172 * <p>
173 *
174 */
175 public
176 void
177 setBioAssayTupleData(
178 BioAssayTupleData_list bioAssayTupleData
179 )
180 {
181 ((List)this.bioAssayTupleData).addAll((List)bioAssayTupleData);
182 }
183
184 /**
185 * Get method for bioAssayTupleData
186 * <p>
187 * @return value of the attribute
188 * <p>
189 *
190 */
191 public
192 BioAssayTupleData_list
193 getBioAssayTupleData()
194 {
195 return bioAssayTupleData;
196 }
197
198 /**
199 * Method to add BioAssayDatum to BioAssayTupleData_list
200 *
201 */
202 public
203 void
204 addToBioAssayTupleData(
205 BioAssayDatum bioAssayDatum
206 )
207 {
208 this.bioAssayTupleData.add(bioAssayDatum);
209 }
210
211 /**
212 * Method to add BioAssayDatum at position to BioAssayTupleData_list
213 *
214 */
215 public
216 void
217 addToBioAssayTupleData(
218 int position,
219 BioAssayDatum bioAssayDatum
220 )
221 {
222 this.bioAssayTupleData.add(position, bioAssayDatum);
223 }
224
225 /**
226 * Method to get BioAssayDatum from BioAssayTupleData_list
227 *
228 */
229 public
230 BioAssayDatum
231 getFromBioAssayTupleData(
232 int position
233 )
234 {
235 return (BioAssayDatum) this.bioAssayTupleData.get(position);
236 }
237
238 /**
239 * Method to remove by position from BioAssayTupleData_list
240 *
241 */
242 public
243 void
244 removeElementAtFromBioAssayTupleData(
245 int position
246 )
247 {
248 this.bioAssayTupleData.removeElementAt(position);
249 }
250
251 /**
252 * Method to remove first BioAssayDatum from BioAssayTupleData_list
253 *
254 */
255 public
256 void
257 removeFromBioAssayTupleData(
258 BioAssayDatum bioAssayDatum
259 )
260 {
261 this.bioAssayTupleData.remove(bioAssayDatum);
262 }
263
264 }