Class IncludeExcludeFileSelector

  • All Implemented Interfaces:
    FileSelector

    public class IncludeExcludeFileSelector
    extends java.lang.Object
    implements FileSelector
    This file selector uses a set of patterns for including/excluding files.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ROLE_HINT
      The include/exclude file selectors role-hint: "standard".
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String[] getExcludes()
      Returns the list of exclude patterns to use.
      java.lang.String[] getIncludes()
      Returns the list of include patterns to use.
      boolean isCaseSensitive()
      Returns, whether the include/exclude patterns are case sensitive.
      protected boolean isExcluded​(java.lang.String name)
      Tests whether or not a name matches against at least one exclude pattern.
      protected boolean isIncluded​(java.lang.String name)
      Tests whether or not a name matches against at least one include pattern.
      boolean isSelected​(FileInfo fileInfo)
      Returns, whether the given file is selected.
      boolean isUseDefaultExcludes()
      Returns, whether to use the default excludes, as specified by FileUtils.getDefaultExcludes().
      protected boolean matchPath​(java.lang.String pattern, java.lang.String name, boolean isCaseSensitive)
      Tests, whether the given pattern is matching the given name.
      void setCaseSensitive​(boolean caseSensitive)
      Sets, whether the include/exclude patterns are case sensitive.
      void setExcludes​(java.lang.String[] excludes)
      Sets the list of exclude patterns to use.
      void setIncludes​(java.lang.String[] includes)
      Sets the list of include patterns to use.
      void setUseDefaultExcludes​(boolean pUseDefaultExcludes)
      Sets, whether to use the default excludes, as specified by FileUtils.getDefaultExcludes().
      • Methods inherited from class java.lang.Object

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

      • ROLE_HINT

        public static final java.lang.String ROLE_HINT
        The include/exclude file selectors role-hint: "standard".
        See Also:
        Constant Field Values
    • Constructor Detail

      • IncludeExcludeFileSelector

        public IncludeExcludeFileSelector()
    • Method Detail

      • isExcluded

        protected boolean isExcluded​(@Nonnull
                                     java.lang.String name)
        Tests whether or not a name matches against at least one exclude pattern.
        Parameters:
        name - The name to match. Must not be null.
        Returns:
        true when the name matches against at least one exclude pattern, or false otherwise.
      • setIncludes

        public void setIncludes​(@Nullable
                                java.lang.String[] includes)
        Sets the list of include patterns to use. All '/' and '\' characters are replaced by File.separatorChar, so the separator used need not match File.separatorChar.

        When a pattern ends with a '/' or '\', "**" is appended.

        Parameters:
        includes - A list of include patterns. May be null, indicating that all files should be included. If a non-null list is given, all elements must be non-null.
      • getIncludes

        @Nullable
        public java.lang.String[] getIncludes()
        Returns the list of include patterns to use.
        Returns:
        A list of include patterns. May be null, indicating that all files should be included. If a non-null list is given, all elements must be non-null.
      • setExcludes

        public void setExcludes​(@Nullable
                                java.lang.String[] excludes)
        Sets the list of exclude patterns to use. All '/' and '\' characters are replaced by File.separatorChar, so the separator used need not match File.separatorChar.

        When a pattern ends with a '/' or '\', "**" is appended.

        Parameters:
        excludes - A list of exclude patterns. May be null, indicating that no files should be excluded. If a non-null list is given, all elements must be non-null.
      • getExcludes

        @Nullable
        public java.lang.String[] getExcludes()
        Returns the list of exclude patterns to use.
        Returns:
        A list of exclude patterns. May be null, indicating that no files should be excluded. If a non-null list is given, all elements must be non-null.
      • matchPath

        protected boolean matchPath​(@Nonnull
                                    java.lang.String pattern,
                                    @Nonnull
                                    java.lang.String name,
                                    boolean isCaseSensitive)
        Tests, whether the given pattern is matching the given name.
        Parameters:
        pattern - The pattern to match
        name - The name to test
        isCaseSensitive - Whether the pattern is case sensitive.
        Returns:
        True, if the pattern matches, otherwise false
      • isIncluded

        protected boolean isIncluded​(@Nonnull
                                     java.lang.String name)
        Tests whether or not a name matches against at least one include pattern.
        Parameters:
        name - The name to match. Must not be null.
        Returns:
        true when the name matches against at least one include pattern, or false otherwise.
      • isSelected

        public boolean isSelected​(@Nonnull
                                  FileInfo fileInfo)
        Description copied from interface: FileSelector
        Returns, whether the given file is selected.
        Specified by:
        isSelected in interface FileSelector
        Parameters:
        fileInfo - An instance of FileInfo with the files meta data. It is recommended, that the caller creates an instance of PlexusIoResource.
      • isCaseSensitive

        public boolean isCaseSensitive()
        Returns, whether the include/exclude patterns are case sensitive.
        Returns:
        True, if the patterns are case sensitive (default), or false.
      • setCaseSensitive

        public void setCaseSensitive​(boolean caseSensitive)
        Sets, whether the include/exclude patterns are case sensitive.
        Parameters:
        caseSensitive - True, if the patterns are case sensitive (default), or false.
      • isUseDefaultExcludes

        public boolean isUseDefaultExcludes()
        Returns, whether to use the default excludes, as specified by FileUtils.getDefaultExcludes().
      • setUseDefaultExcludes

        public void setUseDefaultExcludes​(boolean pUseDefaultExcludes)
        Sets, whether to use the default excludes, as specified by FileUtils.getDefaultExcludes().