net.obxlabs.romefeeder
Class Feeder

java.lang.Object
  extended by net.obxlabs.romefeeder.Feeder
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
TwitterFeeder

public class Feeder
extends java.lang.Object
implements java.lang.Runnable

Feed manager.

The feeder allows to load and update one or multiple syndicated feeds using the ROME library. It provides sorting functions to view the loaded entries in different orders, and it includes a simple way to load feeds through a PHP web proxy.

Author:
Bruno Nadeau

Field Summary
 EntryCallback postloadEntryCallback
          Callback after an entry is loaded.
 FeedCallback postloadFeedCallback
          Callback after a feed is loaded.
 FeedCallback postupdateFeedCallback
          Callback after a feed is updated.
 FeedCallback postupdateGlobalCallback
          Callback after feeds are updated.
 EntryCallback preloadEntryCallback
          Callback before an entry is loaded.
 FeedCallback preloadFeedCallback
          Callback before a feed is loaded.
 FeedCallback preupdateFeedCallback
          Callback before a feed is updated.
 FeedCallback preupdateGlobalCallback
          Callback before feeds are updated.
static int PUBLISHED_DATE
          Sort option: published date.
static int TITLE
          Sort option: title.
static int UNSORTED
          Sort options: unsorted (default).
static int UPDATED_DATE
          Sort option: updated date.
 boolean verbose
          Outputs process information when true.
 
Constructor Summary
Feeder()
          Create an empty Feeder.
Feeder(java.lang.String xml)
          Create a Feeder and load a Feed from a given xml file or url.
 
Method Summary
 void clear()
          Clear the feeder.
 int count()
          Return the number of loaded entries.
 int countFeeds()
          Return the number of loaded feeds.
 void err(java.lang.String msg)
          Outputs errors to the console.
 com.sun.syndication.feed.synd.SyndFeed getFeed(java.lang.String xml)
          Get the loaded Feed with a given id.
 long getUpdateInterval()
          Get the update interval.
 boolean hasNext()
          Check if there is more entries in the list.
 com.sun.syndication.feed.synd.SyndEntry last()
          Get the last entry in the list and move the pointer to it.
 void load(java.lang.String xml)
          Load a Feed from a given xml file or url and uses the feed's path as id.
 com.sun.syndication.feed.synd.SyndEntry next()
          Get the next entry in the list.
 void out(java.lang.String msg)
          Outputs text to the console.
 com.sun.syndication.feed.synd.SyndFeed removeFeed(java.lang.String xml)
          Remove the loaded Feed with a given id.
 com.sun.syndication.feed.synd.SyndFeed removeFeed(com.sun.syndication.feed.synd.SyndFeed feed)
          Remove the loaded Feed.
 void reset()
          Reset the list iterator of the entries.
 void run()
          Main function of the loading/updating thread.
 void setLoadCallback(FeedCallback postloadCallback)
          Deprecated. Replaced by setLoadFeedCallback
 void setLoadCallback(FeedCallback preloadCallback, FeedCallback postloadCallback)
          Deprecated. Replaced by setLoadFeedCallback
 void setLoadEntryCallback(EntryCallback postloadEntryCallback)
          Set the post load entry callback.
 void setLoadEntryCallback(EntryCallback preloadEntryCallback, EntryCallback postloadEntryCallback)
          Set the pre and post load entry callbacks.
 void setLoadFeedCallback(FeedCallback postloadFeedCallback)
          Set the post load feed callback.
 void setLoadFeedCallback(FeedCallback preloadFeedCallback, FeedCallback postloadFeedCallback)
          Set the pre and post load feed callbacks.
 void setProxy(java.lang.String proxy)
          Set the proxy used to fetch external feeds.
 void setUpdateCallback(FeedCallback postupdateCallback)
          Deprecated. Replaced by setUpdateFeedCallback
 void setUpdateCallback(FeedCallback preupdateCallback, FeedCallback postupdateCallback)
          Deprecated. Replaced by setUpdateFeedCallback
 void setUpdateFeedCallback(FeedCallback postupdateFeedCallback)
          Set the post update feed callback.
 void setUpdateFeedCallback(FeedCallback preupdateFeedCallback, FeedCallback postupdateFeedCallback)
          Set the post update feed callback.
 void setUpdateInterval(long ui)
          Set the interval between updates.
 void sort(int value)
          Set the sorting value for loading entries
 void startUpdate()
          Start updating loaded feeds.
 void startUpdate(FeedCallback postupdateGlobalCallback)
          Start updating loaded feeds and set global post update callbacks.
 void startUpdate(FeedCallback preupdateGlobalCallback, FeedCallback postupdateGlobalCallback)
          Start updating loaded feeds and set global update callbacks.
 void stopUpdate()
          Stop updating loaded feeds.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNSORTED

