Class FileListData<T extends File>

java.lang.Object
PamUtils.worker.filelist.FileListData<T>
All Implemented Interfaces:
Cloneable

public class FileListData<T extends File> extends Object implements Cloneable
Information about a list of files.
Author:
dg50
  • Constructor Details

    • FileListData

      public FileListData(String[] rootList, boolean subFolders, boolean useOldIfPossible)
  • Method Details

    • addFile

      public int addFile(T aFile)
    • clear

      public void clear()
      Clear the file list.
    • getFileIterator

      public ListIterator<T> getFileIterator()
    • getFileCount

      public int getFileCount()
    • getListCopy

      public ArrayList<T> getListCopy()
    • addFolder

      public void addFolder()
    • getFoldersSearched

      public int getFoldersSearched()
    • getRootList

      public String[] getRootList()
    • isSubFolders

      public boolean isSubFolders()
    • isUseOldIfPossible

      public boolean isUseOldIfPossible()
    • sortFileList

      public void sortFileList()
      Sort the file list, sorting only by name, not path.
    • removeDuplicates

      public void removeDuplicates(String preferredExtension)
      Remove duplicates from the file list, keeping only the first instance of each file name. If a preferred extension is provided, it will keep the file with that extension if duplicates exist.
      Parameters:
      preferredExtension - - the preferred file extension to keep in case of duplicates.
    • sortFilePath

      public void sortFilePath()
      Sort the file list, sorting by the full path.
    • sort

      public void sort(Comparator<T> comparator)
      Sort using supplied comparator.
      Parameters:
      comparator -
    • sort

      public void sort()
      Sort using internal compartor of list type.
    • clone

      protected FileListData<T> clone()
      Overrides:
      clone in class Object
    • filterDuplicateFiles

      public static List<? extends File> filterDuplicateFiles(List<? extends File> files, String preferredExtension)
      Filters a list of File objects to remove duplicates based on the name (excluding extension). If duplicates exist, it keeps the one with the preferred extension. If none of the duplicates have the preferred extension, it keeps the first encountered duplicate File object from the original list.
      Parameters:
      files - A list of File objects.
      preferredExtension - The preferred file extension (e.g., "pdf", "docx").
      Returns:
      A new list of File objects with duplicates removed according to the specified rules.