fable.adt
Class Feed

java.lang.Object
  extended by fable.adt.FableComponent
      extended by fable.adt.Feed
All Implemented Interfaces:
FableContainer

public class Feed
extends FableComponent

This class represents a feed that contains articles. Feed has information about the feed URL.

Author:
Wonsik Kim

Constructor Summary
Feed(java.lang.String feedURL)
          Construct a new Feed with provided feedURL.
 
Method Summary
 void accept(FableVisitor v)
          Accept the visitor v to visit this.
 void acceptRecursive(FableVisitor v)
          Accept the visitor v to visit this, and recurse on children of this.
 boolean addChild(FableComponent fc)
          Feed can only have articles as a children.
 int getCacheTime()
          Returns cache time of this feed.
 java.net.URL getFeedURL()
          Returns an URL object from which the feed retrieves articles.
 java.util.Date getLastRefreshedTime()
          Returns last refreshed date of this feed.
 int getRefreshRate()
          Returns the refresh rate of this feed.
 boolean isCustomFeed()
          Checks if the feed is a custom feed from the hard disk
 boolean isSimilarTo(FableComponent fc)
          Returns true if this and fc are similar.
 void setCacheTime(int time)
          Sets the cache time of this feed.
 void setFeedURL(java.lang.String feedURL)
          Set the feed URL of this as the provided feedURL.
 void setLastRefreshedTime(java.util.Date d)
          Set the last refreshed time ad Date d.
 void setRefreshRate(int rate)
          Set the refresh rate of this to the provided rate.
 java.lang.String toString()
          Returns string representation of this feed.
 
Methods inherited from class fable.adt.FableComponent
activate, addStructuralChangeListener, getChildren, getDate, getDescendants, getParent, getPosition, getTitle, isAncestorOf, moveDown, moveUp, removeAllListeners, removeChild, removeStructuralChangeListener, setParent, setPosition, setTitle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Feed

public Feed(java.lang.String feedURL)
     throws java.net.MalformedURLException
Construct a new Feed with provided feedURL.

Parameters:
feedURL - a string corresponds to the feed URL.
Throws:
java.net.MalformedURLException - if feedURL is not a correct URL.
java.lang.NullPointerException - if feedURL is null.
Effects:
construct a new Feed object.
Modifies:
this
Method Detail

isSimilarTo

public boolean isSimilarTo(FableComponent fc)
Returns true if this and fc are similar. In this case, similar means that two components are equals.

Specified by:
isSimilarTo in class FableComponent
Parameters:
fc - FableComponent object to compare.
Returns:
true if this and fc are similar.

isCustomFeed

public boolean isCustomFeed()
Checks if the feed is a custom feed from the hard disk

Returns:
true if it is, false otherwise

toString

public java.lang.String toString()
Returns string representation of this feed.

Overrides:
toString in class java.lang.Object
Returns:
string representation of this feed.

addChild

public boolean addChild(FableComponent fc)
Feed can only have articles as a children.

Specified by:
addChild in interface FableContainer
Overrides:
addChild in class FableComponent
Parameters:
fc - a FableComponent to add as a child of this.
Returns:
true if adding child succeed, when fc is null, just returns false.
Effects:
add fc as children of this.
Modifies:
this.children, fc.parent

getFeedURL

public java.net.URL getFeedURL()
Returns an URL object from which the feed retrieves articles.

Returns:
an URL object from which the feed retrieves articles.

getRefreshRate

public int getRefreshRate()
Returns the refresh rate of this feed.

Returns:
the refresh rate of this feed.

getCacheTime

public int getCacheTime()
Returns cache time of this feed.

Returns:
cache time of this feed.

getLastRefreshedTime

public java.util.Date getLastRefreshedTime()
Returns last refreshed date of this feed.

Returns:
last refreshed date of this feed.

setFeedURL

public void setFeedURL(java.lang.String feedURL)
                throws java.net.MalformedURLException
Set the feed URL of this as the provided feedURL.

Parameters:
feedURL - a string represents to the new feed URL to replace the old one.
Throws:
java.lang.NullPointerException - if feedURL is null.
java.net.MalformedURLException
Effects:
set URL of this.
Modifies:
this.feedURL

setRefreshRate

public void setRefreshRate(int rate)
Set the refresh rate of this to the provided rate.

Parameters:
rate - the rate that is to be the refresh rate of this.
Effects:
set refresh rate of this.
Modifies:
this.refreshRate

setCacheTime

public void setCacheTime(int time)
Sets the cache time of this feed.

Parameters:
time - an integer to be the cache time of this feed.
Effects:
set cache time of this.
Modifies:
this.cacheTime

setLastRefreshedTime

public void setLastRefreshedTime(java.util.Date d)
Set the last refreshed time ad Date d.

Parameters:
d - a new Date to be the last refreshed time of this feed.
Effects:
set last refreshed time of this.
Modifies:
this.lastRefreshedTime

accept

public void accept(FableVisitor v)
Description copied from class: FableComponent
Accept the visitor v to visit this.

Specified by:
accept in class FableComponent
Parameters:
v - the visitor to visit this.

acceptRecursive

public void acceptRecursive(FableVisitor v)
Description copied from class: FableComponent
Accept the visitor v to visit this, and recurse on children of this.

Specified by:
acceptRecursive in class FableComponent
Parameters:
v - the visitor to visit this and decendants of this.