Package PamUtils.worker.filelist
Class FileListData<T extends File>
java.lang.Object
PamUtils.worker.filelist.FileListData<T>
- All Implemented Interfaces:
Cloneable
Information about a list of files.
- Author:
- dg50
-
Constructor Summary
ConstructorsConstructorDescriptionFileListData
(String[] rootList, boolean subFolders, boolean useOldIfPossible) -
Method Summary
Modifier and TypeMethodDescriptionint
void
void
clear()
Clear the file list.protected FileListData
<T> clone()
filterDuplicateFiles
(List<? extends File> files, String preferredExtension) Filters a list of File objects to remove duplicates based on the name (excluding extension).int
int
String[]
boolean
boolean
void
removeDuplicates
(String preferredExtension) Remove duplicates from the file list, keeping only the first instance of each file name.void
sort()
Sort using internal compartor of list type.void
sort
(Comparator<T> comparator) Sort using supplied comparator.void
Sort the file list, sorting only by name, not path.void
Sort the file list, sorting by the full path.
-
Constructor Details
-
FileListData
-
-
Method Details
-
addFile
-
clear
public void clear()Clear the file list. -
getFileIterator
-
getFileCount
public int getFileCount() -
getListCopy
-
addFolder
public void addFolder() -
getFoldersSearched
public int getFoldersSearched() -
getRootList
-
isSubFolders
public boolean isSubFolders() -
isUseOldIfPossible
public boolean isUseOldIfPossible() -
sortFileList
public void sortFileList()Sort the file list, sorting only by name, not path. -
removeDuplicates
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
Sort using supplied comparator.- Parameters:
comparator
-
-
sort
public void sort()Sort using internal compartor of list type. -
clone
-
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.
-