Class RecentFilesList


  • public class RecentFilesList
    extends java.lang.Object
    List of recently used files.

    Provides functionality to keep a list of a certain max size. New files are added to the top. When a file is added that is already in the list, it is shuffled to the top. When the maximum list size has been reached, files start dropping off the end.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<java.io.File> list
      The list.
      private int max
      The max.
    • Constructor Summary

      Constructors 
      Constructor Description
      RecentFilesList​(int maxSize)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addFile​(java.io.File file)
      Add a file at the beginning.
      void appendFile​(java.io.File file)
      Append a file at the end of the list (useful for initialization).
      java.util.List<java.io.File> getFileList()
      Get the internal list of files, in the proper order (most recent first).
      private void shiftRight()
      Shift right.
      java.util.List<java.lang.String> toStringList()
      Return the file list as a list of strings for persistence.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • list

        private final java.util.List<java.io.File> list
        The list.
      • max

        private final int max
        The max.
    • Constructor Detail

      • RecentFilesList

        public RecentFilesList​(int maxSize)
        Constructor.
        Parameters:
        maxSize - The maximum size to which the list can grow.
    • Method Detail

      • getFileList

        public java.util.List<java.io.File> getFileList()
        Get the internal list of files, in the proper order (most recent first).
        Returns:
        A recency-sorted list of files.
      • appendFile

        public void appendFile​(java.io.File file)
        Append a file at the end of the list (useful for initialization).
        Parameters:
        file - The file to be added.
      • addFile

        public void addFile​(java.io.File file)
        Add a file at the beginning. If maximum capacity is exceeded, drop last file. If file is already in the list, move it to the front.
        Parameters:
        file - The file to be added.
      • shiftRight

        private final void shiftRight()
        Shift right.
      • toStringList

        public java.util.List<java.lang.String> toStringList()
        Return the file list as a list of strings for persistence.
        Returns:
        The file list as a list of absolute file names.