KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > nava > informa > utils > toolkit > ChannelRecord


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
//
25
// $Id: ChannelRecord.java,v 1.2 2004/09/16 14:06:00 spyromus Exp $
26
//
27

28 package de.nava.informa.utils.toolkit;
29
30 import de.nava.informa.core.ChannelIF;
31
32 /**
33  * Internal channel record. Used by <code>Scheduler</code> and <code>WorkersManager</code>
34  * to hold information about channels.
35  *
36  * @author Aleksey Gureev (spyromus@noizeramp.com)
37  */

38 public class ChannelRecord {
39   /**
40    * Low priority.
41    */

42   public static final int PRIO_LOW = -1;
43
44   /**
45    * Normal priority.
46    */

47   public static final int PRIO_NORMAL = 0;
48
49   /**
50    * High priority.
51    */

52   public static final int PRIO_HIGH = 1;
53
54   private ChannelIF channel;
55
56   private boolean formatResolved = false;
57
58   private int priority;
59   private long period;
60   private boolean canceled;
61
62   /**
63    * Creates channel record.
64    *
65    * @param channel channel.
66    * @param period period of poll in milliseconds.
67    * @param priority priority of poll.
68    */

69   public ChannelRecord(ChannelIF channel, long period, int priority) {
70     this.priority = priority;
71     this.period = period;
72     this.channel = channel;
73     formatResolved = (channel.getFormat() != null);
74     setCanceled(false);
75   }
76
77   /**
78    * Returns priority of poll.
79    *
80    * @return priority of poll.
81    * @see #PRIO_LOW
82    * @see #PRIO_NORMAL
83    * @see #PRIO_HIGH
84    */

85   public final int getPriority() {
86     return priority;
87   }
88
89   /**
90    * Sets priority of poll.
91    *
92    * @param priority priority of poll.
93    * @see #PRIO_LOW
94    * @see #PRIO_NORMAL
95    * @see #PRIO_HIGH
96    */

97   public final void setPriority(int priority) {
98     this.priority = priority;
99   }
100
101   /**
102    * Returns current period of updates.
103    *
104    * @return period in milliseconds.
105    */

106   public final long getPeriod() {
107     return period;
108   }
109
110   /**
111    * Sets new period of updates (just value). Actuall period will not be affected
112    * as we only store the setting here.
113    *
114    * @param period new period setting in milliseconds.
115    */

116   public final void setPeriod(long period) {
117     this.period = period;
118   }
119
120   /**
121    * Returns channel object.
122    *
123    * @return channel object.
124    */

125   public final ChannelIF getChannel() {
126     return channel;
127   }
128
129   /**
130    * Returns TRUE if format of channel is resolved.
131    *
132    * @return TRUE if format is resolved.
133    */

134   public final boolean isFormatResolved() {
135     return formatResolved;
136   }
137
138   /**
139    * Sets the state of format resolution flag.
140    *
141    * @param formatResolved TRUE if channel format is already resolved.
142    */

143   public final void setFormatResolved(boolean formatResolved) {
144     this.formatResolved = formatResolved;
145   }
146
147   /**
148    * Sets cancel-status of record.
149    *
150    * @param aCanceled <code>true</code> to cancel processing.
151    */

152   public void setCanceled(boolean aCanceled) {
153     this.canceled = aCanceled;
154   }
155
156   /**
157    * Returns cancel-status of record.
158    *
159    * @return <code>true</code> if processing of this record has been canceled.
160    */

161   public boolean isCanceled() {
162     return canceled;
163   }
164 }
165
Popular Tags