Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

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