org.rometools.fetcher.impl
Class HashMapFeedInfoCache

java.lang.Object
  extended by org.rometools.fetcher.impl.HashMapFeedInfoCache
All Implemented Interfaces:
Serializable, FeedFetcherCache
Direct Known Subclasses:
LinkedHashMapFeedInfoCache

public class HashMapFeedInfoCache
extends Object
implements FeedFetcherCache, Serializable

A very simple implementation of the FeedFetcherCache interface.

This implementation uses a HashMap to cache retrieved feeds. This implementation is most suitible for sort term (client aggregator?) use, as the memory usage will increase over time as the number of feeds in the cache increases.

Author:
Nick Lothian
See Also:
Serialized Form

Constructor Summary
HashMapFeedInfoCache()
          Constructor for HashMapFeedInfoCache Only use this if you want multiple instances of the cache.
 
Method Summary
 void clear()
          Removes all items from the cache.
protected  Map createInfoCache()
           
protected  Object get(Object key)
           
 SyndFeedInfo getFeedInfo(URL feedUrl)
          Get a SyndFeedInfo object from the cache.
protected  Map getInfoCache()
           
static FeedFetcherCache getInstance()
          Get the global instance of the cache
protected  void put(Object key, Object value)
           
 SyndFeedInfo remove(URL url)
          Removes the SyndFeedInfo identified by the url from the cache.
 void setFeedInfo(URL feedUrl, SyndFeedInfo syndFeedInfo)
          Add a SyndFeedInfo object to the cache
protected  void setInfoCache(Map map)
          The API of this class indicates that map must thread safe.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashMapFeedInfoCache

public HashMapFeedInfoCache()

Constructor for HashMapFeedInfoCache

Only use this if you want multiple instances of the cache. Usually getInstance() is more appropriate.

Method Detail

getInstance

public static FeedFetcherCache getInstance()
Get the global instance of the cache

Returns:
an implementation of FeedFetcherCache

createInfoCache

protected Map createInfoCache()

get

protected Object get(Object key)

getFeedInfo

public SyndFeedInfo getFeedInfo(URL feedUrl)
Description copied from interface: FeedFetcherCache
Get a SyndFeedInfo object from the cache.

Specified by:
getFeedInfo in interface FeedFetcherCache
Parameters:
feedUrl - The url of the feed
Returns:
A SyndFeedInfo or null if it is not in the cache
See Also:
extensions.io.FeedFetcherCache#getFeedInfo(java.net.URL)

put

protected void put(Object key,
                   Object value)

setFeedInfo

public void setFeedInfo(URL feedUrl,
                        SyndFeedInfo syndFeedInfo)
Description copied from interface: FeedFetcherCache
Add a SyndFeedInfo object to the cache

Specified by:
setFeedInfo in interface FeedFetcherCache
Parameters:
feedUrl - The url of the feed
syndFeedInfo - A SyndFeedInfo for the feed
See Also:
extensions.io.FeedFetcherCache#setFeedInfo(java.net.URL, extensions.io.SyndFeedInfo)

getInfoCache

protected final Map getInfoCache()

setInfoCache

protected final void setInfoCache(Map map)
The API of this class indicates that map must thread safe. In other words, be sure to wrap it in a synchronized map unless you know what you are doing.

Parameters:
map - the map to use as the info cache.

clear

public void clear()
Description copied from interface: FeedFetcherCache
Removes all items from the cache.

Specified by:
clear in interface FeedFetcherCache
See Also:
com.sun.syndication.fetcher.impl.FeedFetcherCache#clear()

remove

public SyndFeedInfo remove(URL url)
Description copied from interface: FeedFetcherCache
Removes the SyndFeedInfo identified by the url from the cache.

Specified by:
remove in interface FeedFetcherCache
Returns:
The removed SyndFeedInfo
See Also:
com.sun.syndication.fetcher.impl.FeedFetcherCache#remove(java.net.URL)


Copyright © 2004-2013 ROME Project. All Rights Reserved.