org.apache.avalon.cornerstone.services.scheduler
Class PeriodicTimeTrigger

java.lang.Object
  extended byorg.apache.avalon.cornerstone.services.scheduler.PeriodicTimeTrigger
All Implemented Interfaces:
TimeTrigger, Trigger

public class PeriodicTimeTrigger
extends java.lang.Object
implements TimeTrigger

Goes off every period milliseconds after waiting for offset milliseconds from the moment the trigger was reset.

Author:
Avalon Development Team

Field Summary
protected  long m_offset
           
protected  long m_period
           
 
Constructor Summary
PeriodicTimeTrigger(int offset, int period)
          Creates a periodic trigger.
 
Method Summary
 long getOffset()
           
 long getPeriod()
           
 long getTimeAfter(long moment)
          Returns the next time after the given moment when this trigger goes off.
 void reset()
          Reset the original TimeTrigger.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_offset

protected final long m_offset

m_period

protected final long m_period
Constructor Detail

PeriodicTimeTrigger

public PeriodicTimeTrigger(int offset,
                           int period)
Creates a periodic trigger. It goes off the first time after offset milliseconds from the time it was reset and then every period milliseconds. The trigger is reset as part of its construction.

Parameters:
offset - initial delay in milliseconds, -1 means fire immediately
period - after initial delay in milliseconds, -1 means fire only once after initial delay
Method Detail

getTimeAfter

public long getTimeAfter(long moment)
Returns the next time after the given moment when this trigger goes off.

Specified by:
getTimeAfter in interface TimeTrigger
Parameters:
moment - base point in milliseconds
Returns:
the time in milliseconds when this trigger goes off

getOffset

public long getOffset()

getPeriod

public long getPeriod()

reset

public void reset()
Reset the original TimeTrigger. This will recalculate the activation time for this trigger.

Specified by:
reset in interface Trigger

toString

public java.lang.String toString()


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.