org.clapper.curn
Class FeedCache

java.lang.Object
  extended by org.clapper.curn.FeedCache

public class FeedCache
extends java.lang.Object

Defines the in-memory format of the curn cache, and provides methods for saving and restoring the cache.

Version:
$Revision: 6498 $
See Also:
Curn, RSSChannel

Method Summary
 void addToCache(java.lang.String uniqueID, java.net.URL url, java.util.Date pubDate, FeedInfo parentFeed)
          Add (or replace) a cached URL.
 boolean containsID(java.lang.String id)
          Determine whether the cache contains an entry with the specified unique ID.
 boolean containsURL(java.net.URL url)
          Determine whether the cache contains the specified URL.
 java.util.Collection<FeedCacheEntry> getAllEntries()
          Get all entries in the cache, in no particular order.
 FeedCacheEntry getEntry(java.lang.String id)
          Get an entry from the cache by its unique ID.
 FeedCacheEntry getEntryByURL(java.net.URL url)
          Get an entry from the cache by its URL.
 void setCurrentTime(java.util.Date datetime)
          Set the cache's notion of the current time, which affects how elements are pruned when loaded from the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

containsID

public boolean containsID(java.lang.String id)
Determine whether the cache contains an entry with the specified unique ID.

Parameters:
id - the ID to check.
Returns:
true if the ID is present in the cache, false if not

containsURL

public boolean containsURL(java.net.URL url)
Determine whether the cache contains the specified URL.

Parameters:
url - the URL to check. This method normalizes it.
Returns:
true if the ID is present in the cache, false if not

getEntry

public FeedCacheEntry getEntry(java.lang.String id)
Get an entry from the cache by its unique ID.

Parameters:
id - the unique ID to check
Returns:
the corresponding FeedCacheEntry object, or null if not found

getEntryByURL

public FeedCacheEntry getEntryByURL(java.net.URL url)
Get an entry from the cache by its URL.

Parameters:
url - the URL
Returns:
the corresponding FeedCacheEntry object, or null if not found

addToCache

public void addToCache(java.lang.String uniqueID,
                       java.net.URL url,
                       java.util.Date pubDate,
                       FeedInfo parentFeed)
Add (or replace) a cached URL.

Parameters:
uniqueID - the unique ID string for the cache entry, or null. If null, the URL is used as the unique ID.
url - the URL to cache. May be an individual item URL, or the URL for an entire feed.
pubDate - the publication date, if known; or null
parentFeed - the associated feed
See Also:
CurnUtil.normalizeURL(java.net.URL)

getAllEntries

public java.util.Collection<FeedCacheEntry> getAllEntries()
Get all entries in the cache, in no particular order.

Returns:
a Collection of entries

setCurrentTime

public void setCurrentTime(java.util.Date datetime)
Set the cache's notion of the current time, which affects how elements are pruned when loaded from the cache. Only meaningful if set before the load() method is called. If this method is never called, then the cache uses the current time.

Parameters:
datetime - the time to use


Copyright © 2004-2006 Brian M. Clapper. All Rights Reserved.