Class FileExtensionSelector

java.lang.Object
org.apache.commons.vfs2.FileExtensionSelector
All Implemented Interfaces:
FileSelector

public class FileExtensionSelector extends Object implements FileSelector
A FileSelector that selects based on file extensions.

The extension comparison is case insensitive.

The selector makes a copy of a given Collection or array. Changing the object passed in the constructors will not affect the selector.

Since:
2.1
  • Field Details

    • extensions

      private final Set<String> extensions
      The extensions to select.
  • Constructor Details

    • FileExtensionSelector

      public FileExtensionSelector(Collection<String> extensions)
      Creates a new selector for the given extensions.
      Parameters:
      extensions - The extensions to be included by this selector.
    • FileExtensionSelector

      public FileExtensionSelector(String... extensions)
      Creates a new selector for the given extensions.
      Parameters:
      extensions - The extensions to be included by this selector.
  • Method Details

    • includeFile

      public boolean includeFile(FileSelectInfo fileInfo) throws Exception
      Determines if a file or folder should be selected.
      Specified by:
      includeFile in interface FileSelector
      Parameters:
      fileInfo - The file selection information.
      Returns:
      true if the file should be selected, false otherwise.
      Throws:
      Exception - if an error occurs.
    • traverseDescendents

      public boolean traverseDescendents(FileSelectInfo fileInfo) throws Exception
      Determines whether a folder should be traversed.
      Specified by:
      traverseDescendents in interface FileSelector
      Parameters:
      fileInfo - The file selection information.
      Returns:
      true if descendants should be traversed, fase otherwise.
      Throws:
      Exception - if an error occurs.