KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > nava > informa > utils > Atom030Settings


1 //
2
//Informa -- RSS Library for Java
3
//Copyright (c) 2002 by Niko Schmuck
4
//
5
//Niko Schmuck
6
//http://sourceforge.net/projects/informa
7
//mailto:niko_schmuck@users.sourceforge.net
8
//
9
//This library is free software.
10
//
11
//You may redistribute it and/or modify it under the terms of the GNU
12
//Lesser General Public License as published by the Free Software Foundation.
13
//
14
//Version 2.1 of the license should be included with this distribution in
15
//the file LICENSE. If the license is not included with this distribution,
16
//you may find a copy at the FSF web site at 'www.gnu.org' or 'www.fsf.org',
17
//or you may write to the Free Software Foundation, 675 Mass Ave, Cambridge,
18
//MA 02139 USA.
19
//
20
//This library is distributed in the hope that it will be useful,
21
//but WITHOUT ANY WARRANTY; without even the implied waranty of
22
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23
//Lesser General Public License for more details.
24
//$Id: Atom030Settings.java,v 1.2 2004/06/25 06:50:26 jga Exp $
25

26 package de.nava.informa.utils;
27
28 import org.apache.commons.logging.Log;
29 import org.apache.commons.logging.LogFactory;
30
31 import de.nava.informa.core.ChannelIF;
32
33 /**
34  * @author jga
35  *
36  * TODO To change the template for this generated type comment go to
37  * Window - Preferences - Java - Code Generation - Code and Comments
38  */

39 public class Atom030Settings implements CacheSettingsIF {
40
41   private static Log logger = LogFactory.getLog(Atom030Settings.class);
42
43   private long defaultTtl = DEFAULT_TTL;
44
45   /**
46    *
47    */

48   public void setDefaultTtl(long defaultTtl) {
49     this.defaultTtl = defaultTtl;
50   }
51
52   /**
53    * return in order of preference: feed producer ttl (if exists and < wantedTtl)
54    * wantedTtl (if exists) defaultTtl (if exists)
55    */

56   public long getTtl(ChannelIF channel, long ttlms) {
57     //TODO : correct this ... getTtl() when atom parsing complete
58
if (channel.getTtl() > 0) {
59       long channelTtl = channel.getTtl() * (60 * 1000); // ttl in feed in minutes
60
if (ttlms > channelTtl) {
61         return ttlms;
62       }
63       return channelTtl;
64     }
65     
66     if (ttlms > MINIMAL_TTL )
67       return ttlms;
68     
69     return this.defaultTtl;
70
71   }
72 }
73
Popular Tags