1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.sun.syndication.samples.module;
18
19 import com.sun.syndication.feed.module.ModuleImpl;
20
21 import java.util.ArrayList;
22 import java.util.Date;
23 import java.util.List;
24
25 /***
26 * Sample ModuleImpl Implementation.
27 * <p>
28 * To show how to integrate a module in Rome.
29 * <p>
30 * @author Alejandro Abdelnur
31 */
32 public class SampleModuleImpl extends ModuleImpl implements SampleModule {
33 private String _bar;
34 private List _foos;
35 private Date _date;
36
37 public SampleModuleImpl() {
38 super(SampleModule.class,SampleModule.URI);
39 }
40
41 /***
42 * Returns the Sample module bar value.
43 *
44 * @return the bar value.
45 */
46 public String getBar() {
47 return _bar;
48 }
49
50 /***
51 * Sets the Sample module bar value.
52 * <p/>
53 *
54 * @param bar the bar value, <b>null</b> if none.
55 */
56 public void setBar(String bar) {
57 _bar = bar;
58 }
59
60 /***
61 * Returns the Sample module foos.
62 * <p/>
63 *
64 * @return a list of String elements with the Sample module foos,
65 * an empty list if none.
66 */
67 public List getFoos() {
68 return (_foos==null) ? (_foos=new ArrayList()) : _foos;
69 }
70
71 /***
72 * Sets the Sample module foos.
73 * <p/>
74 *
75 * @param foos the list of String elements with the Sample module foos to set,
76 * an empty list or <b>null</b> if none.
77 */
78 public void setFoos(List foos) {
79 _foos = foos;
80 }
81
82 /***
83 * Returns the Sample module date.
84 * <p/>
85 *
86 * @return the Sample module date, <b>null</b> if none.
87 */
88 public Date getDate() {
89 return _date;
90 }
91
92 /***
93 * Sets the Sample module date.
94 * <p/>
95 *
96 * @param date the Sample module date to set, <b>null</b> if none.
97 */
98 public void setDate(Date date) {
99 _date = date;
100 }
101
102 /***
103 * Returns the interface the copyFrom works on.
104 * <p/>
105 * This is useful when dealing with properties that may have multiple implementations.
106 * For example, Module.
107 * <p/>
108 *
109 * @return the interface the copyFrom works on.
110 */
111 public Class getInterface() {
112 return SampleModule.class;
113 }
114
115 /***
116 * Copies all the properties of the given bean into this one.
117 * <p/>
118 * Any existing properties in this bean are lost.
119 * <p/>
120 * This method is useful for moving from one implementation of a bean interface to another.
121 * For example from the default SyndFeed bean implementation to a Hibernate ready implementation.
122 * <p/>
123 *
124 * @param obj the instance to copy properties from.
125 */
126 public void copyFrom(Object obj) {
127 SampleModule sm = (SampleModule) obj;
128 setBar(sm.getBar());
129 List foos = new ArrayList(sm.getFoos());
130 setFoos(foos);
131 setDate((Date)sm.getDate().clone());
132 }
133
134 }