Source code: org/biomage/BioMaterial/CompoundMeasurement.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:09 AM *
43 * *
44 ***************************************************************************
45 */
46
47 /**
48 * org.biomage.BioMaterial
49 *
50 */
51 package org.biomage.BioMaterial;
52
53 /**
54 * Import list for CompoundMeasurement
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.HasCompound;
63 import org.biomage.Interface.HasMeasurement;
64 import org.biomage.Common.Extendable;
65 import org.biomage.Measurement.Measurement;
66
67 /**
68 * A CompoundMeasurement is a pairing of a source Compound and an amount
69 * (Measurement) of that Compound.
70 *
71 */
72 public
73 class CompoundMeasurement
74 extends Extendable
75 implements Serializable,
76 HasCompound,
77 HasMeasurement
78 {
79 /**
80 * A Compound to be used to create another Compound.
81 *
82 */
83 private Compound compound;
84
85
86 /**
87 * The amount of the Compound.
88 *
89 */
90 private Measurement measurement;
91
92
93 /**
94 * Default constructor.
95 *
96 */
97 public
98 CompoundMeasurement()
99 {
100 super();
101 }
102
103 /**
104 * Attribute constructor.
105 *
106 * Looks up the attributes in the parameter and casts them from strings
107 * appropriately
108 * @param atts: the attribute list.
109 *
110 */
111 // TODO Work in progress (attribute constructor).
112 public
113 CompoundMeasurement(Attributes atts)
114 {
115 super(atts);
116
117 }
118
119 /**
120 * writeMAGEML
121 * <p>
122 * This method is responsible for assembling the attribute and
123 * association data into XML. It creates the object tag and then calls
124 * the writeAttributes and writeAssociation methods.
125 * <p>
126 *
127 */
128 public
129 void
130 writeMAGEML(Writer out)
131 throws IOException
132 {
133 out.write("<CompoundMeasurement");
134 writeAttributes(out);
135 out.write(">");
136 writeAssociations(out);
137 out.write("</CompoundMeasurement>");
138 }
139
140 /**
141 * writeAttributes
142 * <p>
143 * This method is responsible for assembling the attribute data into
144 * XML. It calls the super method to write out all attributes of this
145 * class and it's ancestors.
146 * <p>
147 *
148 */
149 public
150 void
151 writeAttributes(Writer out)
152 throws IOException
153 {
154 super.writeAttributes(out);
155 }
156
157 /**
158 * writeAssociations
159 * <p>
160 * This method is responsible for assembling the association data
161 * into XML. It calls the super method to write out all associations of
162 * this class's ancestors.
163 * <p>
164 *
165 */
166 public
167 void
168 writeAssociations(Writer out)
169 throws IOException
170 {
171 super.writeAssociations(out);
172 if ( compound != null ){
173 out.write("<Compound_assnref>");
174 out.write("<Compound_ref identifier=\"" + compound.getIdentifier() + "\"/>");
175 out.write("</Compound_assnref>");
176 }
177 if ( measurement != null ){
178 out.write("<Measurement_assn>");
179 measurement.writeMAGEML(out);
180 out.write("</Measurement_assn>");
181 }
182 }
183
184 /**
185 * Set method for compound
186 * <p>
187 * @param value to set
188 * <p>
189 *
190 */
191 public
192 void
193 setCompound(
194 Compound compound
195 )
196 {
197 this.compound = compound;
198 }
199
200 /**
201 * Get method for compound
202 * <p>
203 * @return value of the attribute
204 * <p>
205 *
206 */
207 public
208 Compound
209 getCompound()
210 {
211 return compound;
212 }
213
214 /**
215 * Set method for measurement
216 * <p>
217 * @param value to set
218 * <p>
219 *
220 */
221 public
222 void
223 setMeasurement(
224 Measurement measurement
225 )
226 {
227 this.measurement = measurement;
228 }
229
230 /**
231 * Get method for measurement
232 * <p>
233 * @return value of the attribute
234 * <p>
235 *
236 */
237 public
238 Measurement
239 getMeasurement()
240 {
241 return measurement;
242 }
243
244 }