public static final int UNSORTED
Sort options: unsorted (default).

See Also:
Constant Field Values

PUBLISHED_DATE

public static final int PUBLISHED_DATE
Sort option: published date.

See Also:
Constant Field Values

UPDATED_DATE

public static final int UPDATED_DATE
Sort option: updated date.

See Also:
Constant Field Values

TITLE

public static final int TITLE
Sort option: title.

See Also:
Constant Field Values

preloadFeedCallback

public FeedCallback preloadFeedCallback
Callback before a feed is loaded.


postloadFeedCallback

public FeedCallback postloadFeedCallback
Callback after a feed is loaded.


preupdateFeedCallback

public FeedCallback preupdateFeedCallback
Callback before a feed is updated.


postupdateFeedCallback

public FeedCallback postupdateFeedCallback
Callback after a feed is updated.


preupdateGlobalCallback

public FeedCallback preupdateGlobalCallback
Callback before feeds are updated.


postupdateGlobalCallback

public FeedCallback postupdateGlobalCallback
Callback after feeds are updated.


preloadEntryCallback

public EntryCallback preloadEntryCallback
Callback before an entry is loaded.


postloadEntryCallback

public EntryCallback postloadEntryCallback
Callback after an entry is loaded.


verbose

public boolean verbose
Outputs process information when true.

Constructor Detail

Feeder

public Feeder()
Create an empty Feeder.


Feeder

public Feeder(java.lang.String xml)
Create a Feeder and load a Feed from a given xml file or url.

Parameters:
xml - url or file path
Method Detail

sort

public void sort(int value)
Set the sorting value for loading entries

This must be called before any entry is added to the feeder.

Parameters:
value - value to sort entries by (UNSORTED, PUBLISHED_DATE, UPDATED_DATE, TITLE)

setProxy

public void setProxy(java.lang.String proxy)
Set the proxy used to fetch external feeds.

Parameters:
proxy - the url of the proxy

load

public void load(java.lang.String xml)
Load a Feed from a given xml file or url and uses the feed's path as id.

Parameters:
xml - url or file path

setLoadCallback

public void setLoadCallback(FeedCallback postloadCallback)
Deprecated. Replaced by setLoadFeedCallback

Set the post load callback.

Parameters:
postloadCallback -

setLoadFeedCallback

public void setLoadFeedCallback(FeedCallback postloadFeedCallback)
Set the post load feed callback.

Sets a FeedCallback object that will be called right AFTER a feed is loaded.

Parameters:
postloadFeedCallback -

setLoadCallback

public void setLoadCallback(FeedCallback preloadCallback,
                            FeedCallback postloadCallback)
Deprecated. Replaced by setLoadFeedCallback

Set the pre and post load callbacks.

Parameters:
preloadCallback -
postloadCallback -

setLoadFeedCallback

public void setLoadFeedCallback(FeedCallback preloadFeedCallback,
                                FeedCallback postloadFeedCallback)
Set the pre and post load feed callbacks.

Sets a FeedCallback object that will be called right BEFORE and another object that will be called right AFTER a feed is loaded.

Parameters:
preloadFeedCallback -
postloadFeedCallback -

setUpdateCallback

public void setUpdateCallback(FeedCallback postupdateCallback)
Deprecated. Replaced by setUpdateFeedCallback

