net.sourceforge.java.feednread.backend.model.favoritestree
Class Favorite

java.lang.Object
  extended bynet.sourceforge.java.util.gui.jface.viewers.MutableTreeElement
      extended bynet.sourceforge.java.feednread.backend.model.favoritestree.Favorite
All Implemented Interfaces:
IFilterTag, IGUID, IMutableTreeElement, INameable, INewsFeedStatus, INewsFeedTableStatusListener, ITreeElement

public class Favorite
extends MutableTreeElement
implements IGUID, IFilterTag, INameable, INewsFeedStatus, INewsFeedTableStatusListener

Favorite represents a NewsFeed bookmark in the NewsFeedFavoritesTree component.

Author:
Sebastian Machhausen

Field Summary
private  boolean error
           true if the Favorite caused an error last time its associated NewsFeed was loaded; false if everything went fine.
private  boolean filtered
           true if the Favorite is filtered; false if unfiltered
private  String guid
           The GUID of a Favorite
private  List newsFeedStatusListener
           The list of registered INewsFeedStatusListener instances.
private  List registeredWatches
           A List containing all Watches observing the Favorite
private  String title
           The title of the Favorite
private  JobExecutionStatus updateStatus
           The JobExecutionStatus object of the update job responsible for the Favorite
private  String url
           The url pointing to the NewsFeed of the Favorite
 
Fields inherited from class net.sourceforge.java.util.gui.jface.viewers.MutableTreeElement
 
Constructor Summary
Favorite(String title, NewsFeed newsFeed)
           Creates a new Favorite with the specified title and newsFeed.
Favorite(String title, String url)
           Creates a new Favorite with the specified title and url.
Favorite(String title, String url, String guid)
           Creates a new Favorite with the specified title and url.
 
Method Summary
 void addNewsFeedStatusListener(INewsFeedStatusListener listener)
           Adds the specified INewsFeedStatusListener to the list of registered listeners.
 void closing(NewsFeedTableStatusChangedEvent event)
           Triggered when the NewsFeedTable is about to be closed.
 void dispose()
           Disposes this Favorite.
protected  void fireNewsFeedReadStatusChanged()
           Notifies all registered INewsFeedStatusListener instances that the read status of the NewsFeed associated to this Favorite has changed.
protected  void fireNewsFeedUpdated()
           Notifies all registered INewsFeedStatusListener instances that the NewsFeed associated to this Favorite has been upated.
 String getGUID()
           Gets the GUID of this Favorite.
 NewsFeed getNewsFeed()
           Gets the NewsFeed of this Favorite.
 Watch[] getRegisteredWatches()
           Gets all Watches that this Favorite is registered at, i.e. observed by.
 String getTitle()
           Gets the title of this Favorite.
 int getUnreadCount()
           Returns the number of unread news in the NewsFeed related to this Favorite.
 JobExecutionStatus getUpdateStatus()
           Gets the update status of this Favorite.
 String getUrl()
           Gets the url pointing to the newsfeed of this Favorite.
private  void initializeEventListener()
           Initializes the internal event listener list structure.
 boolean isError()
           Indicates if this Favorite caused an error last time its NewsFeed was loaded.
 boolean isFiltered()
           Gets the filtered status of this Favorite.
 boolean isScheduled()
           Returns true if this Favorite is scheduled for automatic update.
 boolean isUnread()
           Returns true if the NewsFeed related to this Favorite
 void registerWatch(Watch watch)
           Registers the specified Watch, i.e. notifies this Favorite that it is observed by the specified Watch.
 void removeINewsFeedStatusListener(INewsFeedStatusListener listener)
           Removes the specified INewsFeedStatusListener from the list of registered listeners.
 void setError(boolean error)
           Sets the error flag of this Favorite.
 void setFiltered(boolean filtered)
           Sets the filtered status of this Favorite.
 void setNewsFeed(NewsFeed newsFeed)
           Sets the NewsFeed of this Favorite.
 void setTitle(String title)
           Sets the title of this Favorite.
 void setUpdateStatus(JobExecutionStatus status)
           Sets the update status of this Favorite to the specified JobExceutionStatus object.
 void setUrl(String url)
           Sets the url pointing to the newsfeed of this Favorite.
 void statusChanged(NewsFeedTableStatusChangedEvent event)
           Triggered when the status of the NewsFeedTable changes.
 String toString()
           Gets the textual represntation of this Favorite.
 void unregisterWatch(Watch watch)
           Unegisters the specified Watch, i.e. notifies this Favorite that it is no longer observed by the specified Watch.
