Source code: org/biomage/BQS/BibliographicReference.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:33 AM *
43 * *
44 ***************************************************************************
45 */
46
47 /**
48 * org.biomage.BQS
49 *
50 */
51 package org.biomage.BQS;
52
53 /**
54 * Import list for BibliographicReference
55 *
56 */
57 import java.io.Serializable;
58 import java.util.*;
59 import java.util.Date;
60 import org.xml.sax.Attributes;
61 import java.io.Writer;
62 import java.io.IOException;
63 import org.biomage.Interface.HasParameters;
64 import org.biomage.Common.Describable;
65 import org.biomage.Description.OntologyEntry;
66
67 /**
68 * Attributes for the most common criteria and association with
69 * OntologyEntry allows criteria to be specified for searching for a
70 * Bibliographic reference.
71 *
72 */
73 public
74 class BibliographicReference
75 extends Describable
76 implements Serializable,
77 HasParameters
78 {
79 String title;
80
81 String authors;
82
83 String publication;
84
85 String publisher;
86
87 String editor;
88
89 Date year;
90
91 String volume;
92
93 String issue;
94
95 String pages;
96
97 String URI;
98
99 /**
100 * Criteria that can be used to look up the reference in a
101 * repository.
102 *
103 */
104 private Parameters_list parameters = new Parameters_list();
105
106 /**
107 * Default constructor.
108 *
109 */
110 public
111 BibliographicReference()
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 BibliographicReference(Attributes atts)
127 {
128 super(atts);
129
130 {
131 int nIndex = atts.getIndex("", "title");
132 if (nIndex != -1)
133 {
134 title = atts.getValue(nIndex);
135 }
136 }
137
138 {
139 int nIndex = atts.getIndex("", "authors");
140 if (nIndex != -1)
141 {
142 authors = atts.getValue(nIndex);
143 }
144 }
145
146 {
147 int nIndex = atts.getIndex("", "publication");
148 if (nIndex != -1)
149 {
150 publication = atts.getValue(nIndex);
151 }
152 }
153
154 {
155 int nIndex = atts.getIndex("", "publisher");
156 if (nIndex != -1)
157 {
158 publisher = atts.getValue(nIndex);
159 }
160 }
161
162 {
163 int nIndex = atts.getIndex("", "editor");
164 if (nIndex != -1)
165 {
166 editor = atts.getValue(nIndex);
167 }
168 }
169
170 {
171 int nIndex = atts.getIndex("", "year");
172 if (nIndex != -1)
173 {
174 year = new Date(atts.getValue(nIndex));
175 }
176 }
177
178 {
179 int nIndex = atts.getIndex("", "volume");
180 if (nIndex != -1)
181 {
182 volume = atts.getValue(nIndex);
183 }
184 }
185
186 {
187 int nIndex = atts.getIndex("", "issue");
188 if (nIndex != -1)
189 {
190 issue = atts.getValue(nIndex);
191 }
192 }
193
194 {
195 int nIndex = atts.getIndex("", "pages");
196 if (nIndex != -1)
197 {
198 pages = atts.getValue(nIndex);
199 }
200 }
201
202 {
203 int nIndex = atts.getIndex("", "URI");
204 if (nIndex != -1)
205 {
206 URI = atts.getValue(nIndex);
207 }
208 }
209
210 }
211
212 /**
213 * writeMAGEML
214 * <p>
215 * This method is responsible for assembling the attribute and
216 * association data into XML. It creates the object tag and then calls
217 * the writeAttributes and writeAssociation methods.
218 * <p>
219 *
220 */
221 public
222 void
223 writeMAGEML(Writer out)
224 throws IOException
225 {
226 out.write("<BibliographicReference");
227 writeAttributes(out);
228 out.write(">");
229 writeAssociations(out);
230 out.write("</BibliographicReference>");
231 }
232
233 /**
234 * writeAttributes
235 * <p>
236 * This method is responsible for assembling the attribute data into
237 * XML. It calls the super method to write out all attributes of this
238 * class and it's ancestors.
239 * <p>
240 *
241 */
242 public
243 void
244 writeAttributes(Writer out)
245 throws IOException
246 {
247 super.writeAttributes(out);
248 if ( title != null ) {
249 out.write(" title=\"" + title + "\"");
250 }
251 if ( authors != null ) {
252 out.write(" authors=\"" + authors + "\"");
253 }
254 if ( publication != null ) {
255 out.write(" publication=\"" + publication + "\"");
256 }
257 if ( publisher != null ) {
258 out.write(" publisher=\"" + publisher + "\"");
259 }
260 if ( editor != null ) {
261 out.write(" editor=\"" + editor + "\"");
262 }
263 out.write(" year=\"" + year + "\"");
264 if ( volume != null ) {
265 out.write(" volume=\"" + volume + "\"");
266 }
267 if ( issue != null ) {
268 out.write(" issue=\"" + issue + "\"");
269 }
270 if ( pages != null ) {
271 out.write(" pages=\"" + pages + "\"");
272 }
273 if ( URI != null ) {
274 out.write(" URI=\"" + URI + "\"");
275 }
276 }
277
278 /**
279 * writeAssociations
280 * <p>
281 * This method is responsible for assembling the association data
282 * into XML. It calls the super method to write out all associations of
283 * this class's ancestors.
284 * <p>
285 *
286 */
287 public
288 void
289 writeAssociations(Writer out)
290 throws IOException
291 {
292 super.writeAssociations(out);
293 if ( parameters.size() > 0 ){
294 out.write("<Parameters_assnlist>");
295 for ( int i = 0; i < parameters.size(); i++) {
296 ((OntologyEntry)parameters.elementAt(i)).writeMAGEML(out);
297 }
298 out.write("</Parameters_assnlist>");
299 }
300 }
301
302 /**
303 * Set method for title
304 * <p>
305 * @param value to set
306 * <p>
307 *
308 */
309 public
310 void
311 setTitle(
312 String title
313 )
314 {
315 this.title = title;
316 }
317
318 /**
319 * Get method for title
320 * <p>
321 * @return value of the attribute
322 * <p>
323 *
324 */
325 public
326 String
327 getTitle()
328 {
329 return title;
330 }
331
332 /**
333 * Set method for authors
334 * <p>
335 * @param value to set
336 * <p>
337 *
338 */
339 public
340 void
341 setAuthors(
342 String authors
343 )
344 {
345 this.authors = authors;
346 }
347
348 /**
349 * Get method for authors
350 * <p>
351 * @return value of the attribute
352 * <p>
353 *
354 */
355 public
356 String
357 getAuthors()
358 {
359 return authors;
360 }
361
362 /**
363 * Set method for publication
364 * <p>
365 * @param value to set
366 * <p>
367 *
368 */
369 public
370 void
371 setPublication(
372 String publication
373 )
374 {
375 this.publication = publication;
376 }
377
378 /**
379 * Get method for publication
380 * <p>
381 * @return value of the attribute
382 * <p>
383 *
384 */
385 public
386 String
387 getPublication()
388 {
389 return publication;
390 }
391
392 /**
393 * Set method for publisher
394 * <p>
395 * @param value to set
396 * <p>
397 *
398 */
399 public
400 void
401 setPublisher(
402 String publisher
403 )
404 {
405 this.publisher = publisher;
406 }
407
408 /**
409 * Get method for publisher
410 * <p>
411 * @return value of the attribute
412 * <p>
413 *
414 */
415 public
416 String
417 getPublisher()
418 {
419 return publisher;
420 }
421
422 /**
423 * Set method for editor
424 * <p>
425 * @param value to set
426 * <p>
427 *
428 */
429 public
430 void
431 setEditor(
432 String editor
433 )
434 {
435 this.editor = editor;
436 }
437
438 /**
439 * Get method for editor
440 * <p>
441 * @return value of the attribute
442 * <p>
443 *
444 */
445 public
446 String
447 getEditor()
448 {
449 return editor;
450 }
451
452 /**
453 * Set method for year
454 * <p>
455 * @param value to set
456 * <p>
457 *
458 */
459 public
460 void
461 setYear(
462 Date year
463 )
464 {
465 this.year = year;
466 }
467
468 /**
469 * Get method for year
470 * <p>
471 * @return value of the attribute
472 * <p>
473 *
474 */
475 public
476 Date
477 getYear()
478 {
479 return year;
480 }
481
482 /**
483 * Set method for volume
484 * <p>
485 * @param value to set
486 * <p>
487 *
488 */
489 public
490 void
491 setVolume(
492 String volume
493 )
494 {
495 this.volume = volume;
496 }
497
498 /**
499 * Get method for volume
500 * <p>
501 * @return value of the attribute
502 * <p>
503 *
504 */
505 public
506 String
507 getVolume()
508 {
509 return volume;
510 }
511
512 /**
513 * Set method for issue
514 * <p>
515 * @param value to set
516 * <p>
517 *
518 */
519 public
520 void
521 setIssue(
522 String issue
523 )
524 {
525 this.issue = issue;
526 }
527
528 /**
529 * Get method for issue
530 * <p>
531 * @return value of the attribute
532 * <p>
533 *
534 */
535 public
536 String
537 getIssue()
538 {
539 return issue;
540 }
541
542 /**
543 * Set method for pages
544 * <p>
545 * @param value to set
546 * <p>
547 *
548 */
549 public
550 void
551 setPages(
552 String pages
553 )
554 {
555 this.pages = pages;
556 }
557
558 /**
559 * Get method for pages
560 * <p>
561 * @return value of the attribute
562 * <p>
563 *
564 */
565 public
566 String
567 getPages()
568 {
569 return pages;
570 }
571
572 /**
573 * Set method for URI
574 * <p>
575 * @param value to set
576 * <p>
577 *
578 */
579 public
580 void
581 setURI(
582 String URI
583 )
584 {
585 this.URI = URI;
586 }
587
588 /**
589 * Get method for URI
590 * <p>
591 * @return value of the attribute
592 * <p>
593 *
594 */
595 public
596 String
597 getURI()
598 {
599 return URI;
600 }
601
602 /**
603 * Set method for parameters
604 * <p>
605 * @param value to set
606 * <p>
607 *
608 */
609 public
610 void
611 setParameters(
612 Parameters_list parameters
613 )
614 {
615 ((List)this.parameters).addAll((List)parameters);
616 }
617
618 /**
619 * Get method for parameters
620 * <p>
621 * @return value of the attribute
622 * <p>
623 *
624 */
625 public
626 Parameters_list
627 getParameters()
628 {
629 return parameters;
630 }
631
632 /**
633 * Method to add OntologyEntry to Parameters_list
634 *
635 */
636 public
637 void
638 addToParameters(
639 OntologyEntry ontologyEntry
640 )
641 {
642 this.parameters.add(ontologyEntry);
643 }
644
645 /**
646 * Method to add OntologyEntry at position to Parameters_list
647 *
648 */
649 public
650 void
651 addToParameters(
652 int position,
653 OntologyEntry ontologyEntry
654 )
655 {
656 this.parameters.add(position, ontologyEntry);
657 }
658
659 /**
660 * Method to get OntologyEntry from Parameters_list
661 *
662 */
663 public
664 OntologyEntry
665 getFromParameters(
666 int position
667 )
668 {
669 return (OntologyEntry) this.parameters.get(position);
670 }
671
672 /**
673 * Method to remove by position from Parameters_list
674 *
675 */
676 public
677 void
678 removeElementAtFromParameters(
679 int position
680 )
681 {
682 this.parameters.removeElementAt(position);
683 }
684
685 /**
686 * Method to remove first OntologyEntry from Parameters_list
687 *
688 */
689 public
690 void
691 removeFromParameters(
692 OntologyEntry ontologyEntry
693 )
694 {
695 this.parameters.remove(ontologyEntry);
696 }
697
698 }