1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.sun.syndication.feed.module;
18
19 import com.sun.syndication.feed.impl.CopyFromHelper;
20 import com.sun.syndication.feed.impl.ObjectBean;
21
22 import java.util.*;
23
24
25 /***
26 * Dublin Core ModuleImpl, default implementation.
27 * <p>
28 * @see <a href="http://web.resource.org/rss/1.0/modules/dc/">Dublin Core module</a>.
29 * @author Alejandro Abdelnur
30 *
31 */
32 public class DCModuleImpl extends ModuleImpl implements DCModule {
33 private ObjectBean _objBean;
34 private List _title;
35 private List _creator;
36 private List _subject;
37 private List _description;
38 private List _publisher;
39 private List _contributors;
40 private List _date;
41 private List _type;
42 private List _format;
43 private List _identifier;
44 private List _source;
45 private List _language;
46 private List _relation;
47 private List _coverage;
48 private List _rights;
49
50 /***
51 * Properties to be ignored when cloning.
52 */
53 private static final Set IGNORE_PROPERTIES = new HashSet();
54
55 /***
56 * Unmodifiable Set containing the convenience properties of this class.
57 * <p>
58 * Convenience properties are mapped to Modules, for cloning the convenience
59 * properties can be ignored as the will be copied as part of the module
60 * cloning.
61 */
62 public static final Set CONVENIENCE_PROPERTIES = Collections.unmodifiableSet(IGNORE_PROPERTIES);
63
64 static {
65 IGNORE_PROPERTIES.add("title");
66 IGNORE_PROPERTIES.add("creator");
67 IGNORE_PROPERTIES.add("subject");
68 IGNORE_PROPERTIES.add("description");
69 IGNORE_PROPERTIES.add("publisher");
70 IGNORE_PROPERTIES.add("contributor");
71 IGNORE_PROPERTIES.add("date");
72 IGNORE_PROPERTIES.add("type");
73 IGNORE_PROPERTIES.add("format");
74 IGNORE_PROPERTIES.add("identifier");
75 IGNORE_PROPERTIES.add("source");
76 IGNORE_PROPERTIES.add("language");
77 IGNORE_PROPERTIES.add("relation");
78 IGNORE_PROPERTIES.add("coverage");
79 IGNORE_PROPERTIES.add("rights");
80 }
81
82 /***
83 * Default constructor. All properties are set to <b>null</b>.
84 * <p>
85 *
86 */
87 public DCModuleImpl() {
88 super(DCModule.class, URI);
89 _objBean = new ObjectBean(DCModule.class, this, CONVENIENCE_PROPERTIES);
90 }
91
92 /***
93 * Returns the DublinCore module titles.
94 * <p>
95 * @return a list of Strings representing the DublinCore module title,
96 * an empty list if none.
97 *
98 */
99 public List getTitles() {
100 return (_title == null) ? (_title = new ArrayList()) : _title;
101 }
102
103 /***
104 * Sets the DublinCore module titles.
105 * <p>
106 * @param titles the list of String representing the DublinCore module
107 * titles to set, an empty list or <b>null</b> if none.
108 *
109 */
110 public void setTitles(List titles) {
111 _title = titles;
112 }
113
114 /***
115 * Gets the DublinCore module title. Convenience method that can be used to
116 * obtain the first item, <b>null</b> if none.
117 * <p>
118 * @return the first DublinCore module title, <b>null</b> if none.
119 */
120 public String getTitle() {
121 return ((_title != null) && (_title.size() > 0)) ? (String) _title.get(0) : null;
122 }
123
124 /***
125 * Sets the DublinCore module title. Convenience method that can be used
126 * when there is only one title to set.
127 * <p>
128 * @param title the DublinCore module title to set, <b>null</b> if none.
129 *
130 */
131 public void setTitle(String title) {
132 _title = new ArrayList();
133 _title.add(title);
134 }
135
136 /***
137 * Returns the DublinCore module creator.
138 * <p>
139 * @return a list of Strings representing the DublinCore module creator,
140 * an empty list if none.
141 *
142 */
143 public List getCreators() {
144 return (_creator == null) ? (_creator = new ArrayList()) : _creator;
145 }
146
147 /***
148 * Sets the DublinCore module creators.
149 * <p>
150 * @param creators the list of String representing the DublinCore module
151 * creators to set, an empty list or <b>null</b> if none.
152 *
153 */
154 public void setCreators(List creators) {
155 _creator = creators;
156 }
157
158 /***
159 * Gets the DublinCore module title. Convenience method that can be used
160 * to obtain the first item, <b>null</b> if none.
161 * <p>
162 * @return the first DublinCore module title, <b>null</b> if none.
163 */
164 public String getCreator() {
165 return ((_creator != null) && (_creator.size() > 0)) ? (String) _creator.get(0) : null;
166 }
167
168 /***
169 * Sets the DublinCore module creator. Convenience method that can be used
170 * when there is only one creator to set.
171 * <p>
172 * @param creator the DublinCore module creator to set, <b>null</b> if none.
173 *
174 */
175 public void setCreator(String creator) {
176 _creator = new ArrayList();
177 _creator.add(creator);
178 }
179
180 /***
181 * Returns the DublinCore module subjects.
182 * <p>
183 * @return a list of DCSubject elements with the DublinCore module subjects,
184 * an empty list if none.
185 *
186 */
187 public List getSubjects() {
188 return (_subject == null) ? (_subject = new ArrayList()) : _subject;
189 }
190
191 /***
192 * Sets the DublinCore module subjects.
193 * <p>
194 * @param subjects the list of DCSubject elements with the DublinCore
195 * module subjects to set, an empty list or <b>null</b> if none.
196 *
197 */
198 public void setSubjects(List subjects) {
199 _subject = subjects;
200 }
201
202 /***
203 * Gets the DublinCore module subject. Convenience method that can be used
204 * to obtain the first item, <b>null</b> if none.
205 * <p>
206 * @return the first DublinCore module subject, <b>null</b> if none.
207 */
208 public DCSubject getSubject() {
209 return ((_subject != null) && (_subject.size() > 0)) ?
210 (DCSubject) _subject.get(0) : null;
211 }
212
213 /***
214 * Sets the DCSubject element. Convenience method that can be used when
215 * there is only one subject to set.
216 * <p>
217 * @param subject the DublinCore module subject to set, <b>null</b> if none.
218 *
219 */
220 public void setSubject(DCSubject subject) {
221 _subject = new ArrayList();
222 _subject.add(subject);
223 }
224
225 /***
226 * Returns the DublinCore module description.
227 * <p>
228 * @return a list of Strings representing the DublinCore module
229 * description, an empty list if none.
230 *
231 */
232 public List getDescriptions() {
233 return (_description == null) ? (_description = new ArrayList()) : _description;
234 }
235
236 /***
237 * Sets the DublinCore module descriptions.
238 * <p>
239 * @param descriptions the list of String representing the DublinCore
240 * module descriptions to set, an empty list or <b>null</b> if none.
241 *
242 */
243 public void setDescriptions(List descriptions) {
244 _description = descriptions;
245 }
246
247 /***
248 * Gets the DublinCore module description. Convenience method that can be
249 * used to obtain the first item, <b>null</b> if none.
250 * <p>
251 * @return the first DublinCore module description, <b>null</b> if none.
252 */
253 public String getDescription() {
254 return ((_description != null) && (_description.size() > 0)) ?
255 (String) _description.get(0) : null;
256 }
257
258 /***
259 * Sets the DublinCore module description. Convenience method that can be
260 * used when there is only one description to set.
261 * <p>
262 * @param description the DublinCore module description to set, <b>null</b> if none.
263 *
264 */
265 public void setDescription(String description) {
266 _description = new ArrayList();
267 _description.add(description);
268 }
269
270 /***
271 * Returns the DublinCore module publisher.
272 * <p>
273 * @return a list of Strings representing the DublinCore module publisher,
274 * an empty list if none.
275 *
276 */
277 public List getPublishers() {
278 return (_publisher == null) ? (_publisher = new ArrayList()) : _publisher;
279 }
280
281 /***
282 * Sets the DublinCore module publishers.
283 * <p>
284 * @param publishers the list of String representing the DublinCore module
285 * publishers to set, an empty list or <b>null</b> if none.
286 *
287 */
288 public void setPublishers(List publishers) {
289 _publisher = publishers;
290 }
291
292 /***
293 * Gets the DublinCore module title. Convenience method that can be used to
294 * obtain the first item, <b>null</b> if none.
295 * <p>
296 * @return the first DublinCore module title, <b>null</b> if none.
297 */
298 public String getPublisher() {
299 return ((_publisher != null) && (_publisher.size() > 0)) ?
300 (String) _publisher.get(0) : null;
301 }
302
303 /***
304 * Sets the DublinCore module publisher. Convenience method that can be
305 * used when there is only one publisher to set.
306 * <p>
307 * @param publisher the DublinCore module publisher to set, <b>null</b> if none.
308 *
309 */
310 public void setPublisher(String publisher) {
311 _publisher = new ArrayList();
312 _publisher.add(publisher);
313 }
314
315 /***
316 * Returns the DublinCore module contributor.
317 * <p>
318 * @return a list of Strings representing the DublinCore module contributor,
319 * an empty list if none.
320 *
321 */
322 public List getContributors() {
323 return (_contributors == null) ? (_contributors = new ArrayList()) : _contributors;
324 }
325
326 /***
327 * Sets the DublinCore module contributors.
328 * <p>
329 * @param contributors the list of String representing the DublinCore
330 * module contributors to set, an empty list or <b>null</b> if none.
331 *
332 */
333 public void setContributors(List contributors) {
334 _contributors = contributors;
335 }
336
337 /***
338 * Gets the DublinCore module contributor. Convenience method that can be
339 * used to obtain the first item, <b>null</b> if none.
340 * <p>
341 * @return the first DublinCore module contributor, <b>null</b> if none.
342 */
343 public String getContributor() {
344 return ((_contributors != null) && (_contributors.size() > 0)) ?
345 (String) _contributors.get(0) : null;
346 }
347
348 /***
349 * Sets the DublinCore module contributor. Convenience method that can be
350 * used when there is only one contributor to set.
351 * <p>
352 * @param contributor the DublinCore module contributor to set, <b>null</b> if none.
353 *
354 */
355 public void setContributor(String contributor) {
356 _contributors = new ArrayList();
357 _contributors.add(contributor);
358 }
359
360 /***
361 * Returns the DublinCore module date.
362 * <p>
363 * @return a list of Strings representing the DublinCore module date,
364 * an empty list if none.
365 *
366 */
367 public List getDates() {
368 return (_date == null) ? (_date = new ArrayList()) : _date;
369 }
370
371 /***
372 * Sets the DublinCore module dates.
373 * <p>
374 * @param dates the list of Date representing the DublinCore module dates
375 * to set, an empty list or <b>null</b> if none.
376 *
377 */
378 public void setDates(List dates) {
379 _date = dates;
380 }
381
382 /***
383 * Gets the DublinCore module date. Convenience method that can be used to
384 * obtain the first item, <b>null</b> if none.
385 * <p>
386 * @return the first DublinCore module date, <b>null</b> if none.
387 */
388 public Date getDate() {
389 return ((_date != null) && (_date.size() > 0)) ?
390 (Date) _date.get(0) : null;
391 }
392 /***
393 * Sets the DublinCore module date. Convenience method that can be used
394 * when there is only one date to set.
395 * <p>
396 * @param date the DublinCore module date to set, <b>null</b> if none.
397 *
398 */
399 public void setDate(Date date) {
400 _date = new ArrayList();
401 _date.add(date);
402 }
403
404 /***
405 * Returns the DublinCore module type.
406 * <p>
407 * @return a list of Strings representing the DublinCore module type,
408 * an empty list if none.
409 *
410 */
411 public List getTypes() {
412 return (_type == null) ? (_type = new ArrayList()) : _type;
413 }
414
415 /***
416 * Sets the DublinCore module types.
417 * <p>
418 * @param types the list of String representing the DublinCore module types
419 * to set, an empty list or <b>null</b> if none.
420 *
421 */
422 public void setTypes(List types) {
423 _type = types;
424 }
425
426 /***
427 * Gets the DublinCore module type. Convenience method that can be used to
428 * obtain the first item, <b>null</b> if none.
429 * <p>
430 * @return the first DublinCore module type, <b>null</b> if none.
431 */
432 public String getType() {
433 return ((_type != null) && (_type.size() > 0)) ?
434 (String) _type.get(0) : null;
435 }
436
437 /***
438 * Sets the DublinCore module type. Convenience method that can be used
439 * when there is only one type to set.
440 * <p>
441 * @param type the DublinCore module type to set, <b>null</b> if none.
442 *
443 */
444 public void setType(String type) {
445 _type = new ArrayList();
446 _type.add(type);
447 }
448
449 /***
450 * Returns the DublinCore module format.
451 * <p>
452 * @return a list of Strings representing the DublinCore module format,
453 * an empty list if none.
454 *
455 */
456 public List getFormats() {
457 return (_format == null) ? (_format = new ArrayList()) : _format;
458 }
459
460 /***
461 * Sets the DublinCore module formats.
462 * <p>
463 * @param formats the list of String representing the DublinCore module
464 * formats to set, an empty list or <b>null</b> if none.
465 *
466 */
467 public void setFormats(List formats) {
468 _format = formats;
469 }
470
471 /***
472 * Gets the DublinCore module format. Convenience method that can be used
473 * to obtain the first item, <b>null</b> if none.
474 * <p>
475 * @return the first DublinCore module format, <b>null</b> if none.
476 */
477 public String getFormat() {
478 return ((_format != null) && (_format.size() > 0)) ?
479 (String) _format.get(0) : null;
480 }
481
482 /***
483 * Sets the DublinCore module format. Convenience method that can be used
484 * when there is only one format to set.
485 * <p>
486 * @param format the DublinCore module format to set, <b>null</b> if none.
487 *
488 */
489 public void setFormat(String format) {
490 _format = new ArrayList();
491 _format.add(format);
492 }
493
494 /***
495 * Returns the DublinCore module identifier.
496 * <p>
497 * @return a list of Strings representing the DublinCore module identifier,
498 * an empty list if none.
499 *
500 */
501 public List getIdentifiers() {
502 return (_identifier == null) ? (_identifier = new ArrayList()) : _identifier;
503 }
504
505 /***
506 * Sets the DublinCore module identifiers.
507 * <p>
508 * @param identifiers the list of String representing the DublinCore module
509 * identifiers to set, an empty list or <b>null</b> if none.
510 *
511 */
512 public void setIdentifiers(List identifiers) {
513 _identifier = identifiers;
514 }
515
516 /***
517 * Gets the DublinCore module identifier. Convenience method that can be
518 * used to obtain the first item, <b>null</b> if none.
519 * <p>
520 * @return the first DublinCore module identifier, <b>null</b> if none.
521 */
522 public String getIdentifier() {
523 return ((_identifier != null) && (_identifier.size() > 0)) ?
524 (String) _identifier.get(0) : null;
525 }
526
527 /***
528 * Sets the DublinCore module identifier. Convenience method that can be
529 * used when there is only one identifier to set.
530 * <p>
531 * @param identifier the DublinCore module identifier to set, <b>null</b> if none.
532 *
533 */
534 public void setIdentifier(String identifier) {
535 _identifier = new ArrayList();
536 _identifier.add(identifier);
537 }
538
539 /***
540 * Returns the DublinCore module source.
541 * <p>
542 * @return a list of Strings representing the DublinCore module source,
543 * an empty list if none.
544 *
545 */
546 public List getSources() {
547 return (_source == null) ? (_source = new ArrayList()) : _source;
548 }
549
550 /***
551 * Sets the DublinCore module sources.
552 * <p>
553 * @param sources the list of String representing the DublinCore module
554 * sources to set, an empty list or <b>null</b> if none.
555 *
556 */
557 public void setSources(List sources) {
558 _source = sources;
559 }
560
561 /***
562 * Gets the DublinCore module source. Convenience method that can be used
563 * to obtain the first item, <b>null</b> if none.
564 * <p>
565 * @return the first DublinCore module source, <b>null</b> if none.
566 */
567 public String getSource() {
568 return ((_source != null) && (_source.size() > 0)) ?
569 (String) _source.get(0) : null;
570 }
571
572 /***
573 * Sets the DublinCore module source. Convenience method that can be used
574 * when there is only one source to set.
575 * <p>
576 * @param source the DublinCore module source to set, <b>null</b> if none.
577 *
578 */
579 public void setSource(String source) {
580 _source = new ArrayList();
581 _source.add(source);
582 }
583
584 /***
585 * Returns the DublinCore module language.
586 * <p>
587 * @return a list of Strings representing the DublinCore module language,
588 * an empty list if none.
589 *
590 */
591 public List getLanguages() {
592 return (_language == null) ? (_language = new ArrayList()) : _language;
593 }
594
595 /***
596 * Sets the DublinCore module languages.
597 * <p>
598 * @param languages the list of String representing the DublinCore module
599 * languages to set, an empty list or <b>null</b> if none.
600 *
601 */
602 public void setLanguages(List languages) {
603 _language = languages;
604 }
605
606 /***
607 * Gets the DublinCore module language. Convenience method that can be
608 * used to obtain the first item, <b>null</b> if none.
609 * <p>
610 * @return the first DublinCore module langauge, <b>null</b> if none.
611 */
612 public String getLanguage() {
613 return ((_language != null) && (_language.size() > 0)) ?
614 (String) _language.get(0) : null;
615 }
616 /***
617 * Sets the DublinCore module language. Convenience method that can be used
618 * when there is only one language to set.
619 * <p>
620 * @param language the DublinCore module language to set, <b>null</b> if none.
621 *
622 */
623 public void setLanguage(String language) {
624 _language = new ArrayList();
625 _language.add(language);
626 }
627
628 /***
629 * Returns the DublinCore module relation.
630 * <p>
631 * @return a list of Strings representing the DublinCore module relation,
632 * an empty list if none.
633 *
634 */
635 public List getRelations() {
636 return (_relation == null) ? (_relation = new ArrayList()) : _relation;
637 }
638
639 /***
640 * Sets the DublinCore module relations.
641 * <p>
642 * @param relations the list of String representing the DublinCore module
643 * relations to set, an empty list or <b>null</b> if none.
644 *
645 */
646 public void setRelations(List relations) {
647 _relation = relations;
648 }
649
650 /***
651 * Gets the DublinCore module relation. Convenience method that can be used
652 * to obtain the first item, <b>null</b> if none.
653 * <p>
654 * @return the first DublinCore module relation, <b>null</b> if none.
655 */
656 public String getRelation() {
657 return ((_relation != null) && (_relation.size() > 0)) ?
658 (String) _relation.get(0) : null;
659 }
660
661 /***
662 * Sets the DublinCore module relation. Convenience method that can be used
663 * when there is only one relation to set.
664 * <p>
665 * @param relation the DublinCore module relation to set, <b>null</b> if none.
666 *
667 */
668 public void setRelation(String relation) {
669 _relation = new ArrayList();
670 _relation.add(relation);
671 }
672
673 /***
674 * Returns the DublinCore module coverage.
675 * <p>
676 * @return a list of Strings representing the DublinCore module coverage,
677 * an empty list if none.
678 *
679 */
680 public List getCoverages() {
681 return (_coverage == null) ? (_coverage = new ArrayList()) : _coverage;
682 }
683
684 /***
685 * Sets the DublinCore module coverages.
686 * <p>
687 * @param coverages the list of String representing the DublinCore module
688 * coverages to set, an empty list or <b>null</b> if none.
689 *
690 */
691 public void setCoverages(List coverages) {
692 _coverage = coverages;
693 }
694
695 /***
696 * Gets the DublinCore module coverage. Convenience method that can be used
697 * to obtain the first item, <b>null</b> if none.
698 * <p>
699 * @return the first DublinCore module coverage, <b>null</b> if none.
700 */
701 public String getCoverage() {
702 return ((_coverage != null) && (_coverage.size() > 0)) ?
703 (String) _coverage.get(0) : null;
704 }
705
706 /***
707 * Sets the DublinCore module coverage. Convenience method that can be used
708 * when there is only one coverage to set.
709 * <p>
710 * @param coverage the DublinCore module coverage to set, <b>null</b> if none.
711 *
712 */
713 public void setCoverage(String coverage) {
714 _coverage = new ArrayList();
715 _coverage.add(coverage);
716 }
717
718 /***
719 * Returns the DublinCore module rights.
720 * <p>
721 * @return a list of Strings representing the DublinCore module rights,
722 * an empty list if none.
723 *
724 */
725 public List getRightsList() {
726 return (_rights == null) ? (_rights = new ArrayList()) : _rights;
727 }
728
729 /***
730 * Sets the DublinCore module rights.
731 * <p>
732 * @param rights the list of String representing the DublinCore module
733 * rights to set, an empty list or <b>null</b> if none.
734 *
735 */
736 public void setRightsList(List rights) {
737 _rights = rights;
738 }
739
740 /***
741 * Gets the DublinCore module rights. Convenience method that can be used
742 * to obtain the first item, <b>null</b> if none.
743 * <p>
744 * @return the first DublinCore module rights, <b>null</b> if none.
745 */
746 public String getRights() {
747 return ((_rights != null) && (_rights.size() > 0)) ?
748 (String) _rights.get(0) : null;
749 }
750
751 /***
752 * Sets the DublinCore module rights. Convenience method that can be used
753 * when there is only one rights to set.
754 * <p>
755 * @param rights the DublinCore module rights to set, <b>null</b> if none.
756 *
757 */
758 public void setRights(String rights) {
759 _rights = new ArrayList();
760 _rights.add(rights);
761 }
762
763 /***
764 * Creates a deep 'bean' clone of the object.
765 * <p>
766 * @return a clone of the object.
767 * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
768 *
769 */
770 public final Object clone() throws CloneNotSupportedException {
771 return _objBean.clone();
772 }
773
774 /***
775 * Indicates whether some other object is "equal to" this one as defined by the Object equals() method.
776 * <p>
777 * @param other he reference object with which to compare.
778 * @return <b>true</b> if 'this' object is equal to the 'other' object.
779 *
780 */
781 public final boolean equals(Object other) {
782 return _objBean.equals(other);
783 }
784
785 /***
786 * Returns a hashcode value for the object.
787 * <p>
788 * It follows the contract defined by the Object hashCode() method.
789 * <p>
790 * @return the hashcode of the bean object.
791 *
792 */
793 public final int hashCode() {
794 return _objBean.hashCode();
795 }
796
797 /***
798 * Returns the String representation for the object.
799 * <p>
800 * @return String representation for the object.
801 *
802 */
803 public final String toString() {
804 return _objBean.toString();
805 }
806
807 public final Class getInterface() {
808 return DCModule.class;
809 }
810
811 public final void copyFrom(Object obj) {
812 COPY_FROM_HELPER.copy(this,obj);
813 }
814
815 private static final CopyFromHelper COPY_FROM_HELPER;
816
817 static {
818 Map basePropInterfaceMap = new HashMap();
819 basePropInterfaceMap.put("titles", String.class);
820 basePropInterfaceMap.put("creators", String.class);
821 basePropInterfaceMap.put("subjects", DCSubject.class);
822 basePropInterfaceMap.put("descriptions", String.class);
823 basePropInterfaceMap.put("publishers", String.class);
824 basePropInterfaceMap.put("contributors", String.class);
825 basePropInterfaceMap.put("dates", Date.class);
826 basePropInterfaceMap.put("types", String.class);
827 basePropInterfaceMap.put("formats", String.class);
828 basePropInterfaceMap.put("identifiers", String.class);
829 basePropInterfaceMap.put("sources", String.class);
830 basePropInterfaceMap.put("languages", String.class);
831 basePropInterfaceMap.put("relations", String.class);
832 basePropInterfaceMap.put("coverages", String.class);
833 basePropInterfaceMap.put("rightsList", String.class);
834
835 Map basePropClassImplMap = new HashMap();
836 basePropClassImplMap.put(DCSubject.class,DCSubjectImpl.class);
837
838 COPY_FROM_HELPER = new CopyFromHelper(DCModule.class,basePropInterfaceMap,basePropClassImplMap);
839 }
840 }