private  void updateParents()
           Updates all parent Categories of this Favorite.
 
Methods inherited from class net.sourceforge.java.util.gui.jface.viewers.MutableTreeElement
add, addIMutableTreeElementListener, allowsSubElements, collectLeafs, fireElementAdded, fireElementRemoved, fireElementUpdated, getData, getElementAt, getElements, getIndex, getParent, getPath, getSize, hasSubElements, isSubElement, remove, removeIMutableTreeElementListener, setData, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

guid

private String guid

The GUID of a Favorite


title

private String title

The title of the Favorite


url

private String url

The url pointing to the NewsFeed of the Favorite


filtered

private boolean filtered

true if the Favorite is filtered; false if unfiltered


error

private boolean error

true if the Favorite caused an error last time its associated NewsFeed was loaded; false if everything went fine.


updateStatus

private JobExecutionStatus updateStatus

The JobExecutionStatus object of the update job responsible for the Favorite


registeredWatches

private List registeredWatches

A List containing all Watches observing the Favorite


newsFeedStatusListener

private List newsFeedStatusListener

The list of registered INewsFeedStatusListener instances.

Constructor Detail

Favorite

public Favorite(String title,
                String url)

Creates a new Favorite with the specified title and url.

Parameters:
title - the title of this Favorite
url - the url pointing to the NewsFeed of this Favorite
See Also:
Favorite(String, NewsFeed), Favorite(String, String, String)

Favorite

public Favorite(String title,
                NewsFeed newsFeed)

Creates a new Favorite with the specified title and newsFeed.

Parameters:
title - the title of this Favorite
newsFeed - the NewsFeed for this Favorite
See Also:
Favorite(String, String), Favorite(String, String, String)

Favorite

public Favorite(String title,
                String url,
                String guid)

Creates a new Favorite with the specified title and url.

Parameters:
title - the title of this Favorite
url - the url pointing to the NewsFeed of this Favorite
guid - the GUID for this Favorite
See Also:
Favorite(String, NewsFeed), Favorite(String, String)
Method Detail

getGUID

public String getGUID()

Gets the GUID of this Favorite.

Specified by:
getGUID in interface IGUID
Returns:
the GUID of this Favorite
See Also:
IGUID.getGUID()

setTitle

public void setTitle(String title)

Sets the title of this Favorite.

Specified by:
setTitle in interface INameable
Parameters:
title - the title of this Favorite

getTitle

public String getTitle()

Gets the title of this Favorite.

Specified by:
getTitle in interface INameable
Returns:
the title of this Favorite

setUrl

public void setUrl(String url)

Sets the url pointing to the newsfeed of this Favorite.

Parameters:
url - the url pointing to the newsfeed of this Favorite

getUrl

public String getUrl()

Gets the url pointing to the newsfeed of this Favorite.

Returns:
the url pointing to the newsfeed of this Favorite

setNewsFeed

public void setNewsFeed(NewsFeed newsFeed)

Sets the NewsFeed of this Favorite.

Parameters:
newsFeed - the NewsFeed to set
See Also:
getNewsFeed()

getNewsFeed

public NewsFeed getNewsFeed()

Gets the NewsFeed of this Favorite.

Returns:
the NewsFeed of this Favorite
See Also:
setNewsFeed(NewsFeed)

isUnread

public boolean isUnread()

Returns true if the NewsFeed related to this Favorite

Specified by:
isUnread in interface INewsFeedStatus
Returns:
true if the NewsFeed related to this Favoritefalse otherwise
See Also:
INewsFeedStatus.isUnread()

getUnreadCount

public int getUnreadCount()

Returns the number of unread news in the NewsFeed related to this Favorite.

Specified by:
getUnreadCount in interface INewsFeedStatus
Returns:
the number of unread news in the NewsFeed related to this Favorite
See Also:
INewsFeedStatus.getUnreadCount()

setError

public void setError(boolean error)

Sets the error flag of this Favorite. This is used to indicate if this Favorite caused an error last time its NewsFeed was loaded.

Parameters:
error - true to indicate an error; false otherwise
See Also:
isError()

