net.sourceforge.java.feednread.backend.model.watchestree
Class WatchSettings

java.lang.Object
  extended bynet.sourceforge.java.feednread.backend.model.watchestree.WatchSettings

public class WatchSettings
extends Object

Holds the settings used by a Watch to query the matching NewsFeedEntries from a NewsFeed. This is done by creating and compiling a valid regular expression from all contained WatchSettingsEntries which is afterwards used to match the contents of NewsFeedEntries.

Author:
Sebastian Machhausen

Field Summary
private  List entries
           Holds the WatchSettingsEntry objects of which the WatchSettings is composed.
private  Pattern pattern
           The Pattern used for matchingNewsFeedEntries
 
Constructor Summary
WatchSettings()
           Creates a new WatchSettings instance.
 
Method Summary
 void addEntry(WatchSettingsEntry entry)
           Adds the specified WatchSettingsEntry to this WatchSettings.
 void compile()
           Compiles this WatchSettings, i.e. all contained WatchSettingsEntries into a regular expression against which the matching of NewsFeedEntries can be done.
 WatchSettingsEntry[] getEntries()
           
 List match(NewsFeed newsFeed)
           Selects all NewsFeedEntry objects from the specified NewsFeed that match this WatchSettings.
private  boolean match(NewsFeedEntry entry)
           Determines if the specified NewsFeedEntry matches against this WatchSettings.
private  String prepare(String str)
           Prepares the specified String for regular expression compilation.
 void removeAllEntries()
           Removes all WatchSettingsEntry objects from this WatchSettings.
 void removeEntry(WatchSettingsEntry entry)
           Removes the specified WatchSettingsEntry from this WatchSettings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entries

private List entries

Holds the WatchSettingsEntry objects of which the WatchSettings is composed.


pattern

private Pattern pattern

The Pattern used for matchingNewsFeedEntries

Constructor Detail

WatchSettings

public WatchSettings()

Creates a new WatchSettings instance.

Method Detail

getEntries

public WatchSettingsEntry[] getEntries()

addEntry

public void addEntry(WatchSettingsEntry entry)

Adds the specified WatchSettingsEntry to this WatchSettings.

Parameters:
entry - the WatchSettingsEntry to add

removeEntry

public void removeEntry(WatchSettingsEntry entry)

Removes the specified WatchSettingsEntry from this WatchSettings.

Parameters:
entry - the WatchSettingsEntry to remove

removeAllEntries

public void removeAllEntries()

Removes all WatchSettingsEntry objects from this WatchSettings.


match

public List match(NewsFeed newsFeed)

Selects all NewsFeedEntry objects from the specified NewsFeed that match this WatchSettings. If this WatchSettings has not been compiled yet using the compile() method this will be done before the matching.

Parameters:
newsFeed - the NewsFeed to match
Returns:
a List that contains all matching NewsFeedEntry objects from the specified NewsFeed

compile

public void compile()

Compiles this WatchSettings, i.e. all contained WatchSettingsEntries into a regular expression against which the matching of NewsFeedEntries can be done.


prepare

private String prepare(String str)

Prepares the specified String for regular expression compilation.

Parameters:
str - the String to prepare
Returns:
the prepared String

match

private boolean match(NewsFeedEntry entry)

Determines if the specified NewsFeedEntry matches against this WatchSettings.

Parameters:
entry - the NewsFeedEntry to match
Returns:
true if the specified NewsFeedEntry matches; false otherwise