Set the post update callback.

Parameters:
postupdateCallback -

setUpdateFeedCallback

public void setUpdateFeedCallback(FeedCallback postupdateFeedCallback)
Set the post update feed callback.

Sets a FeedCallback object that will be called right AFTER each time a feed is updated.

Parameters:
postupdateFeedCallback -

setUpdateCallback

public void setUpdateCallback(FeedCallback preupdateCallback,
                              FeedCallback postupdateCallback)
Deprecated. Replaced by setUpdateFeedCallback

Set the post update callback.

Parameters:
preupdateCallback -
postupdateCallback -

setUpdateFeedCallback

public void setUpdateFeedCallback(FeedCallback preupdateFeedCallback,
                                  FeedCallback postupdateFeedCallback)
Set the post update feed callback.

Sets a FeedCallback object that will be called right BEFORE and another object that will be called right AFTER each time a feed is updated.

Parameters:
preupdateFeedCallback -
postupdateFeedCallback -

setLoadEntryCallback

public void setLoadEntryCallback(EntryCallback postloadEntryCallback)
Set the post load entry callback.

Sets an EntryCallback object that will be called right AFTER an entry is loaded.

Parameters:
postloadEntryCallback -

setLoadEntryCallback

public void setLoadEntryCallback(EntryCallback preloadEntryCallback,
                                 EntryCallback postloadEntryCallback)
Set the pre and post load entry callbacks.

Sets an EntryCallback object that will be called right BEFORE and another object that will be called right AFTER an entry is loaded.

Parameters:
preloadEntryCallback -
postloadEntryCallback -

getFeed

public com.sun.syndication.feed.synd.SyndFeed getFeed(java.lang.String xml)
Get the loaded Feed with a given id. Returns NULL if no Feed was loaded with the id.

Parameters:
xml - url or file path
Returns:
feed

removeFeed

public com.sun.syndication.feed.synd.SyndFeed removeFeed(java.lang.String xml)
Remove the loaded Feed with a given id.

Parameters:
xml - url or file path
Returns:
removed feed

removeFeed

public com.sun.syndication.feed.synd.SyndFeed removeFeed(com.sun.syndication.feed.synd.SyndFeed feed)
Remove the loaded Feed.

Parameters:
feed -

countFeeds

public int countFeeds()
Return the number of loaded feeds.

Returns:
number of loaded feed.

count

public int count()
Return the number of loaded entries.

Returns:
number of loaded entries

hasNext

public boolean hasNext()
Check if there is more entries in the list.

Returns:
true if feeder has more entries

next

public com.sun.syndication.feed.synd.SyndEntry next()
Get the next entry in the list.

Returns:
the next entry in the list

last

public com.sun.syndication.feed.synd.SyndEntry last()
Get the last entry in the list and move the pointer to it.


reset

public void reset()
Reset the list iterator of the entries.


clear

public void clear()
Clear the feeder.


startUpdate

public void startUpdate()
Start updating loaded feeds.


startUpdate

public void startUpdate(FeedCallback postupdateGlobalCallback)
Start updating loaded feeds and set global post update callbacks.


startUpdate

public void startUpdate(FeedCallback preupdateGlobalCallback,
                        FeedCallback postupdateGlobalCallback)
Start updating loaded feeds and set global update callbacks.


stopUpdate

public void stopUpdate()
Stop updating loaded feeds.


setUpdateInterval

public void setUpdateInterval(long ui)
Set the interval between updates.

Parameters:
ui - interval in milliseconds

getUpdateInterval

public long getUpdateInterval()
Get the update interval.

Returns:
update interval

run

public void run()
Main function of the loading/updating thread.

Specified by:
run in interface java.lang.Runnable

err

public void err(java.lang.String msg)
Outputs errors to the console.


out

public void out(java.lang.String msg)
Outputs text to the console.



processing library romefeeder by Bruno Nadeau. 2008-2009 (c) OBX Labs / Bruno Nadeau / Jason Lewis