001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.commons.betwixt.examples.rss;
019:
020: import java.io.Serializable;
021: import java.util.ArrayList;
022: import java.util.List;
023:
024: /**
025: * <p>Implementation object representing a <strong>channel</strong> in the
026: * <em>Rich Site Summary</em> DTD, version 0.91. This class may be subclassed
027: * to further specialize its behavior.</p>
028: *
029: * <p>Based on the Jakarta Commons <code>Digester</code> implementation.</p>
030: *
031: * @author Craig R. McClanahan
032: * @author Ted Husted
033: * @version $Revision: 438373 $ $Date: 2006-08-30 06:17:21 +0100 (Wed, 30 Aug 2006) $
034: */
035:
036: public class Channel implements Serializable {
037:
038: // ----------------------------------------------------- Instance Variables
039:
040: /**
041: * The set of items associated with this Channel.
042: */
043: protected ArrayList items = new ArrayList();
044:
045: /**
046: * The set of skip days for this channel.
047: */
048: protected ArrayList skipDays = new ArrayList();
049:
050: /**
051: * The set of skip hours for this channel.
052: */
053: protected ArrayList skipHours = new ArrayList();
054:
055: // ------------------------------------------------------------- Properties
056:
057: /**
058: * The channel copyright (1-100 characters).
059: */
060: protected String copyright = null;
061:
062: public String getCopyright() {
063: if (this .copyright == null) {
064: return "Public Domain";
065: } else {
066: return (this .copyright);
067: }
068: }
069:
070: public void setCopyright(String copyright) {
071: this .copyright = copyright;
072: }
073:
074: /**
075: * The channel description (1-500 characters).
076: */
077: protected String description = null;
078:
079: public String getDescription() {
080: return (this .description);
081: }
082:
083: public void setDescription(String description) {
084: this .description = description;
085: }
086:
087: /**
088: * The channel description file URL (1-500 characters).
089: */
090: protected String docs = null;
091:
092: public String getDocs() {
093: return (this .docs);
094: }
095:
096: public void setDocs(String docs) {
097: this .docs = docs;
098: }
099:
100: /**
101: * The image describing this channel.
102: */
103: protected Image image = null;
104:
105: public Image getImage() {
106: return (this .image);
107: }
108:
109: public void setImage(Image image) {
110: this .image = image;
111: }
112:
113: /**
114: * The channel language (2-5 characters).
115: */
116: protected String language = null;
117:
118: public String getLanguage() {
119: return (this .language);
120: }
121:
122: public void setLanguage(String language) {
123: this .language = language;
124: }
125:
126: /**
127: * The channel last build date (1-100 characters).
128: */
129: protected String lastBuildDate = null;
130:
131: public String getLastBuildDate() {
132: return (this .lastBuildDate);
133: }
134:
135: public void setLastBuildDate(String lastBuildDate) {
136: this .lastBuildDate = lastBuildDate;
137: }
138:
139: /**
140: * The channel link (1-500 characters).
141: */
142: protected String link = null;
143:
144: public String getLink() {
145: return (this .link);
146: }
147:
148: public void setLink(String link) {
149: this .link = link;
150: }
151:
152: /**
153: * The managing editor (1-100 characters).
154: */
155: protected String managingEditor = null;
156:
157: public String getManagingEditor() {
158: return (this .managingEditor);
159: }
160:
161: public void setManagingEditor(String managingEditor) {
162: this .managingEditor = managingEditor;
163: }
164:
165: /**
166: * The channel publication date (1-100 characters).
167: */
168: protected String pubDate = null;
169:
170: public String getPubDate() {
171: return (this .pubDate);
172: }
173:
174: public void setPubDate(String pubDate) {
175: this .pubDate = pubDate;
176: }
177:
178: /**
179: * The channel rating (20-500 characters).
180: */
181: protected String rating = null;
182:
183: public String getRating() {
184: return (this .rating);
185: }
186:
187: public void setRating(String rating) {
188: this .rating = rating;
189: }
190:
191: /**
192: * The text input description for this channel.
193: */
194: protected TextInput textInput = null;
195:
196: public TextInput getTextInput() {
197: return (this .textInput);
198: }
199:
200: public void setTextInput(TextInput textInput) {
201: this .textInput = textInput;
202: }
203:
204: /**
205: * The channel title (1-100 characters).
206: */
207: protected String title = null;
208:
209: public String getTitle() {
210: return (this .title);
211: }
212:
213: public void setTitle(String title) {
214: this .title = title;
215: }
216:
217: /**
218: * The RSS specification version number used to create this Channel.
219: */
220: protected double version = 0.91;
221:
222: public double getVersion() {
223: return (this .version);
224: }
225:
226: public void setVersion(double version) {
227: this .version = version;
228: }
229:
230: /**
231: * The webmaster email address (1-100 characters).
232: */
233: protected String webMaster = null;
234:
235: public String getWebMaster() {
236: return (this .webMaster);
237: }
238:
239: public void setWebMaster(String webMaster) {
240: this .webMaster = webMaster;
241: }
242:
243: // --------------------------------------------------------- Public Methods
244:
245: /**
246: * Add an additional item.
247: *
248: * @param item The item to be added
249: */
250: public void addItem(Item item) {
251: synchronized (items) {
252: items.add(item);
253: }
254: }
255:
256: /**
257: * Add an additional skip day name.
258: *
259: * @param skipDay The skip day to be added
260: */
261: public void addSkipDay(String skipDay) {
262: synchronized (skipDays) {
263: skipDays.add(skipDay);
264: }
265: }
266:
267: /**
268: * Add an additional skip hour name.
269: *
270: * @param skipHour The skip hour to be added
271: */
272: public void addSkipHour(String skipHour) {
273: synchronized (skipHours) {
274: skipHours.add(skipHour);
275: }
276: }
277:
278: /**
279: * Return the items for this channel.
280: */
281: public List getItems() {
282: return items;
283: }
284:
285: /**
286: * Return the skip days for this channel.
287: */
288: public String[] findSkipDays() {
289: synchronized (skipDays) {
290: String skipDays[] = new String[this .skipDays.size()];
291: return ((String[]) this .skipDays.toArray(skipDays));
292: }
293: }
294:
295: /**
296: * Return the skip hours for this channel.
297: */
298: public String[] getSkipHours() {
299: return findSkipHours();
300: }
301:
302: /**
303: * Return the skip hours for this channel.
304: */
305: public String[] findSkipHours() {
306: synchronized (skipHours) {
307: String skipHours[] = new String[this .skipHours.size()];
308: return ((String[]) this .skipHours.toArray(skipHours));
309: }
310: }
311:
312: /**
313: * Return the skip days for this channel.
314: */
315: public String[] getSkipDays() {
316: return findSkipDays();
317: }
318:
319: /**
320: * Remove an item for this channel.
321: *
322: * @param item The item to be removed
323: */
324: public void removeItem(Item item) {
325: synchronized (items) {
326: items.remove(item);
327: }
328: }
329:
330: /**
331: * Remove a skip day for this channel.
332: *
333: * @param skipDay The skip day to be removed
334: */
335: public void removeSkipDay(String skipDay) {
336: synchronized (skipDays) {
337: skipDays.remove(skipDay);
338: }
339: }
340:
341: /**
342: * Remove a skip hour for this channel.
343: *
344: * @param skipHour The skip hour to be removed
345: */
346: public void removeSkipHour(String skipHour) {
347: synchronized (skipHours) {
348: skipHours.remove(skipHour);
349: }
350: }
351: }
|