1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.sun.syndication.feed.atom;
18
19 import com.sun.syndication.feed.impl.ObjectBean;
20
21 import java.io.Serializable;
22 import java.util.HashSet;
23 import java.util.Set;
24
25 /***
26 * Bean for content elements of Atom feeds.
27 * <p>
28 * @author Alejandro Abdelnur
29 *
30 */
31 public class Content implements Cloneable,Serializable {
32 public static final String XML = "xml";
33 public static final String BASE64 = "base64";
34 public static final String ESCAPED = "escaped";
35
36 private static final Set MODES = new HashSet();
37
38 static {
39 MODES.add(XML);
40 MODES.add(BASE64);
41 MODES.add(ESCAPED);
42 }
43
44 private ObjectBean _objBean;
45 private String _type;
46 private String _mode;
47 private String _value;
48
49 /***
50 * Default constructor. All properties are set to <b>null</b>.
51 * <p>
52 *
53 */
54 public Content() {
55 _objBean = new ObjectBean(this.getClass(),this);
56 }
57
58 /***
59 * Creates a deep 'bean' clone of the object.
60 * <p>
61 * @return a clone of the object.
62 * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
63 *
64 */
65 public Object clone() throws CloneNotSupportedException {
66 return _objBean.clone();
67 }
68
69 /***
70 * Indicates whether some other object is "equal to" this one as defined by the Object equals() method.
71 * <p>
72 * @param other he reference object with which to compare.
73 * @return <b>true</b> if 'this' object is equal to the 'other' object.
74 *
75 */
76 public boolean equals(Object other) {
77 return _objBean.equals(other);
78 }
79
80 /***
81 * Returns a hashcode value for the object.
82 * <p>
83 * It follows the contract defined by the Object hashCode() method.
84 * <p>
85 * @return the hashcode of the bean object.
86 *
87 */
88 public int hashCode() {
89 return _objBean.hashCode();
90 }
91
92 /***
93 * Returns the String representation for the object.
94 * <p>
95 * @return String representation for the object.
96 *
97 */
98 public String toString() {
99 return _objBean.toString();
100 }
101
102 /***
103 * Returns the content type.
104 * <p>
105 * @return the content type, <b>null</b> if none.
106 *
107 */
108 public String getType() {
109 return _type;
110 }
111
112 /***
113 * Sets the content type.
114 * <p>
115 * @param type the content type, <b>null</b> if none.
116 *
117 */
118 public void setType(String type) {
119 _type = type;
120 }
121
122 /***
123 * Returns the content mode.
124 * <p>
125 * The mode indicates how the value was/will-be encoded in the XML feed.
126 * <p>
127 * @return the content mode, <b>null</b> if none.
128 *
129 */
130 public String getMode() {
131 return _mode;
132 }
133
134 /***
135 * Sets the content mode.
136 * <p>
137 * The mode indicates how the value was/will-be encoded in the XML feed.
138 * <p>
139 * @param mode the content mode, <b>null</b> if none.
140 *
141 */
142 public void setMode(String mode) {
143 mode = (mode!=null) ? mode.toLowerCase() : null;
144 if (mode==null || !MODES.contains(mode)) {
145 throw new IllegalArgumentException("Invalid mode ["+mode+"]");
146 }
147 _mode = mode;
148 }
149
150 /***
151 * Returns the content value.
152 * <p>
153 * The return value should be decoded.
154 * <p>
155 * @return the content value, <b>null</b> if none.
156 *
157 */
158 public String getValue() {
159 return _value;
160 }
161
162 /***
163 * Sets the content value.
164 * <p>
165 * The value being set should be decoded.
166 * <p>
167 * @param value the content value, <b>null</b> if none.
168 *
169 */
170 public void setValue(String value) {
171 _value = value;
172 }
173
174 }
175
176