uk.org.simonsite.log4j.appender
Class TimeBasedRollStrategy

java.lang.Object
  extended by uk.org.simonsite.log4j.appender.TimeBasedRollStrategy

abstract class TimeBasedRollStrategy
extends Object

Responsible for selecting the appropriate time-based rolling strategy at start-up, based upon the contents of the Appender's DatePattern property; also responsible for computing the next roll time. This class is heavily dependent upon the specification of the JDK's SimpleDateFormat class, whose pattern letters are used to select the rolling strategy.

Version:
3.1
Author:
Simon Park
See Also:
SimpleDateFormat

Field Summary
(package private) static TimeBasedRollStrategy ROLL_EACH_DAY
           
(package private) static TimeBasedRollStrategy ROLL_EACH_HALF_DAY
           
(package private) static TimeBasedRollStrategy ROLL_EACH_HOUR
           
(package private) static TimeBasedRollStrategy ROLL_EACH_MINUTE
           
(package private) static TimeBasedRollStrategy ROLL_EACH_MONTH
           
(package private) static TimeBasedRollStrategy ROLL_EACH_WEEK
           
(package private) static TimeBasedRollStrategy ROLL_EACH_YEAR
           
(package private) static TimeBasedRollStrategy ROLL_ERROR
           
 
Constructor Summary
TimeBasedRollStrategy()
           
 
Method Summary
(package private) static TimeBasedRollStrategy findRollStrategy(AppenderRollingProperties properties)
          Checks each available roll strategy in turn, starting at the per-minute strategy, next per-hour, and so on for increasing units of time until a match is found.
(package private) abstract  boolean isRequiredStrategy(LocalizedDateFormatPatternHelper localizedDateFormatPatternHelper, String datePattern)
           
(package private) abstract  long nextRollTimeInMillis(long nowInMillis, AppenderRollingProperties properties)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROLL_ERROR

static final TimeBasedRollStrategy ROLL_ERROR

ROLL_EACH_MINUTE

static final TimeBasedRollStrategy ROLL_EACH_MINUTE

ROLL_EACH_HOUR

static final TimeBasedRollStrategy ROLL_EACH_HOUR

ROLL_EACH_HALF_DAY

static final TimeBasedRollStrategy ROLL_EACH_HALF_DAY

ROLL_EACH_DAY

static final TimeBasedRollStrategy ROLL_EACH_DAY

ROLL_EACH_WEEK

static final TimeBasedRollStrategy ROLL_EACH_WEEK

ROLL_EACH_MONTH

static final TimeBasedRollStrategy ROLL_EACH_MONTH

ROLL_EACH_YEAR

static final TimeBasedRollStrategy ROLL_EACH_YEAR
Constructor Detail

TimeBasedRollStrategy

TimeBasedRollStrategy()
Method Detail

findRollStrategy

static final TimeBasedRollStrategy findRollStrategy(AppenderRollingProperties properties)
Checks each available roll strategy in turn, starting at the per-minute strategy, next per-hour, and so on for increasing units of time until a match is found. If no match is found, the error strategy is returned.

Parameters:
properties -
Returns:
The appropriate roll strategy.

isRequiredStrategy

abstract boolean isRequiredStrategy(LocalizedDateFormatPatternHelper localizedDateFormatPatternHelper,
                                    String datePattern)
Parameters:
localizedDateFormatPatternHelper -
datePattern - The appender's pattern, stripped of quoted sections that might interfere with pattern matching.
Returns:
true if the implementor rolls by the unit of time found in the specified datePattern.

nextRollTimeInMillis

abstract long nextRollTimeInMillis(long nowInMillis,
                                   AppenderRollingProperties properties)
Parameters:
nowInMillis -
properties -
Returns:
The next roll time based upon the implementor's unit of time.