Package org.apache.tools.ant.types
Class AbstractFileSet
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.types.DataType
org.apache.tools.ant.types.AbstractFileSet
- All Implemented Interfaces:
java.lang.Cloneable
,SelectorContainer
- Direct Known Subclasses:
DirSet
,FileSet
,MultiRootFileSet
,Sync.SyncTarget
public abstract class AbstractFileSet extends DataType implements java.lang.Cloneable, SelectorContainer
Class that holds an implicit patternset and supports nested
patternsets and creates a DirectoryScanner using these patterns.
Common base class for DirSet and FileSet.
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description AbstractFileSet()
Construct a newAbstractFileSet
.protected
AbstractFileSet(AbstractFileSet fileset)
Construct a newAbstractFileSet
, shallowly cloned from the specifiedAbstractFileSet
. -
Method Summary
Modifier and Type Method Description void
add(FileSelector selector)
Add an arbitrary selector.void
addAnd(AndSelector selector)
Add an "And" selector entry on the selector list.void
addContains(ContainsSelector selector)
Add a contains selector entry on the selector list.void
addContainsRegexp(ContainsRegexpSelector selector)
Add a regular expression selector entry on the selector list.void
addCustom(ExtendSelector selector)
Add an extended selector entry on the selector list.void
addDate(DateSelector selector)
Add a selector date entry on the selector list.void
addDepend(DependSelector selector)
Add a depends selector entry on the selector list.void
addDepth(DepthSelector selector)
Add a depth selector entry on the selector list.void
addDifferent(DifferentSelector selector)
Add a DifferentSelector entry on the selector list.void
addExecutable(ExecutableSelector e)
void
addFilename(FilenameSelector selector)
Add a selector filename entry on the selector list.void
addMajority(MajoritySelector selector)
Add a majority selector entry on the selector list.void
addModified(ModifiedSelector selector)
Add the modified selector.void
addNone(NoneSelector selector)
Add a "None" selector entry on the selector list.void
addNot(NotSelector selector)
Add a "Not" selector entry on the selector list.void
addOr(OrSelector selector)
Add an "Or" selector entry on the selector list.void
addOwnedBy(OwnedBySelector o)
void
addPosixGroup(PosixGroupSelector o)
void
addPosixPermissions(PosixPermissionsSelector o)
void
addPresent(PresentSelector selector)
Add a present selector entry on the selector list.void
addReadable(ReadableSelector r)
void
addSelector(SelectSelector selector)
Add a "Select" selector entry on the selector list.void
addSize(SizeSelector selector)
Add a selector size entry on the selector list.void
addSymlink(SymlinkSelector e)
void
addType(TypeSelector selector)
Add a selector type entry on the selector list.void
addWritable(WritableSelector w)
void
appendExcludes(java.lang.String[] excludes)
Appendsexcludes
to the current list of exclude patterns.void
appendIncludes(java.lang.String[] includes)
Appendsincludes
to the current list of include patterns.void
appendSelector(FileSelector selector)
Add a new selector into this container.java.lang.Object
clone()
Creates a deep clone of this instance, except for the nested selectors (the list of selectors is a shallow clone of this instance's list).PatternSet.NameEntry
createExclude()
Add a name entry to the exclude list.PatternSet.NameEntry
createExcludesFile()
Add a name entry to the excludes files list.PatternSet.NameEntry
createInclude()
Add a name entry to the include list.PatternSet.NameEntry
createIncludesFile()
Add a name entry to the include files list.PatternSet
createPatternSet()
Creates a nested patternset.protected void
dieOnCircularReference(java.util.Stack<java.lang.Object> stk, Project p)
Check to see whether any DataType we hold references to is included in the Stack (which holds all DataType instances that directly or indirectly reference this instance, including this instance itself).boolean
getDefaultexcludes()
Whether default exclusions should be used or not.java.io.File
getDir()
Retrieves the base-directory for this instance.java.io.File
getDir(Project p)
Retrieves the base-directory for this instance.DirectoryScanner
getDirectoryScanner()
Returns the directory scanner needed to access the files to process.DirectoryScanner
getDirectoryScanner(Project p)
Returns the directory scanner needed to access the files to process.boolean
getErrorOnMissingDir()
Gets whether an error is/should be thrown if the base directory does not exist.int
getMaxLevelsOfSymlinks()
The maximum number of times a symbolic link may be followed during a scan.protected AbstractFileSet
getRef(Project p)
Performs the check for circular references and returns the referenced FileSet.FileSelector[]
getSelectors(Project p)
Returns the set of selectors as an array.boolean
hasPatterns()
Indicates whether there are any patterns here.boolean
hasSelectors()
Indicates whether there are any selectors here.boolean
isCaseSensitive()
Find out if the fileset is case sensitive.boolean
isFollowSymlinks()
Find out if the fileset wants to follow symbolic links.java.lang.String[]
mergeExcludes(Project p)
Get the merged exclude patterns for this AbstractFileSet.java.lang.String[]
mergeIncludes(Project p)
Get the merged include patterns for this AbstractFileSet.PatternSet
mergePatterns(Project p)
Get the merged patterns for this AbstractFileSet.int
selectorCount()
Gives the count of the number of selectors in this container.java.util.Enumeration<FileSelector>
selectorElements()
Returns an enumerator for accessing the set of selectors.void
setCaseSensitive(boolean caseSensitive)
Sets case sensitivity of the file system.void
setDefaultexcludes(boolean useDefaultExcludes)
Sets whether default exclusions should be used or not.void
setDir(java.io.File dir)
Sets the base-directory for this instance.void
setErrorOnMissingDir(boolean errorOnMissingDir)
Sets whether an error is thrown if a directory does not exist.void
setExcludes(java.lang.String excludes)
Appendsexcludes
to the current list of exclude patterns.void
setExcludesfile(java.io.File excl)
Sets theFile
containing the excludes patterns.void
setFile(java.io.File file)
Creates a single file fileset.void
setFollowSymlinks(boolean followSymlinks)
Sets whether or not symbolic links should be followed.void
setIncludes(java.lang.String includes)
Appendsincludes
to the current list of include patterns.void
setIncludesfile(java.io.File incl)
Sets theFile
containing the includes patterns.void
setMaxLevelsOfSymlinks(int max)
The maximum number of times a symbolic link may be followed during a scan.void
setRefid(Reference r)
Makes this instance in effect a reference to another instance.void
setupDirectoryScanner(FileScanner ds)
Set up the specified directory scanner against this AbstractFileSet's Project.void
setupDirectoryScanner(FileScanner ds, Project p)
Set up the specified directory scanner against the specified project.java.lang.String
toString()
Returns included files as a list of semicolon-separated filenames.Methods inherited from class org.apache.tools.ant.types.DataType
checkAttributesAllowed, checkChildrenAllowed, circularReference, dieOnCircularReference, dieOnCircularReference, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getDataTypeName, getRefid, invokeCircularReferenceCheck, isChecked, isReference, noChildrenAllowed, pushAndInvokeCircularReferenceCheck, setChecked, tooManyAttributes
Methods inherited from class org.apache.tools.ant.ProjectComponent
getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject
-
Constructor Details
-
AbstractFileSet
public AbstractFileSet()Construct a newAbstractFileSet
. -
AbstractFileSet
Construct a newAbstractFileSet
, shallowly cloned from the specifiedAbstractFileSet
.- Parameters:
fileset
- theAbstractFileSet
to use as a template.
-
-
Method Details
-
setRefid
Makes this instance in effect a reference to another instance.You must not set another attribute or nest elements inside this element if you make it a reference.
- Overrides:
setRefid
in classDataType
- Parameters:
r
- theReference
to use.- Throws:
BuildException
- on error
-
setDir
Sets the base-directory for this instance.- Parameters:
dir
- the directory'sFile
instance.- Throws:
BuildException
- on error
-
getDir
public java.io.File getDir()Retrieves the base-directory for this instance.- Returns:
File
.
-
getDir
Retrieves the base-directory for this instance.- Parameters:
p
- theProject
against which the reference is resolved, if set.- Returns:
File
.
-
createPatternSet
Creates a nested patternset.- Returns:
PatternSet
.
-
createInclude
Add a name entry to the include list.- Returns:
PatternSet.NameEntry
.
-
createIncludesFile
Add a name entry to the include files list.- Returns:
PatternSet.PatternFileNameEntry
.
-
createExclude
Add a name entry to the exclude list.- Returns:
PatternSet.NameEntry
.
-
createExcludesFile
Add a name entry to the excludes files list.- Returns:
PatternSet.PatternFileNameEntry
.
-
setFile
public void setFile(java.io.File file)Creates a single file fileset.- Parameters:
file
- the singleFile
included in thisAbstractFileSet
.
-
setIncludes
public void setIncludes(java.lang.String includes)Appendsincludes
to the current list of include patterns.Patterns may be separated by a comma or a space.
- Parameters:
includes
- theString
containing the include patterns.
-
appendIncludes
public void appendIncludes(java.lang.String[] includes)Appendsincludes
to the current list of include patterns.- Parameters:
includes
- array containing the include patterns.- Since:
- Ant 1.7
-
setExcludes
public void setExcludes(java.lang.String excludes)Appendsexcludes
to the current list of exclude patterns.Patterns may be separated by a comma or a space.
- Parameters:
excludes
- theString
containing the exclude patterns.
-
appendExcludes
public void appendExcludes(java.lang.String[] excludes)Appendsexcludes
to the current list of exclude patterns.- Parameters:
excludes
- array containing the exclude patterns.- Since:
- Ant 1.7
-
setIncludesfile
Sets theFile
containing the includes patterns.- Parameters:
incl
-File
instance.- Throws:
BuildException
- on error
-
setExcludesfile
Sets theFile
containing the excludes patterns.- Parameters:
excl
-File
instance.- Throws:
BuildException
- on error
-
setDefaultexcludes
public void setDefaultexcludes(boolean useDefaultExcludes)Sets whether default exclusions should be used or not.- Parameters:
useDefaultExcludes
-boolean
.
-
getDefaultexcludes
public boolean getDefaultexcludes()Whether default exclusions should be used or not.- Returns:
- the default exclusions value.
- Since:
- Ant 1.6.3
-
setCaseSensitive
public void setCaseSensitive(boolean caseSensitive)Sets case sensitivity of the file system.- Parameters:
caseSensitive
-boolean
.
-
isCaseSensitive
public boolean isCaseSensitive()Find out if the fileset is case sensitive.- Returns:
boolean
indicating whether the fileset is case sensitive.- Since:
- Ant 1.7
-
setFollowSymlinks
public void setFollowSymlinks(boolean followSymlinks)Sets whether or not symbolic links should be followed.- Parameters:
followSymlinks
- whether or not symbolic links should be followed.
-
isFollowSymlinks
public boolean isFollowSymlinks()Find out if the fileset wants to follow symbolic links.- Returns:
boolean
indicating whether symbolic links should be followed.- Since:
- Ant 1.6
-
setMaxLevelsOfSymlinks
public void setMaxLevelsOfSymlinks(int max)The maximum number of times a symbolic link may be followed during a scan.- Parameters:
max
- int- Since:
- Ant 1.8.0
-
getMaxLevelsOfSymlinks
public int getMaxLevelsOfSymlinks()The maximum number of times a symbolic link may be followed during a scan.- Returns:
- int
- Since:
- Ant 1.8.0
-
setErrorOnMissingDir
public void setErrorOnMissingDir(boolean errorOnMissingDir)Sets whether an error is thrown if a directory does not exist.- Parameters:
errorOnMissingDir
- true if missing directories cause errors, false if not.
-
getErrorOnMissingDir
public boolean getErrorOnMissingDir()Gets whether an error is/should be thrown if the base directory does not exist.- Returns:
- boolean
- Since:
- Ant 1.8.2
-
getDirectoryScanner
Returns the directory scanner needed to access the files to process.- Returns:
- a
DirectoryScanner
instance.
-
getDirectoryScanner
Returns the directory scanner needed to access the files to process.- Parameters:
p
- the Project against which the DirectoryScanner should be configured.- Returns:
- a
DirectoryScanner
instance.
-
setupDirectoryScanner
Set up the specified directory scanner against this AbstractFileSet's Project.- Parameters:
ds
- aFileScanner
instance.
-
setupDirectoryScanner
Set up the specified directory scanner against the specified project.- Parameters:
ds
- aFileScanner
instance.p
- an AntProject
instance.
-
getRef
Performs the check for circular references and returns the referenced FileSet. This method can be overridden together withgetRef()
providing implementations containing the special support for FileSet references, which can be handled by all ArchiveFileSets. NB! This method must be overridden in subclasses such as FileSet and DirSet to distinguish between the data types.- Parameters:
p
- the current project- Returns:
- the dereferenced object.
-
hasSelectors
public boolean hasSelectors()Indicates whether there are any selectors here.- Specified by:
hasSelectors
in interfaceSelectorContainer
- Returns:
- whether any selectors are in this container.
-
hasPatterns
public boolean hasPatterns()Indicates whether there are any patterns here.- Returns:
- whether any patterns are in this container.
-
selectorCount
public int selectorCount()Gives the count of the number of selectors in this container.- Specified by:
selectorCount
in interfaceSelectorContainer
- Returns:
- the number of selectors in this container as an
int
.
-
getSelectors
Returns the set of selectors as an array.- Specified by:
getSelectors
in interfaceSelectorContainer
- Parameters:
p
- the current project- Returns:
- a
FileSelector[]
of the selectors in this container.
-
selectorElements
Returns an enumerator for accessing the set of selectors.- Specified by:
selectorElements
in interfaceSelectorContainer
- Returns:
- an
Enumeration
of selectors.
-
appendSelector
Add a new selector into this container.- Specified by:
appendSelector
in interfaceSelectorContainer
- Parameters:
selector
- the newFileSelector
to add.
-
addSelector
Add a "Select" selector entry on the selector list.- Specified by:
addSelector
in interfaceSelectorContainer
- Parameters:
selector
- theSelectSelector
to add.
-
addAnd
Add an "And" selector entry on the selector list.- Specified by:
addAnd
in interfaceSelectorContainer
- Parameters:
selector
- theAndSelector
to add.
-
addOr
Add an "Or" selector entry on the selector list.- Specified by:
addOr
in interfaceSelectorContainer
- Parameters:
selector
- theOrSelector
to add.
-
addNot
Add a "Not" selector entry on the selector list.- Specified by:
addNot
in interfaceSelectorContainer
- Parameters:
selector
- theNotSelector
to add.
-
addNone
Add a "None" selector entry on the selector list.- Specified by:
addNone
in interfaceSelectorContainer
- Parameters:
selector
- theNoneSelector
to add.
-
addMajority
Add a majority selector entry on the selector list.- Specified by:
addMajority
in interfaceSelectorContainer
- Parameters:
selector
- theMajoritySelector
to add.
-
addDate
Add a selector date entry on the selector list.- Specified by:
addDate
in interfaceSelectorContainer
- Parameters:
selector
- theDateSelector
to add.
-
addSize
Add a selector size entry on the selector list.- Specified by:
addSize
in interfaceSelectorContainer
- Parameters:
selector
- theSizeSelector
to add.
-
addDifferent
Add a DifferentSelector entry on the selector list.- Specified by:
addDifferent
in interfaceSelectorContainer
- Parameters:
selector
- theDifferentSelector
to add.
-
addFilename
Add a selector filename entry on the selector list.- Specified by:
addFilename
in interfaceSelectorContainer
- Parameters:
selector
- theFilenameSelector
to add.
-
addType
Add a selector type entry on the selector list.- Specified by:
addType
in interfaceSelectorContainer
- Parameters:
selector
- theTypeSelector
to add.
-
addCustom
Add an extended selector entry on the selector list.- Specified by:
addCustom
in interfaceSelectorContainer
- Parameters:
selector
- theExtendSelector
to add.
-
addContains
Add a contains selector entry on the selector list.- Specified by:
addContains
in interfaceSelectorContainer
- Parameters:
selector
- theContainsSelector
to add.
-
addPresent
Add a present selector entry on the selector list.- Specified by:
addPresent
in interfaceSelectorContainer
- Parameters:
selector
- thePresentSelector
to add.
-
addDepth
Add a depth selector entry on the selector list.- Specified by:
addDepth
in interfaceSelectorContainer
- Parameters:
selector
- theDepthSelector
to add.
-
addDepend
Add a depends selector entry on the selector list.- Specified by:
addDepend
in interfaceSelectorContainer
- Parameters:
selector
- theDependSelector
to add.
-
addContainsRegexp
Add a regular expression selector entry on the selector list.- Specified by:
addContainsRegexp
in interfaceSelectorContainer
- Parameters:
selector
- theContainsRegexpSelector
to add.
-
addModified
Add the modified selector.- Specified by:
addModified
in interfaceSelectorContainer
- Parameters:
selector
- theModifiedSelector
to add.- Since:
- Ant 1.6
-
addReadable
-
addWritable
-
addExecutable
- Parameters:
e
- ExecutableSelector- Since:
- 1.10.0
-
addSymlink
- Parameters:
e
- SymlinkSelector- Since:
- 1.10.0
-
addOwnedBy
- Parameters:
o
- OwnedBySelector- Since:
- 1.10.0
-
addPosixGroup
- Parameters:
o
- PosixGroupSelector- Since:
- 1.10.4
-
addPosixPermissions
- Parameters:
o
- PosixPermissionsSelector- Since:
- 1.10.4
-
add
Add an arbitrary selector.- Specified by:
add
in interfaceSelectorContainer
- Parameters:
selector
- theFileSelector
to add.- Since:
- Ant 1.6
-
toString
public java.lang.String toString()Returns included files as a list of semicolon-separated filenames. -
clone
public java.lang.Object clone()Creates a deep clone of this instance, except for the nested selectors (the list of selectors is a shallow clone of this instance's list). -
mergeIncludes
Get the merged include patterns for this AbstractFileSet.- Parameters:
p
- the project to use.- Returns:
- the include patterns of the default pattern set and all nested patternsets.
- Since:
- Ant 1.7
-
mergeExcludes
Get the merged exclude patterns for this AbstractFileSet.- Parameters:
p
- the project to use.- Returns:
- the exclude patterns of the default pattern set and all nested patternsets.
- Since:
- Ant 1.7
-
mergePatterns
Get the merged patterns for this AbstractFileSet.- Parameters:
p
- the project to use.- Returns:
- the default patternset merged with the additional sets in a new PatternSet instance.
- Since:
- Ant 1.7
-
dieOnCircularReference
protected void dieOnCircularReference(java.util.Stack<java.lang.Object> stk, Project p) throws BuildExceptionDescription copied from class:DataType
Check to see whether any DataType we hold references to is included in the Stack (which holds all DataType instances that directly or indirectly reference this instance, including this instance itself).If one is included, throw a BuildException created by
circularReference
.This implementation is appropriate only for a DataType that cannot hold other DataTypes as children.
The general contract of this method is that it shouldn't do anything if
DataType.checked
is true and set it to true on exit.- Overrides:
dieOnCircularReference
in classDataType
- Parameters:
stk
- the stack of references to check.p
- the project to use to dereference the references.- Throws:
BuildException
- on error.
-