de.nava.informa.utils
Class ChannelRegistry

java.lang.Object
  extended by de.nava.informa.utils.ChannelRegistry

public class ChannelRegistry
extends Object

This class can be used as central repository for storing a collection of channel objects and maintaining them (by specifying update intervals).

Author:
Niko Schmuck (niko@nava.de)

Field Summary
static int DEFAULT_ACCEPT_NR_ERRORS
           
 
Constructor Summary
ChannelRegistry(ChannelBuilderIF builder)
          Constructor for a new ChannelRegistry object, the new items found by scanning the are created using the given builder.
 
Method Summary
 void activateChannel(ChannelIF channel, int interval)
          Activates a channel and looks for new items for the given channel.
 ChannelIF addChannel(ChannelIF channel, boolean active, int interval)
          Given a stand-alone Channel (i.e.
 ChannelIF addChannel(URL url, Collection<CategoryIF> categories, int interval, boolean active)
          Adds one new channel object in the given category to the registry.
 ChannelIF addChannel(URL url, int interval, boolean active)
          Adds one new channel object (instantiated with the help of the given URL from where the channel can be retrieved from) to the registry.
 void deactivateChannel(ChannelIF channel)
          Deactivates a channel, no more updates are made.
 int getAcceptNrOfErrors()
           
 ChannelIF getChannel(long id)
           
 ChannelGroupIF getChannelGroup()
           
 Collection getChannels()
          Gets all the channels in the registry.
 long getScheduledUpdateTime(ChannelIF channel)
          Gets the scheduled time of the next channel update.
 UpdateChannelInfo getUpdateInfo(ChannelIF channel)
           
 boolean isActiveChannel(ChannelIF channel)
          Returns wether the channel update task is still active or not.
 void removeChannel(ChannelIF channel)
          Removes a channel from the registry.
 void setAcceptNrOfErrors(int acceptNrOfErrors)
          Set number of channel parser errors acceptable after channel is not longer automatically updated.
 void setChannelGroup(ChannelGroupIF channels)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ACCEPT_NR_ERRORS

public static final int DEFAULT_ACCEPT_NR_ERRORS
See Also:
Constant Field Values
Constructor Detail

ChannelRegistry

public ChannelRegistry(ChannelBuilderIF builder)
Constructor for a new ChannelRegistry object, the new items found by scanning the are created using the given builder.

Parameters:
builder - The ChannelBuilderIF to use for creating news items.
Method Detail

addChannel

public ChannelIF addChannel(URL url,
                            int interval,
                            boolean active)
Adds one new channel object (instantiated with the help of the given URL from where the channel can be retrieved from) to the registry.

Parameters:
url - - the URL where the channel news can be retrieved.
interval - - time in seconds between update retrieval.
active - - wether regular updates should be executed.

addChannel

public ChannelIF addChannel(URL url,
                            Collection<CategoryIF> categories,
                            int interval,
                            boolean active)
Adds one new channel object in the given category to the registry.

Parameters:
url - - the URL where the channel news can be retrieved.
categories - - the categories to which this channel should be added to (collection of CategoryIF objects).
interval - - time in seconds between update retrieval.
active - - wether regular updates should be executed.

addChannel

public ChannelIF addChannel(ChannelIF channel,
                            boolean active,
                            int interval)
Given a stand-alone Channel (i.e. just read in from disk) we add it into the ChannelGroup and activated if necessary.

Parameters:
channel - - Fully realized Channel
active - - Same as above
interval - - Same as above

activateChannel

public void activateChannel(ChannelIF channel,
                            int interval)
Activates a channel and looks for new items for the given channel.

Parameters:
channel - The ChannelIF to scan for updates
interval - Difference between channel updates in seconds

getChannel

public ChannelIF getChannel(long id)

getChannels

public Collection getChannels()
Gets all the channels in the registry.

Returns:
A collection of ChannelIF objects.

getChannelGroup

public ChannelGroupIF getChannelGroup()

setChannelGroup

public void setChannelGroup(ChannelGroupIF channels)

removeChannel

public void removeChannel(ChannelIF channel)
Removes a channel from the registry. First it is cleanly deactivated.

Parameters:
channel - The ChannelIF object to remove.

deactivateChannel

public void deactivateChannel(ChannelIF channel)
Deactivates a channel, no more updates are made.


isActiveChannel

public boolean isActiveChannel(ChannelIF channel)
Returns wether the channel update task is still active or not.


getUpdateInfo

public UpdateChannelInfo getUpdateInfo(ChannelIF channel)

getScheduledUpdateTime

public long getScheduledUpdateTime(ChannelIF channel)
Gets the scheduled time of the next channel update.

Parameters:
channel - The ChannelIF to retrieve information for.
Returns:
The date of the next execution, 0 if not available

getAcceptNrOfErrors

public int getAcceptNrOfErrors()

setAcceptNrOfErrors

public void setAcceptNrOfErrors(int acceptNrOfErrors)
Set number of channel parser errors acceptable after channel is not longer automatically updated.



Copyright © 2002-2007 Niko Schmuck. All Rights Reserved.