Package org.savantbuild.io
Class FileSet
java.lang.Object
org.savantbuild.io.FileSet
- Direct Known Subclasses:
ArchiveFileSet
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new FileSet.FileSet(Path directory, Collection<Pattern> includePatterns, Collection<Pattern> excludePatterns) Constructs a new FileSet. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringattributesValid(Map<String, Object> attributes) Determines if the attributes given can be used to construct a FileSet.static FileSetfromAttributes(Path dir, Map<String, Object> attributes) Constructs a FileSet from a Map of attributes.Builds the set of directories that all of the files in this FileSet are contained within.Converts this FileSet to a list of FileInfo objects.withExcludePatterns(List<Pattern> excludePatterns) Sets the excludePatterns.withIncludePatterns(List<Pattern> includePatterns) Sets the includePatterns.
-
Field Details
-
REQUIRED_ATTRIBUTES
-
VALID_ATTRIBUTES
-
directory
-
excludePatterns
-
includePatterns
-
-
Constructor Details
-
FileSet
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
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
Constructs a FileSet from a Map of attributes.- Parameters:
dir- The directory for the FileSet.attributes- The attributes.- Returns:
- The FileSet.
-
toDirectories
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
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
Sets the excludePatterns.- Parameters:
excludePatterns- The excludePatterns.- Returns:
- This.
-
withIncludePatterns
Sets the includePatterns.- Parameters:
includePatterns- The includePatterns.- Returns:
- This.
-