001/**
002 * Logback: the reliable, generic, fast and flexible logging framework.
003 * Copyright (C) 1999-2022, QOS.ch. All rights reserved.
004 *
005 * This program and the accompanying materials are dual-licensed under
006 * either the terms of the Eclipse Public License v1.0 as published by
007 * the Eclipse Foundation
008 *
009 *   or (per the licensee's choosing)
010 *
011 * under the terms of the GNU Lesser General Public License version 2.1
012 * as published by the Free Software Foundation.
013 */
014package ch.qos.logback.core.rolling;
015
016import ch.qos.logback.core.rolling.helper.ArchiveRemover;
017import ch.qos.logback.core.spi.ContextAware;
018
019/**
020 * This interface lists the set of methods that need to be implemented by
021 * triggering policies which are nested within a {@link TimeBasedRollingPolicy}.
022 *
023 * <p>This interface should be considered as an extension of  {@link TimeBasedRollingPolicy} with file naming
024 * support methods.
025 * </p>
026 *
027 * @See also {@link TimeBasedFileNamingAndTriggeringPolicyBase}
028 *
029 * @author Ceki G&uuml;lc&uuml;
030 * 
031 * @param <E>
032 */
033public interface TimeBasedFileNamingAndTriggeringPolicy<E> extends TriggeringPolicy<E>, ContextAware {
034
035    /**
036     * Set the host/parent {@link TimeBasedRollingPolicy}.
037     * 
038     * @param tbrp parent TimeBasedRollingPolicy
039     */
040    void setTimeBasedRollingPolicy(TimeBasedRollingPolicy<E> tbrp);
041
042    /**
043     * Return the file name for the elapsed periods file name.
044     * 
045     * @return
046     */
047    String getElapsedPeriodsFileName();
048
049    /**
050     * Return the current periods file name without the compression suffix. This
051     * value is equivalent to the active file name.
052     * 
053     * @return current period's file name (without compression suffix)
054     */
055    String getCurrentPeriodsFileNameWithoutCompressionSuffix();
056
057    /**
058     * Return the archive remover appropriate for this instance.
059     */
060    ArchiveRemover getArchiveRemover();
061
062    /**
063     * Return the current time which is usually the value returned by
064     * System.currentMillis(). However, for <b>testing</b> purposed this value may
065     * be different than the real time.
066     * 
067     * @return current time value
068     */
069    long getCurrentTime();
070
071    /**
072     * Set the current time. Only unit tests should invoke this method.
073     * 
074     * @param now
075     */
076    void setCurrentTime(long now);
077
078    /**
079     * Set some date in the current period. Only unit tests should invoke this
080     * method.
081     * 
082     * WARNING: method removed. A unit test should not set the date in current
083     * period. It is the job of the FNATP to compute that.
084     * 
085     * @param date
086     */
087    // void setDateInCurrentPeriod(Date date);
088}