1 27 package de.nava.informa.utils; 28 29 import de.nava.informa.core.ChannelIF; 30 import de.nava.informa.core.ChannelFormat; 31 32 40 public class CacheSettings implements CacheSettingsIF { 41 42 static private CacheSettingsIF v_091; 43 static private CacheSettingsIF v_100; 44 static private CacheSettingsIF v_200; 45 static private CacheSettingsIF v_A030; 46 47 48 49 static { 50 v_091 = new RSS091Settings(); 51 v_100 = new RSS100Settings(); 52 v_200 = new RSS200Settings(); 53 v_A030 = new Atom030Settings(); 54 } 55 56 60 public long getTtl(ChannelIF channel, long ttl) { 61 62 if (channel.getFormat().equals(ChannelFormat.RSS_0_91) 63 || channel.getFormat().equals(ChannelFormat.RSS_0_92) 64 || channel.getFormat().equals(ChannelFormat.RSS_0_93) 65 || channel.getFormat().equals(ChannelFormat.RSS_0_94) ) { 66 return v_091.getTtl(channel, ttl); 67 } else if (channel.getFormat().equals(ChannelFormat.RSS_1_0)) { 68 return v_100.getTtl(channel, ttl); 69 } else if (channel.getFormat().equals(ChannelFormat.RSS_2_0)) { 70 return v_200.getTtl(channel, ttl); 71 } 72 else if (channel.getFormat().equals(ChannelFormat.ATOM_0_3)) { 73 return v_A030.getTtl(channel, ttl); 74 } 75 76 return CacheSettingsIF.DEFAULT_TTL; 77 } 78 79 82 public void setDefaultTtl(long defTtl) { 83 v_091.setDefaultTtl(defTtl); 84 v_100.setDefaultTtl(defTtl); 85 v_200.setDefaultTtl(defTtl); 86 v_A030.setDefaultTtl(defTtl); 87 } 88 89 public void setDefaultTtl(String type, long defTtl) { 90 if (ChannelFormat.RSS_0_91.equals(type) 91 || ChannelFormat.RSS_0_92.equals(type) 92 || ChannelFormat.RSS_0_93.equals(type) 93 || ChannelFormat.RSS_0_94.equals(type)) { 94 v_091.setDefaultTtl(defTtl); 95 return; 96 } 97 98 if (ChannelFormat.RSS_1_0.equals(type)) { 99 v_100.setDefaultTtl(defTtl); 100 return; 101 } 102 103 if (ChannelFormat.RSS_2_0.equals(type)) { 104 v_200.setDefaultTtl(defTtl); 105 return; 106 } 107 108 if (ChannelFormat.ATOM_0_3.equals(type)) { 109 v_A030.setDefaultTtl(defTtl); 110 return; 111 } 112 113 } 114 } 115 | Popular Tags |