KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > syndication > feed > atom > Content


1 /*
2  * Copyright 2004 Sun Microsystems, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17 package com.sun.syndication.feed.atom;
18
19 import com.sun.syndication.feed.impl.ObjectBean;
20
21 import java.io.Serializable JavaDoc;
22 import java.util.HashSet JavaDoc;
23 import java.util.Set JavaDoc;
24
25 /**
26  * Bean for content elements of Atom feeds.
27  * <p>
28  * @author Alejandro Abdelnur
29  *
30  */

31 public class Content implements Cloneable JavaDoc,Serializable JavaDoc {
32     public static final String JavaDoc XML = "xml";
33     public static final String JavaDoc BASE64 = "base64";
34     public static final String JavaDoc ESCAPED = "escaped";
35
36     private static final Set JavaDoc MODES = new HashSet JavaDoc();
37
38     static {
39         MODES.add(XML);
40         MODES.add(BASE64);
41         MODES.add(ESCAPED);
42     }
43
44     private ObjectBean _objBean;
45     private String JavaDoc _type;
46     private String JavaDoc _mode;
47     private String JavaDoc _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 JavaDoc clone() throws CloneNotSupportedException JavaDoc {
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 JavaDoc 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 JavaDoc 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 JavaDoc 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 JavaDoc 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 JavaDoc 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 JavaDoc mode) {
143         mode = (mode!=null) ? mode.toLowerCase() : null;
144         if (mode==null || !MODES.contains(mode)) {
145             throw new IllegalArgumentException JavaDoc("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 JavaDoc 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 JavaDoc value) {
171         _value = value;
172     }
173
174 }
175
176
177
Popular Tags