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

Quick Search    Search Deep

Source code: org/biomage/ArrayDesign/CompositeGroup.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:03 AM                                  *
43   *                                                                         *
44   ***************************************************************************
45   */
46  
47  /**
48   *  org.biomage.ArrayDesign
49   *  
50   */
51  package org.biomage.ArrayDesign;
52  
53  /**
54   *  Import list for CompositeGroup
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.HasCompositeSequences;
63  import org.biomage.DesignElement.CompositeSequence;
64  
65  /**
66   *  Allows specification of the type of Composite Design Element.
67   *  
68   */
69  public
70  class CompositeGroup
71      extends DesignElementGroup
72      implements Serializable,
73          HasCompositeSequences
74  {
75      /**
76       *  The compositeSequences that belong to this group.
77       *  
78       */
79      private CompositeSequences_list compositeSequences = new CompositeSequences_list();
80  
81      /**
82       *  Default constructor.
83       *  
84       */
85      public
86      CompositeGroup()
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     CompositeGroup(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("<CompositeGroup");
122         writeAttributes(out);
123         out.write(">");
124         writeAssociations(out);
125         out.write("</CompositeGroup>");
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 ( compositeSequences.size() > 0 ){
161             out.write("<CompositeSequences_assnreflist>");
162             for ( int i = 0; i < compositeSequences.size(); i++) {
163                 out.write("<CompositeSequence_ref identifier=\"" + ((CompositeSequence)compositeSequences.elementAt(i)).getIdentifier() + "\"/>");
164             }
165             out.write("</CompositeSequences_assnreflist>");
166         }
167     }
168 
169     /**
170      *  Set method for compositeSequences
171      *  <p>
172      *  @param value to set
173      *  <p>
174      *  
175      */
176     public
177     void
178     setCompositeSequences(
179         CompositeSequences_list compositeSequences
180     )
181     {
182         ((List)this.compositeSequences).addAll((List)compositeSequences);
183     }
184 
185     /**
186      *  Get method for compositeSequences
187      *  <p>
188      *  @return value of the attribute
189      *  <p>
190      *  
191      */
192     public
193     CompositeSequences_list
194     getCompositeSequences()
195     {
196         return compositeSequences;
197     }
198 
199     /**
200      *  Method to add CompositeSequence to CompositeSequences_list
201      *  
202      */
203     public
204     void
205     addToCompositeSequences(
206         CompositeSequence compositeSequence
207     )
208     {
209         this.compositeSequences.add(compositeSequence);
210     }
211 
212     /**
213      *  Method to add CompositeSequence at position to 
214      *  CompositeSequences_list
215      *  
216      */
217     public
218     void
219     addToCompositeSequences(
220         int position,
221         CompositeSequence compositeSequence
222     )
223     {
224         this.compositeSequences.add(position, compositeSequence);
225     }
226 
227     /**
228      *  Method to get CompositeSequence from CompositeSequences_list
229      *  
230      */
231     public
232     CompositeSequence
233     getFromCompositeSequences(
234         int position
235     )
236     {
237         return (CompositeSequence) this.compositeSequences.get(position);
238     }
239 
240     /**
241      *  Method to remove by position from CompositeSequences_list
242      *  
243      */
244     public
245     void
246     removeElementAtFromCompositeSequences(
247         int position
248     )
249     {
250         this.compositeSequences.removeElementAt(position);
251     }
252 
253     /**
254      *  Method to remove first CompositeSequence from 
255      *  CompositeSequences_list
256      *  
257      */
258     public
259     void
260     removeFromCompositeSequences(
261         CompositeSequence compositeSequence
262     )
263     {
264         this.compositeSequences.remove(compositeSequence);
265     }
266 
267 }