Class FileSet

java.lang.Object
org.savantbuild.io.FileSet
Direct Known Subclasses:
ArchiveFileSet

public class FileSet extends Object
A FileSet represents a set of files within a directory. Currently, this only models all of the files contained in a directory and all sub-directories below it.
  • Field Details

    • REQUIRED_ATTRIBUTES

      public static final Set<String> REQUIRED_ATTRIBUTES
    • VALID_ATTRIBUTES

      public static final Set<String> VALID_ATTRIBUTES
    • directory

      public final Path directory
    • excludePatterns

      public final Set<Pattern> excludePatterns
    • includePatterns

      public final Set<Pattern> includePatterns
  • Constructor Details

    • FileSet

      public FileSet(Path directory)
      Constructs a new FileSet.
      Parameters:
      directory - The directory of the FileSet.
    • FileSet

      public FileSet(Path directory, Collection<Pattern> includePatterns, Collection<Pattern> excludePatterns)
      Constructs a new FileSet. The directory is required but everything else is optional.
      Parameters:
      directory - The directory of the FileSet.
      includePatterns - (Optional) A list of regular expression Pattern objects that list the files to include.
      excludePatterns - (Optional) A list of regular expression Pattern objects that list the files to exclude.
  • Method Details

    • attributesValid

      public static String attributesValid(Map<String,Object> attributes)
      Determines if the attributes given can be used to construct a FileSet.
      Parameters:
      attributes - The attributes.
      Returns:
      Null if the attributes are valid, an error message describing why they aren't valid.
    • fromAttributes

      public static FileSet fromAttributes(Path dir, Map<String,Object> attributes)
      Constructs a FileSet from a Map of attributes.
      Parameters:
      dir - The directory for the FileSet.
      attributes - The attributes.
      Returns:
      The FileSet.
    • toDirectories

      public Set<Directory> toDirectories() throws IOException
      Builds the set of directories that all of the files in this FileSet are contained within.
      Returns:
      The directories.
      Throws:
      IOException - If the build fails.
    • toFileInfos

      public List<FileInfo> toFileInfos() throws IOException
      Converts this FileSet to a list of FileInfo objects. The info objects contain the origin Path and a relative Path. They also include additional information about the file.
      Returns:
      A List of FileInfo objects for this FileSet.
      Throws:
      IOException - If the directory traversal fails.
    • withExcludePatterns

      public FileSet withExcludePatterns(List<Pattern> excludePatterns)
      Sets the excludePatterns.
      Parameters:
      excludePatterns - The excludePatterns.
      Returns:
      This.
    • withIncludePatterns

      public FileSet withIncludePatterns(List<Pattern> includePatterns)
      Sets the includePatterns.
      Parameters:
      includePatterns - The includePatterns.
      Returns:
      This.