Class WildcardOSFilter

  • All Implemented Interfaces:
    FileFilter, FilenameFilter, FileVisitor<Path>, PathMatcher, org.apache.commons.io.file.PathFilter, org.apache.commons.io.file.PathVisitor, org.apache.commons.io.filefilter.IOFileFilter

    public class WildcardOSFilter
    extends org.apache.commons.io.filefilter.AbstractFileFilter
    Filters files using supplied wildcard(s). Based on the Apache WildcardFilter class in the Commons IO package. Difference is that in this class, it uses the org.apache.commons.io.FilenameUtils.wildcardMatchOnSystem() for its matching rules, which means that pattern matching using this class is OS dependent (case-insensitive on Windows and case-sensitive on Unix, Linux, MAC)
    Version:
    $Revision: 8573 $
    Author:
    mcayanan
    • Field Summary

      • Fields inherited from interface org.apache.commons.io.filefilter.IOFileFilter

        EMPTY_STRING_ARRAY
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean accept​(File file)
      Checks to see if the filename matches one of the wildcards.
      boolean accept​(File dir, String name)
      Checks to see if the filename matches one of the wildcards.
      List<String> getWildcards()
      Returns list of filters that were set.
      • Methods inherited from class org.apache.commons.io.filefilter.AbstractFileFilter

        handle, postVisitDirectory, preVisitDirectory, toString, visitFile, visitFileFailed
      • Methods inherited from interface org.apache.commons.io.filefilter.IOFileFilter

        accept, and, matches, negate, or
    • Constructor Detail

      • WildcardOSFilter

        public WildcardOSFilter​(String wc)
        Constructor for a single wildcard.
        Parameters:
        wc - a single filter to set
      • WildcardOSFilter

        public WildcardOSFilter​(List<String> wc)
        Constructor for a list of wildcards.
        Parameters:
        wc - a list of filters to set.
    • Method Detail

      • getWildcards

        public List<String> getWildcards()
        Returns list of filters that were set.
        Returns:
        a list of filters
      • accept

        public boolean accept​(File file)
        Checks to see if the filename matches one of the wildcards. Matching is case-insensitive for Windows and case-sensitive for Unix.
        Specified by:
        accept in interface FileFilter
        Specified by:
        accept in interface org.apache.commons.io.filefilter.IOFileFilter
        Overrides:
        accept in class org.apache.commons.io.filefilter.AbstractFileFilter
        Parameters:
        file - the file to check.
        Returns:
        true if the filename matches one of the wildcards.
      • accept

        public boolean accept​(File dir,
                              String name)
        Checks to see if the filename matches one of the wildcards. Matching is case-insensitive for Windows and case-sensitive for Unix.
        Specified by:
        accept in interface FilenameFilter
        Specified by:
        accept in interface org.apache.commons.io.filefilter.IOFileFilter
        Overrides:
        accept in class org.apache.commons.io.filefilter.AbstractFileFilter
        Parameters:
        dir - the directory to check.
        name - the file name within the directory to check.
        Returns:
        true if the filename matches one of the wildcards, false otherwise.