001: /**********************************************************************************
002:
003: Feedzeo!
004: A free and open source RSS/Atom/RDF feed aggregator
005:
006: Copyright (C) 2005-2006 Anand Rao (anandrao@users.sourceforge.net)
007:
008: This library is free software; you can redistribute it and/or
009: modify it under the terms of the GNU Lesser General Public
010: License as published by the Free Software Foundation; either
011: version 2.1 of the License, or (at your option) any later version.
012:
013: This library is distributed in the hope that it will be useful,
014: but WITHOUT ANY WARRANTY; without even the implied warranty of
015: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: Lesser General Public License for more details.
017:
018: You should have received a copy of the GNU Lesser General Public
019: License along with this library; if not, write to the Free Software
020: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
021:
022: ************************************************************************************/package data;
023:
024: import java.util.*;
025: import java.net.*;
026:
027: import util.DateUtil;
028:
029: /**
030: *
031: * @author Anand Rao
032: */
033: public class ChannelData {
034:
035: //int ChannelFormat;
036: private String FeedSourceURL; // url to the feedsource
037: private String Copyright;
038: private String Creator;
039: private String Title;
040: private String Description;
041: private URL ImageLink;
042: private Date PublishDate;
043: private String Publisher;
044: private long FeedSourceLastModified; // time in ms when the url to feedsource
045: // was last modified
046:
047: private String HTMLfilename; /*
048: * link to the HTML page generated for this
049: * feed; this is set by the page generator
050: * when it generates a page
051: */
052: private String HTMLTableDatafilename; /* link to the HTML file which contains
053: HTML code for only main table with all the
054: feed information, but excluding <head>
055: & <body> tags; This file is useful when
056: users want to embed the feed data into an
057: HTML page; So in those cases, the user can just
058: request for this file and embed the data into
059: their own HTML page
060: */
061:
062: private Vector ItemCollection; /* Vector holding collection of news items */
063:
064: /** Creates a new instance of ChannelData */
065: public ChannelData() {
066: ItemCollection = new Vector();
067: }
068:
069: public void addItem(ItemData item) {
070: ItemCollection.addElement(item);
071: }
072:
073: public int getNumItems() {
074: return (ItemCollection.size());
075: }
076:
077: public ItemData getItem(int Index) {
078: if (getNumItems() == 0)
079: return null;
080: return ((ItemData) ItemCollection.elementAt(Index));
081: }
082:
083: /*
084: public int getChannelFormat() {
085: return ChannelFormat;
086: }
087: */
088:
089: public String getCopyright() {
090: return Copyright;
091: }
092:
093: public String getCreator() {
094: return Creator;
095: }
096:
097: public String getTitle() {
098: return Title;
099: }
100:
101: public String getDescription() {
102: return Description;
103: }
104:
105: public String getImageLink() {
106: return ImageLink.toString();
107: }
108:
109: public Date getPublishDate() {
110: return PublishDate;
111: }
112:
113: public String getPublisher() {
114: return Publisher;
115: }
116:
117: public String getHTMLfilename() {
118: return HTMLfilename;
119: }
120:
121: public String getHTMLTableDatafilename() {
122: return HTMLTableDatafilename;
123: }
124:
125: public String getFeedSourceURL() {
126: return FeedSourceURL;
127: }
128:
129: public long getFeedSourceLastModified() {
130: return FeedSourceLastModified;
131: }
132:
133: /*
134: public void setChannelFormat(int ChannelFormat) {
135: this.ChannelFormat = ChannelFormat;
136: }
137: */
138:
139: public void setCopyright(String Copyright) {
140: this .Copyright = Copyright;
141: }
142:
143: public void setCreator(String Creator) {
144: this .Creator = Creator;
145: }
146:
147: public void setTitle(String Title) {
148: this .Title = Title;
149: }
150:
151: public void setDescription(String Description) {
152: this .Description = Description;
153: }
154:
155: public void setImageLink(URL ImageLink) {
156: this .ImageLink = ImageLink;
157: }
158:
159: public void setPublishDate(Date PublishDate) {
160: this .PublishDate = PublishDate;
161: }
162:
163: public void setPublisher(String Publisher) {
164: this .Publisher = Publisher;
165: }
166:
167: public void setHTMLfilename(String fname) {
168: HTMLfilename = fname;
169: }
170:
171: public void setHTMLTableDatafilename(String fname) {
172: HTMLTableDatafilename = fname;
173: }
174:
175: public void setFeedSourceURL(String url) {
176: FeedSourceURL = url;
177: }
178:
179: public void setFeedSourceLastModified(long lastModifiedTime) {
180: FeedSourceLastModified = lastModifiedTime;
181: }
182:
183: public String getData(String type) {
184: if (type.equalsIgnoreCase(DataElement.FEED_TITLE_ELEM))
185: if (Title != null)
186: return Title;
187: else
188: return "";
189: if (type.equalsIgnoreCase(DataElement.FEED_DESC_ELEM))
190: if (Description != null)
191: return Description;
192: else
193: return "";
194: if (type.equalsIgnoreCase(DataElement.FEED_IMAGE_ELEM))
195: if (ImageLink != null)
196: return ImageLink.toString();
197: else
198: return "";
199: if (type.equalsIgnoreCase(DataElement.FEED_DATE_ELEM))
200: if (PublishDate != null)
201: return DateUtil.getMonthDayYearStr(PublishDate); //PublishDate.toString();
202: else
203: return "";
204:
205: // todo lots more to add
206: return "";
207: }
208:
209: public String getItemData(String type, int index) {
210: if ((index < 0) || (index >= ItemCollection.size()))
211: return ("");
212: ItemData id = (ItemData) ItemCollection.elementAt(index);
213: return id.getData(type);
214: }
215:
216: };
|