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

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

public class Category
extends MutableTreeElement
implements IGUID, IFilterTag, INameable, INewsFeedStatus

Category represents a hierarchical structure for Favorite objects, i.e.NewsFeed bookmarks in the NewsFeedFavoritesTree component.

Author:
Sebastian Machhausen

Field Summary
private  boolean filtered
           true if a Category is filtered; false if unfiltered
private  String guid
           The GUID of a Category
private  String title
           The title of a Category
private  JobExecutionInterval updateInterval
           The update interval of a Category.
 
Fields inherited from class net.sourceforge.java.util.gui.jface.viewers.MutableTreeElement
 
Constructor Summary
Category(String title)
           Creates a new Category with the specified title.
Category(String title, String guid)
           Creates a new Category with the specified title.
 
Method Summary
 Favorite[] collectFavorites()
           Recursively collects all Favorite elements starting at this Category.
 String getGUID()
           Gets the GUID of this Category.
 String getTitle()
           Gets the title of this Category.
 int getUnreadCount()
           Returns the number of unread news in the NewsFeeds related to the Favorites in this Category and all of its sub Categorys.
 int getUnreadCount(ITreeElement element)
           Returns the number of unread news in the NewsFeeds related to the specified ITreeElement.
 JobExecutionInterval getUpdateInterval()
           Gets the update interval of this Category.
 boolean isFiltered()
           Gets the filtered status of this Category.
 boolean isScheduled()
           Returns true if this Category is scheduled for automatic update.
 boolean isUnread()
           Returns true if at least one NewsFeed related to a Favorite in this Category holds an unread news.
private  boolean isUnread(ITreeElement element)
           Returns true if at least one NewsFeed related to a Favorite in the specified ITreeElement holds an unread news.
 void setFiltered(boolean filtered)
           Sets the filtered status of this Category.
 void setTitle(String title)
           Sets the title of this Category.
 void setUpdateInterval(JobExecutionInterval interval)
           Sets the update interval for this Category to the specified JobExceutionInterval object.
 String toString()
           Gets the textual represntation of this Category.
 
Methods inherited from class net.sourceforge.java.util.gui.jface.viewers.MutableTreeElement
add, addIMutableTreeElementListener, allowsSubElements, collectLeafs, dispose, 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 Category


title

private String title

The title of a Category


filtered

private boolean filtered

true if a Category is filtered; false if unfiltered


updateInterval

private JobExecutionInterval updateInterval

The update interval of a Category. This is used as template for all newly created Favorites inside a Category.

Constructor Detail

Category

public Category(String title)

Creates a new Category with the specified title.

Parameters:
title - the title to identify this Category
See Also:
Category(String, String)

Category

public Category(String title,
                String guid)

Creates a new Category with the specified title.

Parameters:
title - the title to identify this Category
guid - the GUID for this < code>Catgory
See Also:
Category(String)
Method Detail

getGUID

public String getGUID()

Gets the GUID of this Category.

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

setTitle

public void setTitle(String title)

Sets the title of this Category. Notifies all registered IMutableTreeElementListener instances of the update.

Specified by:
setTitle in interface INameable
Parameters:
title - the new title for this Category

getTitle

public String getTitle()

Gets the title of this Category.

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

toString

public String toString()

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

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

collectFavorites

public Favorite[] collectFavorites()

Recursively collects all Favorite elements starting at this Category.

Returns:
the collected Favorite elements

isUnread

public boolean isUnread()

Returns true if at least one NewsFeed related to a Favorite in this Category holds an unread news.

Specified by:
isUnread in interface INewsFeedStatus
Returns:
true if at least one NewsFeed related to a Favorite in this Category holds an unread news; false otherwise
See Also:
INewsFeedStatus.isUnread()

isUnread

private boolean isUnread(ITreeElement element)

Returns true if at least one NewsFeed related to a Favorite in the specified ITreeElement holds an unread news.

Parameters:
element - the ITreeElement to test
Returns:
true if at least one NewsFeed related to a Favorite the specified ITreeElement holds an unread news; false otherwise

getUnreadCount

public int getUnreadCount()

Returns the number of unread news in the NewsFeeds related to the Favorites in this Category and all of its sub Categorys.

Specified by:
getUnreadCount in interface INewsFeedStatus
Returns:
the number of unread news in the NewsFeeds related to the Favorites in this Category and all of its sub Categorys
See Also:
INewsFeedStatus.getUnreadCount()

getUnreadCount

public int getUnreadCount(ITreeElement element)

Returns the number of unread news in the NewsFeeds related to the specified ITreeElement. If the specified ITreeElement denotes a Category the calculation is done recursively.

Parameters:
element - the ITreeElement to get the number of unread news for
Returns:
the number of unread news in the NewsFeeds related to the specified ITreeElement

isFiltered

public boolean isFiltered()

Gets the filtered status of this Category.

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

setFiltered

public void setFiltered(boolean filtered)

Sets the filtered status of this Category.

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

setUpdateInterval

public void setUpdateInterval(JobExecutionInterval interval)

Sets the update interval for this Category to the specified JobExceutionInterval object.

Parameters:
interval - the JobExceutionInterval to set for this Category
See Also:
getUpdateInterval(), isScheduled()

getUpdateInterval

public JobExecutionInterval getUpdateInterval()

Gets the update interval of this Category.

Returns:
the JobExceutionInterval/code> of this Category
See Also:
setUpdateInterval(JobExecutionInterval), isScheduled()

isScheduled

public boolean isScheduled()

Returns true if this Category is scheduled for automatic update.

Returns:
true if this Category is scheduled for automatic update; false otherwise
See Also:
getUpdateInterval(), setUpdateInterval(JobExecutionInterval)