isError

public boolean isError()

Indicates if this Favorite caused an error last time its NewsFeed was loaded.

Returns:
true to indicate an error; false otherwise
See Also:
setError(boolean)

dispose

public void dispose()

Disposes this Favorite.

Specified by:
dispose in interface IMutableTreeElement
Overrides:
dispose in class MutableTreeElement

toString

public String toString()

Gets the textual represntation of this Favorite. Returns the Favorite title.

Overrides:
toString in class MutableTreeElement
Returns:
the textual representaion of this Favorite

statusChanged

public void statusChanged(NewsFeedTableStatusChangedEvent event)

Triggered when the status of the NewsFeedTable changes. Called whenever the news read status of the associated NewsFeed changed.

Specified by:
statusChanged in interface INewsFeedTableStatusListener
Parameters:
event - the triggered NewsFeedTableStatusChangedEvent

closing

public void closing(NewsFeedTableStatusChangedEvent event)

Triggered when the NewsFeedTable is about to be closed.

Specified by:
closing in interface INewsFeedTableStatusListener
Parameters:
event - the triggered NewsFeedTableStatusChangedEvent

isFiltered

public boolean isFiltered()

Gets the filtered status of this Favorite.

Specified by:
isFiltered in interface IFilterTag
Returns:
true if this Favorite is filtered; false otherwise

setFiltered

public void setFiltered(boolean filtered)

Sets the filtered status of this Favorite.

Specified by:
setFiltered in interface IFilterTag
Parameters:
filtered - true to mark this Favorite as filtered; false to mark it as unfiltered

setUpdateStatus

public void setUpdateStatus(JobExecutionStatus status)

Sets the update status of this Favorite to the specified JobExceutionStatus object.

Parameters:
status - the JobExceutionStatus holding the update status of this Favorite
See Also:
getUpdateStatus(), isScheduled()

isScheduled

public boolean isScheduled()

Returns true if this Favorite is scheduled for automatic update.

Returns:
true if this Favorite is scheduled for automatic update; false otherwise
See Also:
getUpdateStatus(), setUpdateStatus(JobExecutionStatus)

getUpdateStatus

public JobExecutionStatus getUpdateStatus()

Gets the update status of this Favorite.

Returns:
the JobExceutionStatus holding the update status of this Favorite
See Also:
setUpdateStatus(JobExecutionStatus), isScheduled()

registerWatch

public void registerWatch(Watch watch)

Registers the specified Watch, i.e. notifies this Favorite that it is observed by the specified Watch.

Parameters:
watch - the Watch to register
See Also:
unregisterWatch(Watch)

unregisterWatch

public void unregisterWatch(Watch watch)

Unegisters the specified Watch, i.e. notifies this Favorite that it is no longer observed by the specified Watch.

Parameters:
watch - the Watch to unregister
See Also:
registerWatch(Watch)

getRegisteredWatches

public Watch[] getRegisteredWatches()

Gets all Watches that this Favorite is registered at, i.e. observed by.

Returns:
a list of Watch instances that this Favorite is registered at

addNewsFeedStatusListener

public void addNewsFeedStatusListener(INewsFeedStatusListener listener)

Adds the specified INewsFeedStatusListener to the list of registered listeners.

Parameters:
listener - the listener to add
See Also:
removeINewsFeedStatusListener(INewsFeedStatusListener)

removeINewsFeedStatusListener

public void removeINewsFeedStatusListener(INewsFeedStatusListener listener)

Removes the specified INewsFeedStatusListener from the list of registered listeners.

Parameters:
listener - the listener to remove
See Also:
addNewsFeedStatusListener(INewsFeedStatusListener)

fireNewsFeedUpdated

protected void fireNewsFeedUpdated()

Notifies all registered INewsFeedStatusListener instances that the NewsFeed associated to this Favorite has been upated.

See Also:
fireNewsFeedReadStatusChanged()

fireNewsFeedReadStatusChanged

protected void fireNewsFeedReadStatusChanged()

Notifies all registered INewsFeedStatusListener instances that the read status of the NewsFeed associated to this Favorite has changed.

See Also:
fireNewsFeedUpdated()

updateParents

private void updateParents()

Updates all parent Categories of this Favorite.


initializeEventListener

private void initializeEventListener()

Initializes the internal event listener list structure.