KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > syndication > feed > WireFeed


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;
18
19 import com.sun.syndication.feed.impl.ObjectBean;
20 import com.sun.syndication.feed.module.Module;
21 import com.sun.syndication.feed.module.impl.ModuleUtils;
22
23 import java.util.List JavaDoc;
24 import java.util.ArrayList JavaDoc;
25 import java.io.Serializable JavaDoc;
26
27 /**
28  * Parent class of the RSS (Channel) and Atom (Feed) feed beans.
29  * <p>
30  * NOTE: We don't like this class at this package level but the alternative would have
31  * been a proliferation of packages (one more level to hold atom and rss package with
32  * this class just in that package).
33  * <p>
34  * The format of the 'type' property must be [FEEDNAME]_[FEEDVERSION] with the FEEDNAME in lower case,
35  * for example: rss_0.9, rss_0.93, atom_0.3
36  * <p>
37  * @author Alejandro Abdelnur
38  *
39  */

40 public abstract class WireFeed implements Cloneable JavaDoc,Serializable JavaDoc {
41     private ObjectBean _objBean;
42     private String JavaDoc _feedType;
43     private String JavaDoc _encoding;
44     private List JavaDoc _modules;
45
46     /**
47      * Default constructor, for bean cloning purposes only.
48      * <p>
49      *
50      */

51     protected WireFeed() {
52         _objBean = new ObjectBean(this.getClass(),this);
53     }
54
55     /**
56      * Creates a feed for a given type.
57      * <p>
58      * @param type of the feed to create.
59      *
60      */

61     protected WireFeed(String JavaDoc type) {
62         this();
63         _feedType = type;
64     }
65
66     /**
67      * Creates a deep 'bean' clone of the object.
68      * <p>
69      * @return a clone of the object.
70      * @throws CloneNotSupportedException thrown if an element of the object cannot be cloned.
71      *
72      */

73     public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
74         return _objBean.clone();
75     }
76
77     /**
78      * Indicates whether some other object is "equal to" this one as defined by the Object equals() method.
79      * <p>
80      * @param other he reference object with which to compare.
81      * @return <b>true</b> if 'this' object is equal to the 'other' object.
82      *
83      */

84     public boolean equals(Object JavaDoc other) {
85         return _objBean.equals(other);
86     }
87
88     /**
89      * Returns a hashcode value for the object.
90      * <p>
91      * It follows the contract defined by the Object hashCode() method.
92      * <p>
93      * @return the hashcode of the bean object.
94      *
95      */

96     public int hashCode() {
97         return _objBean.hashCode();
98     }
99
100     /**
101      * Returns the String representation for the object.
102      * <p>
103      * @return String representation for the object.
104      *
105      */

106     public String JavaDoc toString() {
107         return _objBean.toString();
108     }
109
110
111
112
113
114     /**
115      * Sets the feedType of a the feed. <b>Do not use</b>, for bean cloning purposes only.
116      * <p>
117      * @param feedType the feedType of the feed.
118      *
119      */

120     public void setFeedType(String JavaDoc feedType) {
121         _feedType = feedType;
122     }
123
124     /**
125      * Returns the type of the feed.
126      *
127      * @return the type of the feed.
128      */

129     public String JavaDoc getFeedType() {
130         return _feedType;
131     }
132
133     /**
134      * Returns the charset encoding of a the feed.
135      * <p>
136      * This property is not set by feed parsers. But it is used by feed generators
137      * to set the encoding in the XML prolog.
138      * <p>
139      * @return the charset encoding of the feed.
140      *
141      */

142     public String JavaDoc getEncoding() {
143         return _encoding;
144     }
145
146     /**
147      * Sets the charset encoding of a the feed.
148      * <p>
149      * This property is not set by feed parsers. But it is used by feed generators
150      * to set the encoding in the XML prolog.
151      * <p>
152      * @param encoding the charset encoding of the feed.
153      *
154      */

155     public void setEncoding(String JavaDoc encoding) {
156         _encoding = encoding;
157     }
158
159
160     /**
161      * Returns the channel modules.
162      * <p>
163      * @return a list of ModuleImpl elements with the channel modules,
164      * an empty list if none.
165      *
166      */

167     public List JavaDoc getModules() {
168         return (_modules==null) ? (_modules=new ArrayList JavaDoc()) : _modules;
169     }
170
171     /**
172      * Sets the channel modules.
173      * <p>
174      * @param modules the list of ModuleImpl elements with the channel modules to set,
175      * an empty list or <b>null</b> if none.
176      *
177      */

178     public void setModules(List JavaDoc modules) {
179         _modules = modules;
180     }
181
182     /**
183      * Returns the module identified by a given URI.
184      * <p>
185      * @param uri the URI of the ModuleImpl.
186      * @return The module with the given URI, <b>null</b> if none.
187      */

188     public Module getModule(String JavaDoc uri) {
189         return ModuleUtils.getModule(_modules,uri);
190     }
191
192 }
193
Popular Tags