1 17 package com.sun.syndication.fetcher.impl; 18 19 import java.io.Serializable ; 20 import java.net.URL ; 21 import java.util.Collections ; 22 import java.util.HashMap ; 23 import java.util.Map ; 24 25 26 36 public class HashMapFeedInfoCache implements FeedFetcherCache, Serializable { 37 static HashMapFeedInfoCache _instance; 38 39 private Map infoCache; 40 41 48 public HashMapFeedInfoCache() { 49 setInfoCache(Collections.synchronizedMap(new HashMap ())); 50 } 51 52 56 public static synchronized FeedFetcherCache getInstance() { 57 if (_instance == null) { 58 _instance = new HashMapFeedInfoCache(); 59 } 60 return _instance; 61 } 62 63 protected Object get(Object key) { 64 return infoCache.get(key); 65 } 66 67 70 public SyndFeedInfo getFeedInfo(URL feedUrl) { 71 return (SyndFeedInfo) get(feedUrl); 72 } 73 74 protected void put(Object key, Object value) { 75 infoCache.put(key, value); 76 } 77 78 81 public void setFeedInfo(URL feedUrl, SyndFeedInfo syndFeedInfo) { 82 put(feedUrl, syndFeedInfo); 83 } 84 85 protected Map getInfoCache() { 86 return infoCache; 87 } 88 89 protected void setInfoCache(Map map) { 90 infoCache = map; 91 } 92 93 } 94 | Popular Tags |