Class FileRotater


  • public class FileRotater
    extends Object
    Responsible for the log file rotate management as used by the FileProtocol class.

    This class implements a flexible log file rotate management system. For a detailed description of how to use this class, please refer to the documentation of the initialize, update and setMode methods.

    Note: This class is not guaranteed to be threadsafe.

    • Constructor Detail

      • FileRotater

        public FileRotater()
        Creates a new FileRotater instance with a default mode of FileRotate.None. Please refer to the update and initialize methods for additional information about this class.
    • Method Detail

      • initialize

        public void initialize​(Date now)
        Initializes this FileRotater object with a user-supplied timestamp.

        Always call this method after creating a new FileRotater object and before calling the update method the first time. For additional information please refer to the update method.

        Parameters:
        now - The user-specified timestamp to use to initialize this object.
      • update

        public boolean update​(Date now)
                       throws Exception
        This method updates the internal date of this FileRotater object and returns whether the rotate state has changed since the last call to this method or to initialize. Before calling this method, always call the initialize method.
        Parameters:
        now - The timestamp to update this object
        Returns:
        True if the rotate state has changed since the last call to this method or to initialize and false otherwise
        Throws:
        Exception - exception
      • getMode

        public FileRotate getMode()
        Returns the FileRotate mode of this FileRotater object.

        This method returns the current FileRotate mode. For a complete list of available return values, please refer to the FileRotate enum.

        Returns:
        The FileRotate mode of this FileRotater object.
      • setMode

        public void setMode​(FileRotate mode)
        Sets the FileRotate mode of this FileRotater object.

        Always call the initialize method after changing the log rotate mode to reinitialize this FileRotater object. For a complete list of available file log rotate values, please refer to the FileRotate enum.

        Parameters:
        mode - The new FileRotate mode.
        Throws:
        NullPointerException - if the mode argument is null.