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
-
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
-
-
Constructor Summary
Constructors Modifier Constructor Description AbstractFileSet()Construct a newAbstractFileSet.protectedAbstractFileSet(AbstractFileSet fileset)Construct a newAbstractFileSet, shallowly cloned from the specifiedAbstractFileSet.
-
Method Summary
Modifier and Type Method Description voidadd(FileSelector selector)Add an arbitrary selector.voidaddAnd(AndSelector selector)Add an "And" selector entry on the selector list.voidaddContains(ContainsSelector selector)Add a contains selector entry on the selector list.voidaddContainsRegexp(ContainsRegexpSelector selector)Add a regular expression selector entry on the selector list.voidaddCustom(ExtendSelector selector)Add an extended selector entry on the selector list.voidaddDate(DateSelector selector)Add a selector date entry on the selector list.voidaddDepend(DependSelector selector)Add a depends selector entry on the selector list.voidaddDepth(DepthSelector selector)Add a depth selector entry on the selector list.voidaddDifferent(DifferentSelector selector)Add a DifferentSelector entry on the selector list.voidaddExecutable(ExecutableSelector e)voidaddFilename(FilenameSelector selector)Add a selector filename entry on the selector list.voidaddMajority(MajoritySelector selector)Add a majority selector entry on the selector list.voidaddModified(ModifiedSelector selector)Add the modified selector.voidaddNone(NoneSelector selector)Add a "None" selector entry on the selector list.voidaddNot(NotSelector selector)Add a "Not" selector entry on the selector list.voidaddOr(OrSelector selector)Add an "Or" selector entry on the selector list.voidaddOwnedBy(OwnedBySelector o)voidaddPosixGroup(PosixGroupSelector o)voidaddPosixPermissions(PosixPermissionsSelector o)voidaddPresent(PresentSelector selector)Add a present selector entry on the selector list.voidaddReadable(ReadableSelector r)voidaddSelector(SelectSelector selector)Add a "Select" selector entry on the selector list.voidaddSize(SizeSelector selector)Add a selector size entry on the selector list.voidaddSymlink(SymlinkSelector e)voidaddType(TypeSelector selector)Add a selector type entry on the selector list.voidaddWritable(WritableSelector w)voidappendExcludes(java.lang.String[] excludes)Appendsexcludesto the current list of exclude patterns.voidappendIncludes(java.lang.String[] includes)Appendsincludesto the current list of include patterns.voidappendSelector(FileSelector selector)Add a new selector into this container.java.lang.Objectclone()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.NameEntrycreateExclude()Add a name entry to the exclude list.PatternSet.NameEntrycreateExcludesFile()Add a name entry to the excludes files list.PatternSet.NameEntrycreateInclude()Add a name entry to the include list.PatternSet.NameEntrycreateIncludesFile()Add a name entry to the include files list.PatternSetcreatePatternSet()Creates a nested patternset.protected voiddieOnCircularReference(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).booleangetDefaultexcludes()Whether default exclusions should be used or not.java.io.FilegetDir()Retrieves the base-directory for this instance.java.io.FilegetDir(Project p)Retrieves the base-directory for this instance.DirectoryScannergetDirectoryScanner()Returns the directory scanner needed to access the files to process.DirectoryScannergetDirectoryScanner(Project p)Returns the directory scanner needed to access the files to process.booleangetErrorOnMissingDir()Gets whether an error is/should be thrown if the base directory does not exist.intgetMaxLevelsOfSymlinks()The maximum number of times a symbolic link may be followed during a scan.protected AbstractFileSetgetRef(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.booleanhasPatterns()Indicates whether there are any patterns here.booleanhasSelectors()Indicates whether there are any selectors here.booleanisCaseSensitive()Find out if the fileset is case sensitive.booleanisFollowSymlinks()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.PatternSetmergePatterns(Project p)Get the merged patterns for this AbstractFileSet.intselectorCount()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.voidsetCaseSensitive(boolean caseSensitive)Sets case sensitivity of the file system.voidsetDefaultexcludes(boolean useDefaultExcludes)Sets whether default exclusions should be used or not.voidsetDir(java.io.File dir)Sets the base-directory for this instance.voidsetErrorOnMissingDir(boolean errorOnMissingDir)Sets whether an error is thrown if a directory does not exist.voidsetExcludes(java.lang.String excludes)Appendsexcludesto the current list of exclude patterns.voidsetExcludesfile(java.io.File excl)Sets theFilecontaining the excludes patterns.voidsetFile(java.io.File file)Creates a single file fileset.voidsetFollowSymlinks(boolean followSymlinks)Sets whether or not symbolic links should be followed.voidsetIncludes(java.lang.String includes)Appendsincludesto the current list of include patterns.voidsetIncludesfile(java.io.File incl)Sets theFilecontaining the includes patterns.voidsetMaxLevelsOfSymlinks(int max)The maximum number of times a symbolic link may be followed during a scan.voidsetRefid(Reference r)Makes this instance in effect a reference to another instance.voidsetupDirectoryScanner(FileScanner ds)Set up the specified directory scanner against this AbstractFileSet's Project.voidsetupDirectoryScanner(FileScanner ds, Project p)Set up the specified directory scanner against the specified project.java.lang.StringtoString()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 Detail
-
AbstractFileSet
public AbstractFileSet()
Construct a newAbstractFileSet.
-
AbstractFileSet
protected AbstractFileSet(AbstractFileSet fileset)
Construct a newAbstractFileSet, shallowly cloned from the specifiedAbstractFileSet.- Parameters:
fileset- theAbstractFileSetto use as a template.
-
-
Method Detail
-
setRefid
public void setRefid(Reference r) throws BuildException
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:
setRefidin classDataType- Parameters:
r- theReferenceto use.- Throws:
BuildException- on error
-
setDir
public void setDir(java.io.File dir) throws BuildExceptionSets the base-directory for this instance.- Parameters:
dir- the directory'sFileinstance.- Throws:
BuildException- on error
-
getDir
public java.io.File getDir()
Retrieves the base-directory for this instance.- Returns:
File.
-
getDir
public java.io.File getDir(Project p)
Retrieves the base-directory for this instance.- Parameters:
p- theProjectagainst which the reference is resolved, if set.- Returns:
File.
-
createPatternSet
public PatternSet createPatternSet()
Creates a nested patternset.- Returns:
PatternSet.
-
createInclude
public PatternSet.NameEntry createInclude()
Add a name entry to the include list.- Returns:
PatternSet.NameEntry.
-
createIncludesFile
public PatternSet.NameEntry createIncludesFile()
Add a name entry to the include files list.- Returns:
PatternSet.PatternFileNameEntry.
-
createExclude
public PatternSet.NameEntry createExclude()
Add a name entry to the exclude list.- Returns:
PatternSet.NameEntry.
-
createExcludesFile
public 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 singleFileincluded in thisAbstractFileSet.
-
setIncludes
public void setIncludes(java.lang.String includes)
Appendsincludesto the current list of include patterns.Patterns may be separated by a comma or a space.
- Parameters:
includes- theStringcontaining the include patterns.
-
appendIncludes
public void appendIncludes(java.lang.String[] includes)
Appendsincludesto 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)
Appendsexcludesto the current list of exclude patterns.Patterns may be separated by a comma or a space.
- Parameters:
excludes- theStringcontaining the exclude patterns.
-
appendExcludes
public void appendExcludes(java.lang.String[] excludes)
Appendsexcludesto the current list of exclude patterns.- Parameters:
excludes- array containing the exclude patterns.- Since:
- Ant 1.7
-
setIncludesfile
public void setIncludesfile(java.io.File incl) throws BuildExceptionSets theFilecontaining the includes patterns.- Parameters:
incl-Fileinstance.- Throws:
BuildException- on error
-
setExcludesfile
public void setExcludesfile(java.io.File excl) throws BuildExceptionSets theFilecontaining the excludes patterns.- Parameters:
excl-Fileinstance.- 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:
booleanindicating 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:
booleanindicating 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
public DirectoryScanner getDirectoryScanner()
Returns the directory scanner needed to access the files to process.- Returns:
- a
DirectoryScannerinstance.
-
getDirectoryScanner
public DirectoryScanner getDirectoryScanner(Project p)
Returns the directory scanner needed to access the files to process.- Parameters:
p- the Project against which the DirectoryScanner should be configured.- Returns:
- a
DirectoryScannerinstance.
-
setupDirectoryScanner
public void setupDirectoryScanner(FileScanner ds)
Set up the specified directory scanner against this AbstractFileSet's Project.- Parameters:
ds- aFileScannerinstance.
-
setupDirectoryScanner
public void setupDirectoryScanner(FileScanner ds, Project p)
Set up the specified directory scanner against the specified project.- Parameters:
ds- aFileScannerinstance.p- an AntProjectinstance.
-
getRef
protected AbstractFileSet getRef(Project p)
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:
hasSelectorsin 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:
selectorCountin interfaceSelectorContainer- Returns:
- the number of selectors in this container as an
int.
-
getSelectors
public FileSelector[] getSelectors(Project p)
Returns the set of selectors as an array.- Specified by:
getSelectorsin interfaceSelectorContainer- Parameters:
p- the current project- Returns:
- a
FileSelector[]of the selectors in this container.
-
selectorElements
public java.util.Enumeration<FileSelector> selectorElements()
Returns an enumerator for accessing the set of selectors.- Specified by:
selectorElementsin interfaceSelectorContainer- Returns:
- an
Enumerationof selectors.
-
appendSelector
public void appendSelector(FileSelector selector)
Add a new selector into this container.- Specified by:
appendSelectorin interfaceSelectorContainer- Parameters:
selector- the newFileSelectorto add.
-
addSelector
public void addSelector(SelectSelector selector)
Add a "Select" selector entry on the selector list.- Specified by:
addSelectorin interfaceSelectorContainer- Parameters:
selector- theSelectSelectorto add.
-
addAnd
public void addAnd(AndSelector selector)
Add an "And" selector entry on the selector list.- Specified by:
addAndin interfaceSelectorContainer- Parameters:
selector- theAndSelectorto add.
-
addOr
public void addOr(OrSelector selector)
Add an "Or" selector entry on the selector list.- Specified by:
addOrin interfaceSelectorContainer- Parameters:
selector- theOrSelectorto add.
-
addNot
public void addNot(NotSelector selector)
Add a "Not" selector entry on the selector list.- Specified by:
addNotin interfaceSelectorContainer- Parameters:
selector- theNotSelectorto add.
-
addNone
public void addNone(NoneSelector selector)
Add a "None" selector entry on the selector list.- Specified by:
addNonein interfaceSelectorContainer- Parameters:
selector- theNoneSelectorto add.
-
addMajority
public void addMajority(MajoritySelector selector)
Add a majority selector entry on the selector list.- Specified by:
addMajorityin interfaceSelectorContainer- Parameters:
selector- theMajoritySelectorto add.
-
addDate
public void addDate(DateSelector selector)
Add a selector date entry on the selector list.- Specified by:
addDatein interfaceSelectorContainer- Parameters:
selector- theDateSelectorto add.
-
addSize
public void addSize(SizeSelector selector)
Add a selector size entry on the selector list.- Specified by:
addSizein interfaceSelectorContainer- Parameters:
selector- theSizeSelectorto add.
-
addDifferent
public void addDifferent(DifferentSelector selector)
Add a DifferentSelector entry on the selector list.- Specified by:
addDifferentin interfaceSelectorContainer- Parameters:
selector- theDifferentSelectorto add.
-
addFilename
public void addFilename(FilenameSelector selector)
Add a selector filename entry on the selector list.- Specified by:
addFilenamein interfaceSelectorContainer- Parameters:
selector- theFilenameSelectorto add.
-
addType
public void addType(TypeSelector selector)
Add a selector type entry on the selector list.- Specified by:
addTypein interfaceSelectorContainer- Parameters:
selector- theTypeSelectorto add.
-
addCustom
public void addCustom(ExtendSelector selector)
Add an extended selector entry on the selector list.- Specified by:
addCustomin interfaceSelectorContainer- Parameters:
selector- theExtendSelectorto add.
-
addContains
public void addContains(ContainsSelector selector)
Add a contains selector entry on the selector list.- Specified by:
addContainsin interfaceSelectorContainer- Parameters:
selector- theContainsSelectorto add.
-
addPresent
public void addPresent(PresentSelector selector)
Add a present selector entry on the selector list.- Specified by:
addPresentin interfaceSelectorContainer- Parameters:
selector- thePresentSelectorto add.
-
addDepth
public void addDepth(DepthSelector selector)
Add a depth selector entry on the selector list.- Specified by:
addDepthin interfaceSelectorContainer- Parameters:
selector- theDepthSelectorto add.
-
addDepend
public void addDepend(DependSelector selector)
Add a depends selector entry on the selector list.- Specified by:
addDependin interfaceSelectorContainer- Parameters:
selector- theDependSelectorto add.
-
addContainsRegexp
public void addContainsRegexp(ContainsRegexpSelector selector)
Add a regular expression selector entry on the selector list.- Specified by:
addContainsRegexpin interfaceSelectorContainer- Parameters:
selector- theContainsRegexpSelectorto add.
-
addModified
public void addModified(ModifiedSelector selector)
Add the modified selector.- Specified by:
addModifiedin interfaceSelectorContainer- Parameters:
selector- theModifiedSelectorto add.- Since:
- Ant 1.6
-
addReadable
public void addReadable(ReadableSelector r)
-
addWritable
public void addWritable(WritableSelector w)
-
addExecutable
public void addExecutable(ExecutableSelector e)
- Parameters:
e- ExecutableSelector- Since:
- 1.10.0
-
addSymlink
public void addSymlink(SymlinkSelector e)
- Parameters:
e- SymlinkSelector- Since:
- 1.10.0
-
addOwnedBy
public void addOwnedBy(OwnedBySelector o)
- Parameters:
o- OwnedBySelector- Since:
- 1.10.0
-
addPosixGroup
public void addPosixGroup(PosixGroupSelector o)
- Parameters:
o- PosixGroupSelector- Since:
- 1.10.4
-
addPosixPermissions
public void addPosixPermissions(PosixPermissionsSelector o)
- Parameters:
o- PosixPermissionsSelector- Since:
- 1.10.4
-
add
public void add(FileSelector selector)
Add an arbitrary selector.- Specified by:
addin interfaceSelectorContainer- Parameters:
selector- theFileSelectorto 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
public java.lang.String[] mergeIncludes(Project p)
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
public java.lang.String[] mergeExcludes(Project p)
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
public PatternSet mergePatterns(Project p)
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:DataTypeCheck 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.checkedis true and set it to true on exit.- Overrides:
dieOnCircularReferencein classDataType- Parameters:
stk- the stack of references to check.p- the project to use to dereference the references.- Throws:
BuildException- on error.
-
-