net.sourceforge.java.util.jobs.scheduling
Class JobExecutionInterval

java.lang.Object
  extended bynet.sourceforge.java.util.jobs.scheduling.JobExecutionInterval
All Implemented Interfaces:
EventListener, ILanguageResourceChangeListener

public class JobExecutionInterval
extends Object
implements ILanguageResourceChangeListener

Represents an interval for a repeated automatic execution of an IJob within the JobManager scheduler context.

Author:
Sebastian Machhausen

Field Summary
static JobExecutionInterval APPLICATION_STARTUP
           Default interval of 1 (execution at application startup)
static JobExecutionInterval[] DEFAULT_INTERVALS
           The predefined intervals
static JobExecutionInterval EIGHT_HOURS
           Default interval of 8 hours
static JobExecutionInterval FIFTEEN_MINUTES
           Default interval of 15 minutes
static JobExecutionInterval FIVE_MINUTES
           Default interval of 5 minutes
static JobExecutionInterval FOUR_HOURS
           Default interval of 4 hours
static JobExecutionInterval FOUR_MINUTES
           Default interval of 4 minutes
private  String localizedPeriod
           The localized textual representation of a period
static JobExecutionInterval NO_EXECUTION
           Default interval of zero (no execution)
static JobExecutionInterval ONE_DAY
           Default interval of 1 day
static JobExecutionInterval ONE_HOUR
           Default interval of 1 hour
static JobExecutionInterval ONE_MINUTE
           Default interval of 1 minute
static JobExecutionInterval ONE_WEEK
           Default interval of 1 week
private  long period
           The period in milliseconds that separates executions of an IJob.
static JobExecutionInterval TEN_MINUTES
           Default interval of 10 minutes
static JobExecutionInterval THIRTY_MINUTES
           Default interval of 30 minutes
static JobExecutionInterval THREE_MINUTES
           Default interval of 3 minutes
static JobExecutionInterval TWELVE_HOURS
           Default interval of 12 hours
static JobExecutionInterval TWO_HOURS
           Default interval of 2 hours
static JobExecutionInterval TWO_MINUTES
           Default interval of 2 minutes
 
Constructor Summary
JobExecutionInterval(long period)
           Creates a new JobExceutionInterval.
 
Method Summary
 void defaultLanguageChanged(LanguageResourceChangeEvent lrce)
           Called whenever the configured default language changed.
protected  void finalize()
           Fianlizes this JobExecutionInterval instance.
static JobExecutionInterval getInterval(long period)
           Gets the JobExecutionInterval that matches the specified period.
 String getLocalizedPeriod()
           Gets the localized textual representation of the currently set period as returned by the getPeriod() method, e.g. "5 minutes".
 long getPeriod()
           Gets the period in milliseconds that separates subsequent executions of an IJob.
private  void initializeLocalizedPeriod()
           Initializes the localized textual representation of the currently set period as returned by the getPeriod() method, e.g. "5 minutes".
 void setPeriod(long period)
           Sets the period in milliseconds that separates subsequent executions of an IJob.
 String toString()
           Gets the textual representation of this JobExecutionInterval instance.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_EXECUTION

public static final JobExecutionInterval NO_EXECUTION

Default interval of zero (no execution)


APPLICATION_STARTUP

public static final JobExecutionInterval APPLICATION_STARTUP

Default interval of 1 (execution at application startup)


ONE_MINUTE

public static final JobExecutionInterval ONE_MINUTE

Default interval of 1 minute


TWO_MINUTES

public static final JobExecutionInterval TWO_MINUTES

Default interval of 2 minutes


THREE_MINUTES

public static final JobExecutionInterval THREE_MINUTES

Default interval of 3 minutes


FOUR_MINUTES

public static final JobExecutionInterval FOUR_MINUTES

Default interval of 4 minutes


FIVE_MINUTES

public static final JobExecutionInterval FIVE_MINUTES

Default interval of 5 minutes


TEN_MINUTES

public static final JobExecutionInterval TEN_MINUTES

Default interval of 10 minutes


FIFTEEN_MINUTES

public static final JobExecutionInterval FIFTEEN_MINUTES

Default interval of 15 minutes


THIRTY_MINUTES

public static final JobExecutionInterval THIRTY_MINUTES

Default interval of 30 minutes


ONE_HOUR

public static final JobExecutionInterval ONE_HOUR

Default interval of 1 hour


TWO_HOURS

public static final JobExecutionInterval TWO_HOURS

Default interval of 2 hours


FOUR_HOURS

public static final JobExecutionInterval FOUR_HOURS

Default interval of 4 hours


EIGHT_HOURS

public static final JobExecutionInterval EIGHT_HOURS

Default interval of 8 hours


TWELVE_HOURS

public static final JobExecutionInterval TWELVE_HOURS

Default interval of 12 hours


ONE_DAY

public static final JobExecutionInterval ONE_DAY

Default interval of 1 day


ONE_WEEK

public static final JobExecutionInterval ONE_WEEK

Default interval of 1 week


DEFAULT_INTERVALS

public static final JobExecutionInterval[] DEFAULT_INTERVALS

The predefined intervals


period

private long period

The period in milliseconds that separates executions of an IJob.


localizedPeriod

private String localizedPeriod

The localized textual representation of a period

Constructor Detail

JobExecutionInterval

public JobExecutionInterval(long period)

Creates a new JobExceutionInterval.

Parameters:
period - period the period in milliseconds that separates executions of an IJob
Method Detail

setPeriod

public void setPeriod(long period)

Sets the period in milliseconds that separates subsequent executions of an IJob.

Parameters:
period - the period in milliseconds that separates subsequent executions of an IJob
Throws:
IllegalArgumentException - if a value less than zero is specified for period

getPeriod

public long getPeriod()

Gets the period in milliseconds that separates subsequent executions of an IJob.

Returns:
the period in milliseconds that separates subsequent executions of an IJob

getLocalizedPeriod

public String getLocalizedPeriod()

Gets the localized textual representation of the currently set period as returned by the getPeriod() method, e.g. "5 minutes".

Returns:
the localized textual representation of the currently set period as returned by the getPeriod() method, e.g. "5 minutes"

toString

public String toString()

Gets the textual representation of this JobExecutionInterval instance. This method returns the localized textual representation of the currently set period as returned by the getLocalizedPeriod() method, e.g. "5 minutes".

Returns:
the textual representation of this JobExecutionInterval instance

defaultLanguageChanged

public void defaultLanguageChanged(LanguageResourceChangeEvent lrce)

Called whenever the configured default language changed. This method reinitializes the localized period String.

Specified by:
defaultLanguageChanged in interface ILanguageResourceChangeListener
Parameters:
lrce - the triggered LanguageResourceChangeEvent

getInterval

public static JobExecutionInterval getInterval(long period)

Gets the JobExecutionInterval that matches the specified period. If none of the predefined JobExecutionIntervals matches the specified period the default NO_EXECUTION JobExecutionInterval is returned.

Parameters:
period - the period to get the JobExecutionIntevral for
Returns:
the JobExecutionInterval matching the specified period

finalize

protected void finalize()
                 throws Throwable

Fianlizes this JobExecutionInterval instance.

Throws:
Throwable - if an error occured during finalization

initializeLocalizedPeriod

private void initializeLocalizedPeriod()

Initializes the localized textual representation of the currently set period as returned by the getPeriod() method, e.g. "5 minutes".