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

Quick Search    Search Deep

Source code: org/biomage/Protocol/Protocol.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:27 AM                                  *
43   *                                                                         *
44   ***************************************************************************
45   */
46  
47  /**
48   *  org.biomage.Protocol
49   *  
50   */
51  package org.biomage.Protocol;
52  
53  /**
54   *  Import list for Protocol
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.HasSoftwares;
63  import org.biomage.Interface.HasHardwares;
64  import org.biomage.Interface.HasType;
65  import org.biomage.Description.OntologyEntry;
66  
67  /**
68   *  A Protocol is a parameterizable description of a method.  
69   *  ProtocolApplication is used to specify the ParameterValues of it's 
70   *  Protocol's Parameters.
71   *  
72   */
73  public
74  class Protocol
75      extends Parameterizable
76      implements Serializable,
77          HasSoftwares,
78          HasHardwares,
79          HasType
80  {
81      /**
82       *  The text description of the Protocol.
83       *  
84       */
85       String text;
86  
87      /**
88       *  The title of the Protocol
89       *  
90       */
91       String title;
92  
93      /**
94       *  Software used by this Protocol.
95       *  
96       */
97      private Softwares_list softwares = new Softwares_list();
98  
99      /**
100      *  Hardware used by this protocol.
101      *  
102      */
103     private Hardwares_list hardwares = new Hardwares_list();
104 
105     /**
106      *  The type of a Protocol,  a user should provide/use a recommended 
107      *  vocabulary.  Examples of types include:  RNA extraction, array 
108      *  washing, etc...
109      *  
110      */
111     private OntologyEntry type;
112 
113 
114     /**
115      *  Default constructor.
116      *  
117      */
118     public
119     Protocol()
120     {
121         super();
122     }
123 
124     /**
125      *  Attribute constructor.
126      *  
127      *  Looks up the attributes in the parameter and casts them from strings 
128      *  appropriately
129      *  @param atts: the attribute list.
130      *  
131      */
132     // TODO Work in progress (attribute constructor).
133     public
134     Protocol(Attributes atts)
135     {
136         super(atts);
137 
138         {
139             int nIndex = atts.getIndex("", "text");
140             if (nIndex != -1)
141             {
142                 text = atts.getValue(nIndex);
143             }
144         }
145 
146         {
147             int nIndex = atts.getIndex("", "title");
148             if (nIndex != -1)
149             {
150                 title = atts.getValue(nIndex);
151             }
152         }
153 
154     }
155 
156     /**
157      *  writeMAGEML
158      *  <p>
159      *  This method is responsible for assembling the attribute and 
160      *  association data into XML. It creates the object tag and then calls 
161      *  the writeAttributes and writeAssociation methods.
162      *  <p>
163      *  
164      */
165     public
166     void
167     writeMAGEML(Writer out)
168     throws IOException
169     {
170         out.write("<Protocol");
171         writeAttributes(out);
172         out.write(">");
173         writeAssociations(out);
174         out.write("</Protocol>");
175     }
176 
177     /**
178      *  writeAttributes
179      *  <p>
180      *  This method is responsible for assembling the attribute data into 
181      *  XML. It calls the super method to write out all attributes of this 
182      *  class and it's ancestors.
183      *  <p>
184      *  
185      */
186     public
187     void
188     writeAttributes(Writer out)
189     throws IOException
190     {
191         super.writeAttributes(out);
192         if ( text != null ) {
193             out.write(" text=\"" + text + "\"");
194         }
195         if ( title != null ) {
196             out.write(" title=\"" + title + "\"");
197         }
198     }
199 
200     /**
201      *  writeAssociations
202      *  <p>
203      *  This method is responsible for assembling the association data 
204      *  into XML. It calls the super method to write out all associations of 
205      *  this class's ancestors.
206      *  <p>
207      *  
208      */
209     public
210     void
211     writeAssociations(Writer out)
212     throws IOException
213     {
214         super.writeAssociations(out);
215         if ( type != null ){
216             out.write("<Type_assn>");
217             type.writeMAGEML(out);
218             out.write("</Type_assn>");
219         }
220         if ( hardwares.size() > 0 ){
221             out.write("<Hardwares_assnreflist>");
222             for ( int i = 0; i < hardwares.size(); i++) {
223                 out.write("<Hardware_ref identifier=\"" + ((Hardware)hardwares.elementAt(i)).getIdentifier() + "\"/>");
224             }
225             out.write("</Hardwares_assnreflist>");
226         }
227         if ( softwares.size() > 0 ){
228             out.write("<Softwares_assnreflist>");
229             for ( int i = 0; i < softwares.size(); i++) {
230                 out.write("<Software_ref identifier=\"" + ((Software)softwares.elementAt(i)).getIdentifier() + "\"/>");
231             }
232             out.write("</Softwares_assnreflist>");
233         }
234     }
235 
236     /**
237      *  Set method for text
238      *  <p>
239      *  @param value to set
240      *  <p>
241      *  
242      */
243     public
244     void
245     setText(
246         String text
247     )
248     {
249         this.text = text;
250     }
251 
252     /**
253      *  Get method for text
254      *  <p>
255      *  @return value of the attribute
256      *  <p>
257      *  
258      */
259     public
260     String
261     getText()
262     {
263         return text;
264     }
265 
266     /**
267      *  Set method for title
268      *  <p>
269      *  @param value to set
270      *  <p>
271      *  
272      */
273     public
274     void
275     setTitle(
276         String title
277     )
278     {
279         this.title = title;
280     }
281 
282     /**
283      *  Get method for title
284      *  <p>
285      *  @return value of the attribute
286      *  <p>
287      *  
288      */
289     public
290     String
291     getTitle()
292     {
293         return title;
294     }
295 
296     /**
297      *  Set method for softwares
298      *  <p>
299      *  @param value to set
300      *  <p>
301      *  
302      */
303     public
304     void
305     setSoftwares(
306         Softwares_list softwares
307     )
308     {
309         ((List)this.softwares).addAll((List)softwares);
310     }
311 
312     /**
313      *  Get method for softwares
314      *  <p>
315      *  @return value of the attribute
316      *  <p>
317      *  
318      */
319     public
320     Softwares_list
321     getSoftwares()
322     {
323         return softwares;
324     }
325 
326     /**
327      *  Method to add Software to Softwares_list
328      *  
329      */
330     public
331     void
332     addToSoftwares(
333         Software software
334     )
335     {
336         this.softwares.add(software);
337     }
338 
339     /**
340      *  Method to add Software at position to Softwares_list
341      *  
342      */
343     public
344     void
345     addToSoftwares(
346         int position,
347         Software software
348     )
349     {
350         this.softwares.add(position, software);
351     }
352 
353     /**
354      *  Method to get Software from Softwares_list
355      *  
356      */
357     public
358     Software
359     getFromSoftwares(
360         int position
361     )
362     {
363         return (Software) this.softwares.get(position);
364     }
365 
366     /**
367      *  Method to remove by position from Softwares_list
368      *  
369      */
370     public
371     void
372     removeElementAtFromSoftwares(
373         int position
374     )
375     {
376         this.softwares.removeElementAt(position);
377     }
378 
379     /**
380      *  Method to remove first Software from Softwares_list
381      *  
382      */
383     public
384     void
385     removeFromSoftwares(
386         Software software
387     )
388     {
389         this.softwares.remove(software);
390     }
391 
392     /**
393      *  Set method for hardwares
394      *  <p>
395      *  @param value to set
396      *  <p>
397      *  
398      */
399     public
400     void
401     setHardwares(
402         Hardwares_list hardwares
403     )
404     {
405         ((List)this.hardwares).addAll((List)hardwares);
406     }
407 
408     /**
409      *  Get method for hardwares
410      *  <p>
411      *  @return value of the attribute
412      *  <p>
413      *  
414      */
415     public
416     Hardwares_list
417     getHardwares()
418     {
419         return hardwares;
420     }
421 
422     /**
423      *  Method to add Hardware to Hardwares_list
424      *  
425      */
426     public
427     void
428     addToHardwares(
429         Hardware hardware
430     )
431     {
432         this.hardwares.add(hardware);
433     }
434 
435     /**
436      *  Method to add Hardware at position to Hardwares_list
437      *  
438      */
439     public
440     void
441     addToHardwares(
442         int position,
443         Hardware hardware
444     )
445     {
446         this.hardwares.add(position, hardware);
447     }
448 
449     /**
450      *  Method to get Hardware from Hardwares_list
451      *  
452      */
453     public
454     Hardware
455     getFromHardwares(
456         int position
457     )
458     {
459         return (Hardware) this.hardwares.get(position);
460     }
461 
462     /**
463      *  Method to remove by position from Hardwares_list
464      *  
465      */
466     public
467     void
468     removeElementAtFromHardwares(
469         int position
470     )
471     {
472         this.hardwares.removeElementAt(position);
473     }
474 
475     /**
476      *  Method to remove first Hardware from Hardwares_list
477      *  
478      */
479     public
480     void
481     removeFromHardwares(
482         Hardware hardware
483     )
484     {
485         this.hardwares.remove(hardware);
486     }
487 
488     /**
489      *  Set method for type
490      *  <p>
491      *  @param value to set
492      *  <p>
493      *  
494      */
495     public
496     void
497     setType(
498         OntologyEntry type
499     )
500     {
501         this.type = type;
502     }
503 
504     /**
505      *  Get method for type
506      *  <p>
507      *  @return value of the attribute
508      *  <p>
509      *  
510      */
511     public
512     OntologyEntry
513     getType()
514     {
515         return type;
516     }
517 
518 }