1 19 20 package org.jperdian.rss2.dom; 21 22 import java.io.Serializable ; 23 import java.net.URL ; 24 import java.util.ArrayList ; 25 import java.util.Date ; 26 import java.util.HashSet ; 27 import java.util.List ; 28 import java.util.Set ; 29 30 import org.jperdian.rss2.RssChannelUpdateListener; 31 import org.jperdian.rss2.RssClient; 32 import org.jperdian.rss2.RssException; 33 34 40 41 public class RssChannel implements Serializable { 42 43 private transient RssClient myClient = null; 44 private boolean stateDataLoaded = false; 45 private boolean stateDataLoadFailed = false; 46 private long myLastUpdate = -1; 47 48 private String myTitle = ""; 49 private URL myLink = null; 50 private String myDescription = ""; 51 private String myLanguage = ""; 52 private String myCopyright = ""; 53 private String myManagingEditor = ""; 54 private String myWebmaster = ""; 55 private Date myPubDate = null; 56 private Date myLastBuildDate = null; 57 private List myCategoryList = new ArrayList (1); 58 private String myGenerator = ""; 59 private URL myDocs = null; 60 private RssCloud myCloud = null; 61 private int myTtl = RssConstants.DEFAULT_TTL; 62 private RssImage myImage = null; 63 private String myRating = ""; 64 private Set mySkipHours = new HashSet (); 65 private Set mySkipDays = new HashSet (); 66 private List myItemList = new ArrayList (); 67 private RssTextInput myTextInput = null; 68 private List myUpdateListenerList = new ArrayList (); 69 70 public RssChannel(RssClient client) { 71 this.setClient(client); 72 } 73 74 public String toString() { 75 StringBuffer result = new StringBuffer (); 76 result.append(this.getTitle()).append(" @ ").append(this.getLink()); 77 result.append("\n").append(this.getDescription()); 78 return result.toString(); 79 } 80 81 84 public void update() throws RssException { 85 this.getClient().loadData(this); 86 } 87 88 89 93 public void addCategory(String category) { 94 this.getCategoryList().add(category); 95 } 96 97 public List getCategoryList() { 98 return this.myCategoryList; 99 } 100 101 public void setCategoryList(List categoryList) { 102 this.myCategoryList = categoryList; 103 } 104 105 public RssCloud getCloud() { 106 return this.myCloud; 107 } 108 109 public void setCloud(RssCloud cloud) { 110 this.myCloud = cloud; 111 } 112 113 public String getCopyright() { 114 return this.myCopyright; 115 } 116 117 public void setCopyright(String copyright) { 118 this.myCopyright = copyright; 119 } 120 121 public String getDescription() { 122 return this.myDescription; 123 } 124 125 public void setDescription(String description) { 126 this.myDescription = description; 127 } 128 129 public URL getDocs() { 130 return this.myDocs; 131 } 132 133 public void setDocs(URL docs) { 134 this.myDocs = docs; 135 } 136 137 public String getGenerator() { 138 return this.myGenerator; 139 } 140 141 public void setGenerator(String generator) { 142 this.myGenerator = generator; 143 } 144 145 public RssImage getImage() { 146 return this.myImage; 147 } 148 149 public void setImage(RssImage image) { 150 this.myImage = image; 151 } 152 153 public void addItem(RssItem item) { 154 this.getItemList().add(item); 155 } 156 157 public List getItemList() { 158 return this.myItemList; 159 } 160 161 public void setItemList(List itemList) { 162 this.myItemList = itemList; 163 } 164 165 public String getLanguage() { 166 return this.myLanguage; 167 } 168 169 public void setLanguage(String language) { 170 this.myLanguage = language; 171 } 172 173 public Date getLastBuildDate() { 174 return this.myLastBuildDate; 175 } 176 177 public void setLastBuildDate(Date lastBuildDate) { 178 this.myLastBuildDate = lastBuildDate; 179 } 180 181 public URL getLink() { 182 return this.myLink; 183 } 184 185 public void setLink(URL link) { 186 this.myLink = link; 187 } 188 189 public String getManagingEditor() { 190 return this.myManagingEditor; 191 } 192 193 public void setManagingEditor(String managingEditor) { 194 this.myManagingEditor = managingEditor; 195 } 196 197 public Date getPubDate() { 198 return this.myPubDate; 199 } 200 201 public void setPubDate(Date pubDate) { 202 this.myPubDate = pubDate; 203 } 204 205 public String getRating() { 206 return this.myRating; 207 } 208 209 public void setRating(String rating) { 210 this.myRating = rating; 211 } 212 213 public void addSkipDay(String day) { 214 this.getSkipDays().add(day); 215 } 216 217 public Set getSkipDays() { 218 return this.mySkipDays; 219 } 220 221 public void setSkipDays(Set skipDays) { 222 this.mySkipDays = skipDays; 223 } 224 225 public void addSkipHour(int hour) { 226 this.getSkipHours().add(new Integer (hour)); 227 } 228 229 public Set getSkipHours() { 230 return this.mySkipHours; 231 } 232 233 public void setSkipHours(Set skipHours) { 234 this.mySkipHours = skipHours; 235 } 236 237 public String getTitle() { 238 return this.myTitle; 239 } 240 241 public void setTitle(String title) { 242 this.myTitle = title; 243 } 244 245 public int getTtl() { 246 return this.myTtl; 247 } 248 249 public void setTtl(int ttl) { 250 this.myTtl = ttl; 251 } 252 253 public String getWebmaster() { 254 return this.myWebmaster; 255 } 256 257 public void setWebmaster(String webmaster) { 258 this.myWebmaster = webmaster; 259 } 260 261 public RssTextInput getTextInput() { 262 return this.myTextInput; 263 } 264 265 public void setTextInput(RssTextInput textInput) { 266 this.myTextInput = textInput; 267 } 268 269 272 public void setDataLoaded(boolean state) { 273 this.stateDataLoaded = state; 274 } 275 276 279 public boolean isDataLoaded() { 280 return this.stateDataLoaded; 281 } 282 283 286 public void setDataLoadFailed(boolean state) { 287 this.stateDataLoadFailed = state; 288 } 289 290 293 public boolean isDataLoadFailed() { 294 return this.stateDataLoadFailed; 295 } 296 297 300 public void setClient(RssClient client) { 301 this.myClient = client; 302 } 303 304 307 public RssClient getClient() { 308 return this.myClient; 309 } 310 311 314 public void setLastUpdate(long time) { 315 this.myLastUpdate = time; 316 } 317 318 321 public long getLastUpdate() { 322 return this.myLastUpdate; 323 } 324 325 329 protected List getUpdateListenerList() { 330 return this.myUpdateListenerList; 331 } 332 333 336 protected void fireChannelUpdate() { 337 for(int i=0; i < this.getUpdateListenerList().size(); i++) { 338 ((RssChannelUpdateListener)this.getUpdateListenerList().get(i)).channelUpdated(this); 339 } 340 } 341 342 345 public void addUpdateListener(RssChannelUpdateListener listener) { 346 this.getUpdateListenerList().add(listener); 347 } 348 349 352 public void removeUpdateListener(RssChannelUpdateListener listener) { 353 this.getUpdateListenerList().remove(listener); 354 } 355 356 } | Popular Tags |