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

Quick Search    Search Deep

Source code: org/biomage/Common/Describable.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:47 AM                                  *
43   *                                                                         *
44   ***************************************************************************
45   */
46  
47  /**
48   *  org.biomage.Common
49   *  
50   */
51  package org.biomage.Common;
52  
53  /**
54   *  Import list for Describable
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.HasSecurity;
63  import org.biomage.Interface.HasAuditTrail;
64  import org.biomage.Interface.HasDescriptions;
65  import org.biomage.AuditAndSecurity.Audit;
66  import org.biomage.AuditAndSecurity.Security;
67  import org.biomage.Description.Description;
68  
69  /**
70   *  Abstract class that allows subclasses to inherit the association to 
71   *  Description, for detailed annotations such as Ontology entries and 
72   *  Database references, the association to Audit, for tracking changes, and 
73   *  the association to Security for indicating permissions.
74   *  
75   */
76  public
77  abstract
78  class Describable
79      extends Extendable
80      implements Serializable,
81          HasSecurity,
82          HasAuditTrail,
83          HasDescriptions
84  {
85      /**
86       *  Information on the security for the instance of the class.
87       *  
88       */
89      private Security security;
90  
91  
92      /**
93       *  A list of Audit instances that track changes to the instance of 
94       *  Describable.
95       *  
96       */
97      private AuditTrail_list auditTrail = new AuditTrail_list();
98  
99      /**
100      *  Free hand text descriptions.  Makes available the associations of 
101      *  Description to an instance of Describable.
102      *  
103      */
104     private Descriptions_list descriptions = new Descriptions_list();
105 
106     /**
107      *  Default constructor.
108      *  
109      */
110     public
111     Describable()
112     {
113         super();
114     }
115 
116     /**
117      *  Attribute constructor.
118      *  
119      *  Looks up the attributes in the parameter and casts them from strings 
120      *  appropriately
121      *  @param atts: the attribute list.
122      *  
123      */
124     // TODO Work in progress (attribute constructor).
125     public
126     Describable(Attributes atts)
127     {
128         super(atts);
129 
130     }
131 
132     /**
133      *  writeMAGEML
134      *  <p>
135      *  This method is responsible for assembling the attribute and 
136      *  association data into XML. It creates the object tag and then calls 
137      *  the writeAttributes and writeAssociation methods.
138      *  <p>
139      *  
140      */
141     public
142     void
143     writeMAGEML(Writer out)
144     throws IOException
145     {
146     }
147 
148     /**
149      *  writeAttributes
150      *  <p>
151      *  This method is responsible for assembling the attribute data into 
152      *  XML. It calls the super method to write out all attributes of this 
153      *  class and it's ancestors.
154      *  <p>
155      *  
156      */
157     public
158     void
159     writeAttributes(Writer out)
160     throws IOException
161     {
162         super.writeAttributes(out);
163     }
164 
165     /**
166      *  writeAssociations
167      *  <p>
168      *  This method is responsible for assembling the association data 
169      *  into XML. It calls the super method to write out all associations of 
170      *  this class's ancestors.
171      *  <p>
172      *  
173      */
174     public
175     void
176     writeAssociations(Writer out)
177     throws IOException
178     {
179         super.writeAssociations(out);
180         if ( descriptions.size() > 0 ){
181             out.write("<Descriptions_assnlist>");
182             for ( int i = 0; i < descriptions.size(); i++) {
183                 ((Description)descriptions.elementAt(i)).writeMAGEML(out);
184             }
185             out.write("</Descriptions_assnlist>");
186         }
187         if ( auditTrail.size() > 0 ){
188             out.write("<AuditTrail_assnlist>");
189             for ( int i = 0; i < auditTrail.size(); i++) {
190                 ((Audit)auditTrail.elementAt(i)).writeMAGEML(out);
191             }
192             out.write("</AuditTrail_assnlist>");
193         }
194         if ( security != null ){
195             out.write("<Security_assnref>");
196             out.write("<Security_ref identifier=\"" + security.getIdentifier() + "\"/>");
197             out.write("</Security_assnref>");
198         }
199     }
200 
201     /**
202      *  Set method for security
203      *  <p>
204      *  @param value to set
205      *  <p>
206      *  
207      */
208     public
209     void
210     setSecurity(
211         Security security
212     )
213     {
214         this.security = security;
215     }
216 
217     /**
218      *  Get method for security
219      *  <p>
220      *  @return value of the attribute
221      *  <p>
222      *  
223      */
224     public
225     Security
226     getSecurity()
227     {
228         return security;
229     }
230 
231     /**
232      *  Set method for auditTrail
233      *  <p>
234      *  @param value to set
235      *  <p>
236      *  
237      */
238     public
239     void
240     setAuditTrail(
241         AuditTrail_list auditTrail
242     )
243     {
244         ((List)this.auditTrail).addAll((List)auditTrail);
245     }
246 
247     /**
248      *  Get method for auditTrail
249      *  <p>
250      *  @return value of the attribute
251      *  <p>
252      *  
253      */
254     public
255     AuditTrail_list
256     getAuditTrail()
257     {
258         return auditTrail;
259     }
260 
261     /**
262      *  Method to add Audit to AuditTrail_list
263      *  
264      */
265     public
266     void
267     addToAuditTrail(
268         Audit audit
269     )
270     {
271         this.auditTrail.add(audit);
272     }
273 
274     /**
275      *  Method to add Audit at position to AuditTrail_list
276      *  
277      */
278     public
279     void
280     addToAuditTrail(
281         int position,
282         Audit audit
283     )
284     {
285         this.auditTrail.add(position, audit);
286     }
287 
288     /**
289      *  Method to get Audit from AuditTrail_list
290      *  
291      */
292     public
293     Audit
294     getFromAuditTrail(
295         int position
296     )
297     {
298         return (Audit) this.auditTrail.get(position);
299     }
300 
301     /**
302      *  Method to remove by position from AuditTrail_list
303      *  
304      */
305     public
306     void
307     removeElementAtFromAuditTrail(
308         int position
309     )
310     {
311         this.auditTrail.removeElementAt(position);
312     }
313 
314     /**
315      *  Method to remove first Audit from AuditTrail_list
316      *  
317      */
318     public
319     void
320     removeFromAuditTrail(
321         Audit audit
322     )
323     {
324         this.auditTrail.remove(audit);
325     }
326 
327     /**
328      *  Set method for descriptions
329      *  <p>
330      *  @param value to set
331      *  <p>
332      *  
333      */
334     public
335     void
336     setDescriptions(
337         Descriptions_list descriptions
338     )
339     {
340         ((List)this.descriptions).addAll((List)descriptions);
341     }
342 
343     /**
344      *  Get method for descriptions
345      *  <p>
346      *  @return value of the attribute
347      *  <p>
348      *  
349      */
350     public
351     Descriptions_list
352     getDescriptions()
353     {
354         return descriptions;
355     }
356 
357     /**
358      *  Method to add Description to Descriptions_list
359      *  
360      */
361     public
362     void
363     addToDescriptions(
364         Description description
365     )
366     {
367         this.descriptions.add(description);
368     }
369 
370     /**
371      *  Method to add Description at position to Descriptions_list
372      *  
373      */
374     public
375     void
376     addToDescriptions(
377         int position,
378         Description description
379     )
380     {
381         this.descriptions.add(position, description);
382     }
383 
384     /**
385      *  Method to get Description from Descriptions_list
386      *  
387      */
388     public
389     Description
390     getFromDescriptions(
391         int position
392     )
393     {
394         return (Description) this.descriptions.get(position);
395     }
396 
397     /**
398      *  Method to remove by position from Descriptions_list
399      *  
400      */
401     public
402     void
403     removeElementAtFromDescriptions(
404         int position
405     )
406     {
407         this.descriptions.removeElementAt(position);
408     }
409 
410     /**
411      *  Method to remove first Description from Descriptions_list
412      *  
413      */
414     public
415     void
416     removeFromDescriptions(
417         Description description
418     )
419     {
420         this.descriptions.remove(description);
421     }
422 
423 }