From ce6c8d711c59101ecf7c4bbef534d5d66daec1f7 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Tue, 1 Jan 2002 09:13:47 +0000 Subject: [PATCH] Started to migrate FileSet away from using Project and for implementing references itself (rather than letting container manage references) git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270499 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/antlib/xml/XMLValidateTask.java | 4 +- .../apache/tools/ant/taskdefs/Checksum.java | 4 +- .../apache/tools/ant/taskdefs/DependSet.java | 8 +- .../apache/tools/ant/taskdefs/ExecuteOn.java | 4 +- .../org/apache/tools/ant/taskdefs/Expand.java | 4 +- .../tools/ant/taskdefs/MatchingTask.java | 2 +- .../apache/tools/ant/taskdefs/SQLExec.java | 4 +- .../org/apache/tools/ant/taskdefs/Tar.java | 18 +- .../apache/tools/ant/taskdefs/UpToDate.java | 4 +- .../org/apache/tools/ant/taskdefs/Zip.java | 4 +- .../apache/tools/ant/taskdefs/file/Copy.java | 6 +- .../tools/ant/taskdefs/file/Delete.java | 14 +- .../apache/tools/ant/taskdefs/file/Move.java | 2 +- .../apache/tools/ant/taskdefs/file/Touch.java | 4 +- .../tools/ant/taskdefs/javadoc/Javadoc.java | 2 +- .../tools/ant/taskdefs/optional/Cab.java | 2 +- .../optional/ejb/GenericDeploymentTool.java | 4 +- .../ant/taskdefs/optional/i18n/Translate.java | 2 +- .../ant/taskdefs/optional/ide/VAJImport.java | 2 +- .../taskdefs/optional/junit/BatchTest.java | 2 +- .../optional/junit/XMLResultAggregator.java | 2 +- .../metamata/AbstractMetamataTask.java | 2 +- .../tools/ant/taskdefs/optional/net/FTP.java | 4 +- .../ant/taskdefs/optional/net/MimeMail.java | 2 +- .../ant/taskdefs/optional/perforce/P4Add.java | 2 +- .../taskdefs/optional/sitraka/CovMerge.java | 2 +- .../tools/ant/taskdefs/security/SignJar.java | 4 +- .../ant/taskdefs/text/ReplaceRegExp.java | 2 +- .../apache/tools/ant/taskdefs/unix/Chmod.java | 6 +- .../org/apache/tools/ant/types/FileSet.java | 281 ++++-------------- .../main/org/apache/tools/ant/types/Path.java | 4 +- .../apache/tools/ant/types/PatternSet.java | 202 +++---------- .../apache/tools/ant/types/ZipFileSet.java | 16 +- .../types/optional/depend/ClassfileSet.java | 2 +- .../apache/tools/ant/taskdefs/Checksum.java | 4 +- .../apache/tools/ant/taskdefs/DependSet.java | 8 +- .../apache/tools/ant/taskdefs/ExecuteOn.java | 4 +- .../org/apache/tools/ant/taskdefs/Expand.java | 4 +- .../tools/ant/taskdefs/MatchingTask.java | 2 +- .../apache/tools/ant/taskdefs/SQLExec.java | 4 +- .../org/apache/tools/ant/taskdefs/Tar.java | 18 +- .../apache/tools/ant/taskdefs/UpToDate.java | 4 +- .../org/apache/tools/ant/taskdefs/Zip.java | 4 +- .../apache/tools/ant/taskdefs/file/Copy.java | 6 +- .../tools/ant/taskdefs/file/Delete.java | 14 +- .../apache/tools/ant/taskdefs/file/Move.java | 2 +- .../apache/tools/ant/taskdefs/file/Touch.java | 4 +- .../tools/ant/taskdefs/javadoc/Javadoc.java | 2 +- .../tools/ant/taskdefs/optional/Cab.java | 2 +- .../optional/ejb/GenericDeploymentTool.java | 4 +- .../ant/taskdefs/optional/i18n/Translate.java | 2 +- .../ant/taskdefs/optional/ide/VAJImport.java | 2 +- .../taskdefs/optional/junit/BatchTest.java | 2 +- .../optional/junit/XMLResultAggregator.java | 2 +- .../metamata/AbstractMetamataTask.java | 2 +- .../tools/ant/taskdefs/optional/net/FTP.java | 4 +- .../ant/taskdefs/optional/net/MimeMail.java | 2 +- .../ant/taskdefs/optional/perforce/P4Add.java | 2 +- .../taskdefs/optional/sitraka/CovMerge.java | 2 +- .../tools/ant/taskdefs/security/SignJar.java | 4 +- .../ant/taskdefs/text/ReplaceRegExp.java | 2 +- .../apache/tools/ant/taskdefs/unix/Chmod.java | 6 +- .../org/apache/tools/ant/types/FileSet.java | 281 ++++-------------- .../todo/org/apache/tools/ant/types/Path.java | 4 +- .../apache/tools/ant/types/PatternSet.java | 202 +++---------- .../apache/tools/ant/types/ZipFileSet.java | 16 +- .../types/optional/depend/ClassfileSet.java | 2 +- 67 files changed, 308 insertions(+), 942 deletions(-) diff --git a/proposal/myrmidon/src/java/org/apache/antlib/xml/XMLValidateTask.java b/proposal/myrmidon/src/java/org/apache/antlib/xml/XMLValidateTask.java index eb3a8ee45..0e4fa4d72 100644 --- a/proposal/myrmidon/src/java/org/apache/antlib/xml/XMLValidateTask.java +++ b/proposal/myrmidon/src/java/org/apache/antlib/xml/XMLValidateTask.java @@ -259,12 +259,12 @@ public class XMLValidateTask { FileSet fs = (FileSet)filesets.get( i ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); String[] files = ds.getIncludedFiles(); for( int j = 0; j < files.length; j++ ) { - File srcFile = new File( fs.getDir( getProject() ), files[ j ] ); + File srcFile = new File( fs.getDir(), files[ j ] ); doValidate( srcFile ); fileProcessed++; } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Checksum.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Checksum.java index 412ee5b72..6cc05610f 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Checksum.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Checksum.java @@ -473,11 +473,11 @@ public class Checksum extends MatchingTask implements Condition for( int i = 0; i < sizeofFileSet; i++ ) { FileSet fs = (FileSet)filesets.get( i ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); String[] srcFiles = ds.getIncludedFiles(); for( int j = 0; j < srcFiles.length; j++ ) { - File src = new File( fs.getDir( getProject() ), srcFiles[ j ] ); + File src = new File( fs.getDir(), srcFiles[ j ] ); addToIncludeFileMap( src ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/DependSet.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/DependSet.java index d0c522617..88fabac1a 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/DependSet.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/DependSet.java @@ -154,13 +154,13 @@ public class DependSet extends MatchingTask { FileSet targetFS = (FileSet)enumTargetSets.next(); - DirectoryScanner targetDS = targetFS.getDirectoryScanner( getProject() ); + DirectoryScanner targetDS = targetFS.getDirectoryScanner(); String[] targetFiles = targetDS.getIncludedFiles(); for( int i = 0; i < targetFiles.length; i++ ) { - File dest = new File( targetFS.getDir( getProject() ), targetFiles[ i ] ); + File dest = new File( targetFS.getDir(), targetFiles[ i ] ); allTargets.add( dest ); if( dest.lastModified() > now ) @@ -212,12 +212,12 @@ public class DependSet extends MatchingTask { FileSet sourceFS = (FileSet)enumSourceSets.next(); - DirectoryScanner sourceDS = sourceFS.getDirectoryScanner( getProject() ); + DirectoryScanner sourceDS = sourceFS.getDirectoryScanner(); String[] sourceFiles = sourceDS.getIncludedFiles(); for( int i = 0; upToDate && i < sourceFiles.length; i++ ) { - File src = new File( sourceFS.getDir( getProject() ), sourceFiles[ i ] ); + File src = new File( sourceFS.getDir(), sourceFiles[ i ] ); if( src.lastModified() > now ) { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java index 88fd3bcfa..9c2b41da9 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java @@ -385,8 +385,8 @@ public class ExecuteOn extends ExecTask for( int i = 0; i < filesets.size(); i++ ) { FileSet fs = (FileSet)filesets.get( i ); - File base = fs.getDir( getProject() ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + File base = fs.getDir(); + DirectoryScanner ds = fs.getDirectoryScanner(); if( !"dir".equals( type ) ) { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Expand.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Expand.java index 3d4146e0d..764ab1a69 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Expand.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Expand.java @@ -131,8 +131,8 @@ public class Expand extends MatchingTask for( int j = 0; j < filesets.size(); j++ ) { FileSet fs = (FileSet)filesets.get( j ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); - File fromDir = fs.getDir( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); + File fromDir = fs.getDir(); String[] files = ds.getIncludedFiles(); for( int i = 0; i < files.length; ++i ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java index a07f05c24..dec58827d 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java @@ -157,7 +157,7 @@ public abstract class MatchingTask extends Task { fileset.setDir( baseDir ); fileset.setDefaultexcludes( useDefaultExcludes ); - return fileset.getDirectoryScanner( getProject() ); + return fileset.getDirectoryScanner(); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SQLExec.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SQLExec.java index 10091a85a..185047090 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SQLExec.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SQLExec.java @@ -407,8 +407,8 @@ public class SQLExec for( int i = 0; i < filesets.size(); i++ ) { FileSet fs = (FileSet)filesets.get( i ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); - File srcDir = fs.getDir( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); + File srcDir = fs.getDir(); String[] srcFiles = ds.getIncludedFiles(); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tar.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tar.java index 40fd19756..969f0e93c 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tar.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tar.java @@ -129,7 +129,7 @@ public class Tar } // add the main fileset to the list of filesets to process. - TarFileSet mainFileSet = new TarFileSet( fileset ); + TarFileSet mainFileSet = new TarFileSet( /*fileset*/ ); mainFileSet.setDir( baseDir ); filesets.add( mainFileSet ); } @@ -154,7 +154,7 @@ public class Tar for( int i = 0; i < files.length; ++i ) { - if( tarFile.equals( new File( fs.getDir( getProject() ), files[ i ] ) ) ) + if( tarFile.equals( new File( fs.getDir(), files[ i ] ) ) ) { throw new TaskException( "A tar file cannot include itself" ); } @@ -196,7 +196,7 @@ public class Tar String[] files = fs.getFiles( getProject() ); for( int i = 0; i < files.length; i++ ) { - File f = new File( fs.getDir( getProject() ), files[ i ] ); + File f = new File( fs.getDir(), files[ i ] ); String name = files[ i ].replace( File.separatorChar, '/' ); tarFile( f, tOut, name, fs ); } @@ -322,16 +322,6 @@ public class Tar private String userName = ""; private String groupName = ""; - public TarFileSet( FileSet fileset ) - { - super( fileset ); - } - - public TarFileSet() - { - super(); - } - public void setGroup( String groupName ) { this.groupName = groupName; @@ -359,7 +349,7 @@ public class Tar { if( files == null ) { - DirectoryScanner ds = getDirectoryScanner( p ); + DirectoryScanner ds = getDirectoryScanner(); String[] directories = ds.getIncludedDirectories(); String[] filesPerSe = ds.getIncludedFiles(); files = new String[ directories.length + filesPerSe.length ]; diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/UpToDate.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/UpToDate.java index cb5aee12d..7f62043db 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/UpToDate.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/UpToDate.java @@ -127,8 +127,8 @@ public class UpToDate extends MatchingTask implements Condition while( upToDate && enum.hasNext() ) { FileSet fs = (FileSet)enum.next(); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); - upToDate = upToDate && scanDir( fs.getDir( getProject() ), + DirectoryScanner ds = fs.getDirectoryScanner(); + upToDate = upToDate && scanDir( fs.getDir(), ds.getIncludedFiles() ); } return upToDate; diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Zip.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Zip.java index ed712a3dd..7e2604748 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Zip.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Zip.java @@ -264,7 +264,7 @@ public class Zip extends MatchingTask for( int i = 0; i < filesets.size(); i++ ) { FileSet fs = (FileSet)filesets.get( i ); - dss.add( fs.getDirectoryScanner( getProject() ) ); + dss.add( fs.getDirectoryScanner() ); } int dssSize = dss.size(); FileScanner[] scanners = new FileScanner[ dssSize ]; @@ -541,7 +541,7 @@ public class Zip extends MatchingTask for( int i = 0; i < filesets.size(); i++ ) { FileSet fs = (FileSet)filesets.get( i ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); String prefix = ""; String fullpath = ""; diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Copy.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Copy.java index 9eb399d8b..59974f2e5 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Copy.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Copy.java @@ -229,8 +229,8 @@ public class Copy for( int i = 0; i < m_filesets.size(); i++ ) { final FileSet fileSet = (FileSet)m_filesets.get( i ); - final DirectoryScanner scanner = fileSet.getDirectoryScanner( getProject() ); - final File fromDir = fileSet.getDir( getProject() ); + final DirectoryScanner scanner = fileSet.getDirectoryScanner(); + final File fromDir = fileSet.getDir(); final String[] srcFiles = scanner.getIncludedFiles(); final String[] srcDirs = scanner.getIncludedDirectories(); @@ -486,7 +486,7 @@ public class Copy else { FileSet fs = (FileSet)m_filesets.get( 0 ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); String[] srcFiles = ds.getIncludedFiles(); if( srcFiles.length > 0 ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Delete.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Delete.java index 8b10b330f..3b3873100 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Delete.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Delete.java @@ -44,7 +44,7 @@ public class Delete * * @param dir the directory path. */ - public void setDir( File dir ) + public void setDir( final File dir ) { m_dir = dir; } @@ -54,7 +54,7 @@ public class Delete * * @param file the file to be deleted */ - public void setFile( File file ) + public void setFile( final File file ) { m_file = file; } @@ -100,14 +100,16 @@ public class Delete getLogger().info( "Deleting: " + m_file.getAbsolutePath() ); if( !m_file.delete() ) { - String message = "Unable to delete file " + m_file.getAbsolutePath(); + final String message = "Unable to delete file " + m_file.getAbsolutePath(); throw new TaskException( message ); } } } else { - getLogger().debug( "Could not find file " + m_file.getAbsolutePath() + " to delete." ); + final String message = + "Could not find file " + m_file.getAbsolutePath() + " to delete."; + getLogger().debug( message ); } } @@ -124,10 +126,10 @@ public class Delete FileSet fs = (FileSet)filesets.get( i ); try { - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); String[] files = ds.getIncludedFiles(); String[] dirs = ds.getIncludedDirectories(); - removeFiles( fs.getDir( getProject() ), files, dirs ); + removeFiles( fs.getDir(), files, dirs ); } catch( TaskException be ) { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Move.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Move.java index 242a245e8..fa41dbb9a 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Move.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Move.java @@ -205,7 +205,7 @@ public class Move while( e.hasNext() ) { FileSet fs = (FileSet)e.next(); - File dir = fs.getDir( getProject() ); + File dir = fs.getDir(); if( okToDelete( dir ) ) { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Touch.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Touch.java index 3e7ea0314..c89c24a93 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Touch.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Touch.java @@ -157,8 +157,8 @@ public class Touch for( int i = 0; i < size; i++ ) { final FileSet fs = (FileSet)m_filesets.get( i ); - final DirectoryScanner ds = fs.getDirectoryScanner( null ); - final File fromDir = fs.getDir( null ); + final DirectoryScanner ds = fs.getDirectoryScanner(); + final File fromDir = fs.getDir(); final String[] srcFiles = ds.getIncludedFiles(); final String[] srcDirs = ds.getIncludedDirectories(); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java index 109a86640..5f6b7a730 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java @@ -1022,7 +1022,7 @@ public class Javadoc final File source = resolveFile( list[ j ] ); fs.setDir( source ); - final DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + final DirectoryScanner ds = fs.getDirectoryScanner(); final String[] packageDirs = ds.getIncludedDirectories(); for( int i = 0; i < packageDirs.length; i++ ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java index 55c7fdf94..d3c0854ed 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java @@ -204,7 +204,7 @@ public class Cab extends MatchingTask FileSet fs = (FileSet)filesets.get( i ); if( fs != null ) { - appendFiles( files, fs.getDirectoryScanner( getProject() ) ); + appendFiles( files, fs.getDirectoryScanner() ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java index 271014251..641c765d9 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java @@ -559,8 +559,8 @@ public class GenericDeploymentTool for( Iterator i = config.supportFileSets.iterator(); i.hasNext(); ) { FileSet supportFileSet = (FileSet)i.next(); - File supportBaseDir = supportFileSet.getDir( project ); - DirectoryScanner supportScanner = supportFileSet.getDirectoryScanner( project ); + File supportBaseDir = supportFileSet.getDir(); + DirectoryScanner supportScanner = supportFileSet.getDirectoryScanner(); supportScanner.scan(); String[] supportFiles = supportScanner.getIncludedFiles(); for( int j = 0; j < supportFiles.length; ++j ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java index 9af0dc104..e484ce1a4 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java @@ -518,7 +518,7 @@ public class Translate for( int i = 0; i < filesets.size(); i++ ) { FileSet fs = (FileSet)filesets.get( i ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); String[] srcFiles = ds.getIncludedFiles(); for( int j = 0; j < srcFiles.length; j++ ) { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java index 8a86d00f8..f2136e32a 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java @@ -224,7 +224,7 @@ public class VAJImport extends VAJTask */ protected void importFileset( FileSet fileset ) { - DirectoryScanner ds = fileset.getDirectoryScanner( this.getProject() ); + DirectoryScanner ds = fileset.getDirectoryScanner(); if( ds.getIncludedFiles().length == 0 ) { return; diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java index e5459953f..dfe4d075e 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java @@ -127,7 +127,7 @@ public final class BatchTest extends BaseTest for( int j = 0; j < size; j++ ) { FileSet fs = (FileSet)filesets.get( j ); - DirectoryScanner ds = fs.getDirectoryScanner( project ); + DirectoryScanner ds = fs.getDirectoryScanner(); ds.scan(); String[] f = ds.getIncludedFiles(); for( int k = 0; k < f.length; k++ ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java index 39bd0657e..912d4d89c 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java @@ -200,7 +200,7 @@ public class XMLResultAggregator extends Task implements XMLConstants for( int i = 0; i < size; i++ ) { FileSet fs = (FileSet)filesets.get( i ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); ds.scan(); String[] f = ds.getIncludedFiles(); for( int j = 0; j < f.length; j++ ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java index 34b30101c..f7e19df11 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java @@ -365,7 +365,7 @@ public abstract class AbstractMetamataTask extends Task for( int i = 0; i < fileSets.size(); i++ ) { FileSet fs = (FileSet)fileSets.get( i ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); ds.scan(); String[] f = ds.getIncludedFiles(); getLogger().debug( i + ") Adding " + f.length + " files from directory " + ds.getBasedir() ); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java index a9c740dd5..af41dcd7a 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java @@ -792,12 +792,12 @@ public class FTP if( action == SEND_FILES ) { - ds = fs.getDirectoryScanner( getProject() ); + ds = fs.getDirectoryScanner(); } else { ds = new FTPDirectoryScanner( ftp ); - fs.setupDirectoryScanner( ds, getProject() ); + fs.setupDirectoryScanner( ds ); ds.scan(); } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java index 333c8cf7c..d98fe62c9 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java @@ -307,7 +307,7 @@ public class MimeMail extends Task FileSet fs = (FileSet)filesets.get( i ); if( fs != null ) { - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); String[] dsfiles = ds.getIncludedFiles(); File baseDir = ds.getBasedir(); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Add.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Add.java index 10e2dbbd2..5a6558631 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Add.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Add.java @@ -123,7 +123,7 @@ public class P4Add extends P4Base for( int i = 0; i < filesets.size(); i++ ) { FileSet fs = (FileSet)filesets.get( i ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); //File fromDir = fs.getDir(project); String[] srcFiles = ds.getIncludedFiles(); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java index 5ee156716..823c7f88f 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java @@ -152,7 +152,7 @@ public class CovMerge extends Task for( int i = 0; i < size; i++ ) { FileSet fs = (FileSet)filesets.get( i ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); ds.scan(); String[] f = ds.getIncludedFiles(); for( int j = 0; j < f.length; j++ ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/security/SignJar.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/security/SignJar.java index 1b85b8847..567d85f3b 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/security/SignJar.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/security/SignJar.java @@ -151,12 +151,12 @@ public class SignJar for( int i = 0; i < m_filesets.size(); i++ ) { final FileSet fileSet = (FileSet)m_filesets.get( i ); - final DirectoryScanner scanner = fileSet.getDirectoryScanner( null ); + final DirectoryScanner scanner = fileSet.getDirectoryScanner(); final String[] jarFiles = scanner.getIncludedFiles(); for( int j = 0; j < jarFiles.length; j++ ) { final File file = - new File( fileSet.getDir( null ), jarFiles[ j ] ); + new File( fileSet.getDir(), jarFiles[ j ] ); doOneJar( file, null ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/text/ReplaceRegExp.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/text/ReplaceRegExp.java index 6364379ae..0455b5462 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/text/ReplaceRegExp.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/text/ReplaceRegExp.java @@ -205,7 +205,7 @@ public class ReplaceRegExp extends Task for( int i = 0; i < sz; i++ ) { FileSet fs = (FileSet)( filesets.get( i ) ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); String files[] = ds.getIncludedFiles(); for( int j = 0; j < files.length; j++ ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/unix/Chmod.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/unix/Chmod.java index 56e6ff5ae..f442d2744 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/unix/Chmod.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/unix/Chmod.java @@ -152,14 +152,14 @@ public class Chmod extends ExecuteOn public void execute() throws TaskException { - if( defaultSetDefined || defaultSet.getDir( getProject() ) == null ) + if( defaultSetDefined || defaultSet.getDir() == null ) { super.execute(); } else if( isValidOs() ) { // we are chmodding the given directory - createArg().setValue( defaultSet.getDir( getProject() ).getPath() ); + createArg().setValue( defaultSet.getDir().getPath() ); Execute execute = prepareExec(); try { @@ -191,7 +191,7 @@ public class Chmod extends ExecuteOn throw new TaskException( "Required attribute perm not set in chmod" ); } - if( defaultSetDefined && defaultSet.getDir( getProject() ) != null ) + if( defaultSetDefined && defaultSet.getDir() != null ) { addFileset( defaultSet ); } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java index 6bc143424..f73ed3da4 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java @@ -9,11 +9,9 @@ package org.apache.tools.ant.types; import java.io.File; import java.util.ArrayList; -import java.util.Stack; import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.FileScanner; -import org.apache.tools.ant.Project; /** * Moved out of MatchingTask to make it a standalone object that could be @@ -31,64 +29,36 @@ public class FileSet extends DataType implements Cloneable { - private PatternSet defaultPatterns = new PatternSet(); - private ArrayList additionalPatterns = new ArrayList(); - private boolean useDefaultExcludes = true; - private boolean isCaseSensitive = true; - - private File dir; + private PatternSet m_defaultPatterns = new PatternSet(); + private ArrayList m_additionalPatterns = new ArrayList(); + private boolean m_useDefaultExcludes = true; + private boolean m_isCaseSensitive = true; + private File m_dir; public FileSet() { - super(); - } - - protected FileSet( FileSet fileset ) - { - this.dir = fileset.dir; - this.defaultPatterns = fileset.defaultPatterns; - this.additionalPatterns = fileset.additionalPatterns; - this.useDefaultExcludes = fileset.useDefaultExcludes; - this.isCaseSensitive = fileset.isCaseSensitive; } /** * Sets case sensitivity of the file system - * - * @param isCaseSensitive "true"|"on"|"yes" if file system is case - * sensitive, "false"|"off"|"no" when not. */ - public void setCaseSensitive( boolean isCaseSensitive ) + public void setCaseSensitive( final boolean isCaseSensitive ) { - this.isCaseSensitive = isCaseSensitive; + m_isCaseSensitive = isCaseSensitive; } /** * Sets whether default exclusions should be used or not. - * - * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions - * should be used, "false"|"off"|"no" when they shouldn't be used. */ - public void setDefaultexcludes( boolean useDefaultExcludes ) - throws TaskException + public void setDefaultexcludes( final boolean useDefaultExcludes ) { - if( isReference() ) - { - throw tooManyAttributes(); - } - - this.useDefaultExcludes = useDefaultExcludes; + m_useDefaultExcludes = useDefaultExcludes; } - public void setDir( File dir ) + public void setDir( final File dir ) throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } - - this.dir = dir; + m_dir = dir; } /** @@ -97,32 +67,19 @@ public class FileSet * * @param excludes the string containing the exclude patterns */ - public void setExcludes( String excludes ) - throws TaskException + public void setExcludes( final String excludes ) { - if( isReference() ) - { - throw tooManyAttributes(); - } - - defaultPatterns.setExcludes( excludes ); + m_defaultPatterns.setExcludes( excludes ); } /** * Sets the name of the file containing the includes patterns. * * @param excl The file to fetch the exclude patterns from. - * @exception TaskException Description of Exception */ - public void setExcludesfile( File excl ) - throws TaskException + public void setExcludesfile( final File excl ) { - if( isReference() ) - { - throw tooManyAttributes(); - } - - defaultPatterns.setExcludesfile( excl ); + m_defaultPatterns.setExcludesfile( excl ); } /** @@ -132,250 +89,118 @@ public class FileSet * @param includes the string containing the include patterns */ public void setIncludes( String includes ) - throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } - - defaultPatterns.setIncludes( includes ); + m_defaultPatterns.setIncludes( includes ); } /** * Sets the name of the file containing the includes patterns. * * @param incl The file to fetch the include patterns from. - * @exception TaskException Description of Exception */ public void setIncludesfile( File incl ) - throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } - - defaultPatterns.setIncludesfile( incl ); + m_defaultPatterns.setIncludesfile( incl ); } - /** - * Makes this instance in effect a reference to another PatternSet instance. - *

- * - * You must not set another attribute or nest elements inside this element - * if you make it a reference.

- * - * @param r The new Refid value - * @exception TaskException Description of Exception - */ - public void setRefid( Reference r ) + public void setupDirectoryScanner( final FileScanner ds ) throws TaskException { - if( dir != null || defaultPatterns.hasPatterns() ) + if( null == ds ) { - throw tooManyAttributes(); + final String message = "ds cannot be null"; + throw new IllegalArgumentException( message ); } - if( !additionalPatterns.isEmpty() ) - { - throw noChildrenAllowed(); - } - super.setRefid( r ); - } - public void setupDirectoryScanner( FileScanner ds, Project p ) - throws TaskException - { - if( ds == null ) - { - throw new IllegalArgumentException( "ds cannot be null" ); - } - - ds.setBasedir( dir ); + ds.setBasedir( m_dir ); - for( int i = 0; i < additionalPatterns.size(); i++ ) + final int size = m_additionalPatterns.size(); + for( int i = 0; i < size; i++ ) { - Object o = additionalPatterns.get( i ); - defaultPatterns.append( (PatternSet)o, p ); + final Object o = m_additionalPatterns.get( i ); + m_defaultPatterns.append( (PatternSet)o ); } - getLogger().debug( "FileSet: Setup file scanner in dir " + dir + " with " + defaultPatterns ); + final String message = "FileSet: Setup file scanner in dir " + + m_dir + " with " + m_defaultPatterns; + getLogger().debug( message ); - ds.setIncludes( defaultPatterns.getIncludePatterns( p ) ); - ds.setExcludes( defaultPatterns.getExcludePatterns( p ) ); - if( useDefaultExcludes ) + ds.setIncludes( m_defaultPatterns.getIncludePatterns( null ) ); + ds.setExcludes( m_defaultPatterns.getExcludePatterns( null ) ); + if( m_useDefaultExcludes ) + { ds.addDefaultExcludes(); - ds.setCaseSensitive( isCaseSensitive ); + } + ds.setCaseSensitive( m_isCaseSensitive ); } - public File getDir( Project p ) - throws TaskException + public File getDir() { - if( isReference() ) - { - return getRef( p ).getDir( p ); - } - return dir; + return m_dir; } /** * Returns the directory scanner needed to access the files to process. - * - * @param p Description of Parameter - * @return The DirectoryScanner value */ - public DirectoryScanner getDirectoryScanner( Project p ) + public DirectoryScanner getDirectoryScanner() throws TaskException { - if( isReference() ) - { - return getRef( p ).getDirectoryScanner( p ); - } - - if( dir == null ) + if( m_dir == null ) { throw new TaskException( "No directory specified for fileset." ); } - if( !dir.exists() ) + if( !m_dir.exists() ) { - throw new TaskException( dir.getAbsolutePath() + " not found." ); + throw new TaskException( m_dir.getAbsolutePath() + " not found." ); } - if( !dir.isDirectory() ) + if( !m_dir.isDirectory() ) { - throw new TaskException( dir.getAbsolutePath() + " is not a directory." ); + throw new TaskException( m_dir.getAbsolutePath() + " is not a directory." ); } - DirectoryScanner ds = new DirectoryScanner(); - setupDirectoryScanner( ds, p ); - ds.scan(); - return ds; - } - - /** - * Return a FileSet that has the same basedir and same patternsets as this - * one. - * - * @return Description of the Returned Value - */ - public Object clone() - { - try - { - if( isReference() ) - { - return new FileSet( getRef( getProject() ) ); - } - else - { - return new FileSet( this ); - } - } - catch( TaskException e ) - { - throw new IllegalStateException( e.getMessage() ); - } + final DirectoryScanner scanner = new DirectoryScanner(); + setupDirectoryScanner( scanner ); + scanner.scan(); + return scanner; } /** * add a name entry on the exclude list - * - * @return Description of the Returned Value */ public PatternSet.NameEntry createExclude() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - return defaultPatterns.createExclude(); + return m_defaultPatterns.createExclude(); } /** * add a name entry on the include files list - * - * @return Description of the Returned Value */ public PatternSet.NameEntry createExcludesFile() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - return defaultPatterns.createExcludesFile(); + return m_defaultPatterns.createExcludesFile(); } /** * add a name entry on the include list - * - * @return Description of the Returned Value */ public PatternSet.NameEntry createInclude() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - return defaultPatterns.createInclude(); + return m_defaultPatterns.createInclude(); } /** * add a name entry on the include files list - * - * @return Description of the Returned Value */ public PatternSet.NameEntry createIncludesFile() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - return defaultPatterns.createIncludesFile(); + return m_defaultPatterns.createIncludesFile(); } public PatternSet createPatternSet() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - PatternSet patterns = new PatternSet(); - additionalPatterns.add( patterns ); + final PatternSet patterns = new PatternSet(); + m_additionalPatterns.add( patterns ); return patterns; } - - /** - * Performs the check for circular references and returns the referenced - * FileSet. - * - * @param p Description of Parameter - * @return The Ref value - */ - protected FileSet getRef( Project p ) - throws TaskException - { - if( !checked ) - { - Stack stk = new Stack(); - stk.push( this ); - dieOnCircularReference( stk, p ); - } - - Object o = ref.getReferencedObject( p ); - if( !( o instanceof FileSet ) ) - { - String msg = ref.getRefId() + " doesn\'t denote a fileset"; - throw new TaskException( msg ); - } - else - { - return (FileSet)o; - } - } - } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java index fac5ca02d..c457fe659 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java @@ -588,9 +588,9 @@ public class Path else if( o instanceof FileSet ) { FileSet fs = (FileSet)o; - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); String[] s = ds.getIncludedFiles(); - File dir = fs.getDir( getProject() ); + File dir = fs.getDir(); for( int j = 0; j < s.length; j++ ) { File f = new File( dir, s[ j ] ); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/PatternSet.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/PatternSet.java index f7224e86c..14a349eee 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/PatternSet.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/PatternSet.java @@ -13,7 +13,6 @@ import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; -import java.util.Stack; import java.util.StringTokenizer; import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.Project; @@ -31,12 +30,13 @@ import org.apache.tools.ant.Project; * @author Jon S. Stevens jon@clearink.com * @author Stefan Bodewig */ -public class PatternSet extends DataType +public class PatternSet + extends DataType { - private ArrayList includeList = new ArrayList(); - private ArrayList excludeList = new ArrayList(); - private ArrayList includesFileList = new ArrayList(); - private ArrayList excludesFileList = new ArrayList(); + private ArrayList m_includeList = new ArrayList(); + private ArrayList m_excludeList = new ArrayList(); + private ArrayList m_includesFileList = new ArrayList(); + private ArrayList m_excludesFileList = new ArrayList(); public PatternSet() { @@ -50,12 +50,7 @@ public class PatternSet extends DataType * @param excludes the string containing the exclude patterns */ public void setExcludes( String excludes ) - throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } if( excludes != null && excludes.length() > 0 ) { StringTokenizer tok = new StringTokenizer( excludes, ", ", false ); @@ -73,12 +68,7 @@ public class PatternSet extends DataType * @exception TaskException Description of Exception */ public void setExcludesfile( File excludesFile ) - throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } createExcludesFile().setName( excludesFile.getAbsolutePath() ); } @@ -89,12 +79,7 @@ public class PatternSet extends DataType * @param includes the string containing the include patterns */ public void setIncludes( String includes ) - throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } if( includes != null && includes.length() > 0 ) { StringTokenizer tok = new StringTokenizer( includes, ", ", false ); @@ -112,53 +97,18 @@ public class PatternSet extends DataType * @exception TaskException Description of Exception */ public void setIncludesfile( File includesFile ) - throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } createIncludesFile().setName( includesFile.getAbsolutePath() ); } - /** - * Makes this instance in effect a reference to another PatternSet instance. - *

- * - * You must not set another attribute or nest elements inside this element - * if you make it a reference.

- * - * @param r The new Refid value - * @exception TaskException Description of Exception - */ - public void setRefid( Reference r ) - throws TaskException - { - if( !includeList.isEmpty() || !excludeList.isEmpty() ) - { - throw tooManyAttributes(); - } - super.setRefid( r ); - } - /** * Returns the filtered include patterns. - * - * @param p Description of Parameter - * @return The ExcludePatterns value */ public String[] getExcludePatterns( Project p ) throws TaskException { - if( isReference() ) - { - return getRef( p ).getExcludePatterns( p ); - } - else - { - readFiles( p ); - return makeArray( excludeList, p ); - } + readFiles( p ); + return makeArray( m_excludeList ); } /** @@ -170,32 +120,17 @@ public class PatternSet extends DataType public String[] getIncludePatterns( Project p ) throws TaskException { - if( isReference() ) - { - return getRef( p ).getIncludePatterns( p ); - } - else - { - readFiles( p ); - return makeArray( includeList, p ); - } + readFiles( p ); + return makeArray( m_includeList ); } /** * Adds the patterns of the other instance to this set. - * - * @param other Description of Parameter - * @param p Description of Parameter */ - public void append( PatternSet other, Project p ) + protected void append( PatternSet other ) throws TaskException { - if( isReference() ) - { - throw new TaskException( "Cannot append to a reference" ); - } - - String[] incl = other.getIncludePatterns( p ); + String[] incl = other.getIncludePatterns( null ); if( incl != null ) { for( int i = 0; i < incl.length; i++ ) @@ -204,7 +139,7 @@ public class PatternSet extends DataType } } - String[] excl = other.getExcludePatterns( p ); + String[] excl = other.getExcludePatterns( null ); if( excl != null ) { for( int i = 0; i < excl.length; i++ ) @@ -220,13 +155,8 @@ public class PatternSet extends DataType * @return Description of the Returned Value */ public NameEntry createExclude() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - return addPatternToList( excludeList ); + return addPatternToList( m_excludeList ); } /** @@ -235,121 +165,66 @@ public class PatternSet extends DataType * @return Description of the Returned Value */ public NameEntry createExcludesFile() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - return addPatternToList( excludesFileList ); + return addPatternToList( m_excludesFileList ); } /** * add a name entry on the include list - * - * @return Description of the Returned Value */ public NameEntry createInclude() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - return addPatternToList( includeList ); + return addPatternToList( m_includeList ); } /** * add a name entry on the include files list - * - * @return Description of the Returned Value */ public NameEntry createIncludesFile() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - return addPatternToList( includesFileList ); + return addPatternToList( m_includesFileList ); } public String toString() { - return "patternSet{ includes: " + includeList + - " excludes: " + excludeList + " }"; + return "patternSet{ includes: " + m_includeList + + " excludes: " + m_excludeList + " }"; } /** * helper for FileSet. - * - * @return Description of the Returned Value */ boolean hasPatterns() { - return includesFileList.size() > 0 || excludesFileList.size() > 0 - || includeList.size() > 0 || excludeList.size() > 0; - } - - /** - * Performs the check for circular references and returns the referenced - * PatternSet. - * - * @param p Description of Parameter - * @return The Ref value - */ - private PatternSet getRef( Project p ) - throws TaskException - { - if( !checked ) - { - Stack stk = new Stack(); - stk.push( this ); - dieOnCircularReference( stk, p ); - } - - Object o = ref.getReferencedObject( p ); - if( !( o instanceof PatternSet ) ) - { - String msg = ref.getRefId() + " doesn\'t denote a patternset"; - throw new TaskException( msg ); - } - else - { - return (PatternSet)o; - } + return m_includesFileList.size() > 0 || m_excludesFileList.size() > 0 || + m_includeList.size() > 0 || m_excludeList.size() > 0; } /** * add a name entry to the given list - * - * @param list The feature to be added to the PatternToList attribute - * @return Description of the Returned Value */ - private NameEntry addPatternToList( ArrayList list ) + private NameEntry addPatternToList( final ArrayList list ) { - NameEntry result = new NameEntry(); + final NameEntry result = new NameEntry(); list.add( result ); return result; } /** * Convert a vector of NameEntry elements into an array of Strings. - * - * @param list Description of Parameter - * @param p Description of Parameter - * @return Description of the Returned Value */ - private String[] makeArray( ArrayList list, Project p ) + private String[] makeArray( final ArrayList list ) { if( list.size() == 0 ) + { return null; + } - ArrayList tmpNames = new ArrayList(); + final ArrayList tmpNames = new ArrayList(); for( Iterator e = list.iterator(); e.hasNext(); ) { - NameEntry ne = (NameEntry)e.next(); - String pattern = ne.evalName( p ); + final NameEntry ne = (NameEntry)e.next(); + final String pattern = ne.evalName( null ); if( pattern != null && pattern.length() > 0 ) { tmpNames.add( pattern ); @@ -362,15 +237,13 @@ public class PatternSet extends DataType /** * Read includesfile ot excludesfile if not already done so. - * - * @param p Description of Parameter */ private void readFiles( Project p ) throws TaskException { - if( includesFileList.size() > 0 ) + if( m_includesFileList.size() > 0 ) { - Iterator e = includesFileList.iterator(); + Iterator e = m_includesFileList.iterator(); while( e.hasNext() ) { NameEntry ne = (NameEntry)e.next(); @@ -382,15 +255,15 @@ public class PatternSet extends DataType throw new TaskException( "Includesfile " + inclFile.getAbsolutePath() + " not found." ); - readPatterns( inclFile, includeList, p ); + readPatterns( inclFile, m_includeList, p ); } } - includesFileList.clear(); + m_includesFileList.clear(); } - if( excludesFileList.size() > 0 ) + if( m_excludesFileList.size() > 0 ) { - Iterator e = excludesFileList.iterator(); + Iterator e = m_excludesFileList.iterator(); while( e.hasNext() ) { NameEntry ne = (NameEntry)e.next(); @@ -402,10 +275,10 @@ public class PatternSet extends DataType throw new TaskException( "Excludesfile " + exclFile.getAbsolutePath() + " not found." ); - readPatterns( exclFile, excludeList, p ); + readPatterns( exclFile, m_excludeList, p ); } } - excludesFileList.clear(); + m_excludesFileList.clear(); } } @@ -538,5 +411,4 @@ public class PatternSet extends DataType return true; } } - } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/ZipFileSet.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/ZipFileSet.java index b941aab80..a02497ade 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/ZipFileSet.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/ZipFileSet.java @@ -38,16 +38,14 @@ public class ZipFileSet /** * Set the directory for the fileset. Prevents both "dir" and "src" from * being specified. - * - * @param dir The new Dir value - * @exception TaskException Description of Exception */ - public void setDir( File dir ) + public void setDir( final File dir ) throws TaskException { if( srcFile != null ) { - throw new TaskException( "Cannot set both dir and src attributes" ); + final String message = "Cannot set both dir and src attributes"; + throw new TaskException( message ); } else { @@ -104,22 +102,18 @@ public class ZipFileSet public DirectoryScanner getDirectoryScanner( Project p ) throws TaskException { - if( isReference() ) - { - return getRef( p ).getDirectoryScanner( p ); - } if( srcFile != null ) { ZipScanner zs = new ZipScanner(); zs.setSrc( srcFile ); super.setDir( p.getBaseDir() ); - setupDirectoryScanner( zs, p ); + setupDirectoryScanner( zs ); zs.init(); return zs; } else { - return super.getDirectoryScanner( p ); + return super.getDirectoryScanner(); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java index 8e07a0744..c4cbbb0bf 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java @@ -47,7 +47,7 @@ public class ClassfileSet extends FileSet public DirectoryScanner getDirectoryScanner( Project p ) { DependScanner scanner = new DependScanner(); - scanner.setBasedir( getDir( p ) ); + scanner.setBasedir( getDir() ); scanner.setRootClasses( rootClasses ); scanner.scan(); return scanner; diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Checksum.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Checksum.java index 412ee5b72..6cc05610f 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Checksum.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Checksum.java @@ -473,11 +473,11 @@ public class Checksum extends MatchingTask implements Condition for( int i = 0; i < sizeofFileSet; i++ ) { FileSet fs = (FileSet)filesets.get( i ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); String[] srcFiles = ds.getIncludedFiles(); for( int j = 0; j < srcFiles.length; j++ ) { - File src = new File( fs.getDir( getProject() ), srcFiles[ j ] ); + File src = new File( fs.getDir(), srcFiles[ j ] ); addToIncludeFileMap( src ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/DependSet.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/DependSet.java index d0c522617..88fabac1a 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/DependSet.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/DependSet.java @@ -154,13 +154,13 @@ public class DependSet extends MatchingTask { FileSet targetFS = (FileSet)enumTargetSets.next(); - DirectoryScanner targetDS = targetFS.getDirectoryScanner( getProject() ); + DirectoryScanner targetDS = targetFS.getDirectoryScanner(); String[] targetFiles = targetDS.getIncludedFiles(); for( int i = 0; i < targetFiles.length; i++ ) { - File dest = new File( targetFS.getDir( getProject() ), targetFiles[ i ] ); + File dest = new File( targetFS.getDir(), targetFiles[ i ] ); allTargets.add( dest ); if( dest.lastModified() > now ) @@ -212,12 +212,12 @@ public class DependSet extends MatchingTask { FileSet sourceFS = (FileSet)enumSourceSets.next(); - DirectoryScanner sourceDS = sourceFS.getDirectoryScanner( getProject() ); + DirectoryScanner sourceDS = sourceFS.getDirectoryScanner(); String[] sourceFiles = sourceDS.getIncludedFiles(); for( int i = 0; upToDate && i < sourceFiles.length; i++ ) { - File src = new File( sourceFS.getDir( getProject() ), sourceFiles[ i ] ); + File src = new File( sourceFS.getDir(), sourceFiles[ i ] ); if( src.lastModified() > now ) { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ExecuteOn.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ExecuteOn.java index 88fd3bcfa..9c2b41da9 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ExecuteOn.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ExecuteOn.java @@ -385,8 +385,8 @@ public class ExecuteOn extends ExecTask for( int i = 0; i < filesets.size(); i++ ) { FileSet fs = (FileSet)filesets.get( i ); - File base = fs.getDir( getProject() ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + File base = fs.getDir(); + DirectoryScanner ds = fs.getDirectoryScanner(); if( !"dir".equals( type ) ) { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Expand.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Expand.java index 3d4146e0d..764ab1a69 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Expand.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Expand.java @@ -131,8 +131,8 @@ public class Expand extends MatchingTask for( int j = 0; j < filesets.size(); j++ ) { FileSet fs = (FileSet)filesets.get( j ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); - File fromDir = fs.getDir( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); + File fromDir = fs.getDir(); String[] files = ds.getIncludedFiles(); for( int i = 0; i < files.length; ++i ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/MatchingTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/MatchingTask.java index a07f05c24..dec58827d 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/MatchingTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/MatchingTask.java @@ -157,7 +157,7 @@ public abstract class MatchingTask extends Task { fileset.setDir( baseDir ); fileset.setDefaultexcludes( useDefaultExcludes ); - return fileset.getDirectoryScanner( getProject() ); + return fileset.getDirectoryScanner(); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/SQLExec.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/SQLExec.java index 10091a85a..185047090 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/SQLExec.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/SQLExec.java @@ -407,8 +407,8 @@ public class SQLExec for( int i = 0; i < filesets.size(); i++ ) { FileSet fs = (FileSet)filesets.get( i ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); - File srcDir = fs.getDir( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); + File srcDir = fs.getDir(); String[] srcFiles = ds.getIncludedFiles(); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Tar.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Tar.java index 40fd19756..969f0e93c 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Tar.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Tar.java @@ -129,7 +129,7 @@ public class Tar } // add the main fileset to the list of filesets to process. - TarFileSet mainFileSet = new TarFileSet( fileset ); + TarFileSet mainFileSet = new TarFileSet( /*fileset*/ ); mainFileSet.setDir( baseDir ); filesets.add( mainFileSet ); } @@ -154,7 +154,7 @@ public class Tar for( int i = 0; i < files.length; ++i ) { - if( tarFile.equals( new File( fs.getDir( getProject() ), files[ i ] ) ) ) + if( tarFile.equals( new File( fs.getDir(), files[ i ] ) ) ) { throw new TaskException( "A tar file cannot include itself" ); } @@ -196,7 +196,7 @@ public class Tar String[] files = fs.getFiles( getProject() ); for( int i = 0; i < files.length; i++ ) { - File f = new File( fs.getDir( getProject() ), files[ i ] ); + File f = new File( fs.getDir(), files[ i ] ); String name = files[ i ].replace( File.separatorChar, '/' ); tarFile( f, tOut, name, fs ); } @@ -322,16 +322,6 @@ public class Tar private String userName = ""; private String groupName = ""; - public TarFileSet( FileSet fileset ) - { - super( fileset ); - } - - public TarFileSet() - { - super(); - } - public void setGroup( String groupName ) { this.groupName = groupName; @@ -359,7 +349,7 @@ public class Tar { if( files == null ) { - DirectoryScanner ds = getDirectoryScanner( p ); + DirectoryScanner ds = getDirectoryScanner(); String[] directories = ds.getIncludedDirectories(); String[] filesPerSe = ds.getIncludedFiles(); files = new String[ directories.length + filesPerSe.length ]; diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/UpToDate.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/UpToDate.java index cb5aee12d..7f62043db 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/UpToDate.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/UpToDate.java @@ -127,8 +127,8 @@ public class UpToDate extends MatchingTask implements Condition while( upToDate && enum.hasNext() ) { FileSet fs = (FileSet)enum.next(); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); - upToDate = upToDate && scanDir( fs.getDir( getProject() ), + DirectoryScanner ds = fs.getDirectoryScanner(); + upToDate = upToDate && scanDir( fs.getDir(), ds.getIncludedFiles() ); } return upToDate; diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Zip.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Zip.java index ed712a3dd..7e2604748 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Zip.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Zip.java @@ -264,7 +264,7 @@ public class Zip extends MatchingTask for( int i = 0; i < filesets.size(); i++ ) { FileSet fs = (FileSet)filesets.get( i ); - dss.add( fs.getDirectoryScanner( getProject() ) ); + dss.add( fs.getDirectoryScanner() ); } int dssSize = dss.size(); FileScanner[] scanners = new FileScanner[ dssSize ]; @@ -541,7 +541,7 @@ public class Zip extends MatchingTask for( int i = 0; i < filesets.size(); i++ ) { FileSet fs = (FileSet)filesets.get( i ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); String prefix = ""; String fullpath = ""; diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Copy.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Copy.java index 9eb399d8b..59974f2e5 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Copy.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Copy.java @@ -229,8 +229,8 @@ public class Copy for( int i = 0; i < m_filesets.size(); i++ ) { final FileSet fileSet = (FileSet)m_filesets.get( i ); - final DirectoryScanner scanner = fileSet.getDirectoryScanner( getProject() ); - final File fromDir = fileSet.getDir( getProject() ); + final DirectoryScanner scanner = fileSet.getDirectoryScanner(); + final File fromDir = fileSet.getDir(); final String[] srcFiles = scanner.getIncludedFiles(); final String[] srcDirs = scanner.getIncludedDirectories(); @@ -486,7 +486,7 @@ public class Copy else { FileSet fs = (FileSet)m_filesets.get( 0 ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); String[] srcFiles = ds.getIncludedFiles(); if( srcFiles.length > 0 ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Delete.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Delete.java index 8b10b330f..3b3873100 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Delete.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Delete.java @@ -44,7 +44,7 @@ public class Delete * * @param dir the directory path. */ - public void setDir( File dir ) + public void setDir( final File dir ) { m_dir = dir; } @@ -54,7 +54,7 @@ public class Delete * * @param file the file to be deleted */ - public void setFile( File file ) + public void setFile( final File file ) { m_file = file; } @@ -100,14 +100,16 @@ public class Delete getLogger().info( "Deleting: " + m_file.getAbsolutePath() ); if( !m_file.delete() ) { - String message = "Unable to delete file " + m_file.getAbsolutePath(); + final String message = "Unable to delete file " + m_file.getAbsolutePath(); throw new TaskException( message ); } } } else { - getLogger().debug( "Could not find file " + m_file.getAbsolutePath() + " to delete." ); + final String message = + "Could not find file " + m_file.getAbsolutePath() + " to delete."; + getLogger().debug( message ); } } @@ -124,10 +126,10 @@ public class Delete FileSet fs = (FileSet)filesets.get( i ); try { - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); String[] files = ds.getIncludedFiles(); String[] dirs = ds.getIncludedDirectories(); - removeFiles( fs.getDir( getProject() ), files, dirs ); + removeFiles( fs.getDir(), files, dirs ); } catch( TaskException be ) { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Move.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Move.java index 242a245e8..fa41dbb9a 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Move.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Move.java @@ -205,7 +205,7 @@ public class Move while( e.hasNext() ) { FileSet fs = (FileSet)e.next(); - File dir = fs.getDir( getProject() ); + File dir = fs.getDir(); if( okToDelete( dir ) ) { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Touch.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Touch.java index 3e7ea0314..c89c24a93 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Touch.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/file/Touch.java @@ -157,8 +157,8 @@ public class Touch for( int i = 0; i < size; i++ ) { final FileSet fs = (FileSet)m_filesets.get( i ); - final DirectoryScanner ds = fs.getDirectoryScanner( null ); - final File fromDir = fs.getDir( null ); + final DirectoryScanner ds = fs.getDirectoryScanner(); + final File fromDir = fs.getDir(); final String[] srcFiles = ds.getIncludedFiles(); final String[] srcDirs = ds.getIncludedDirectories(); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java index 109a86640..5f6b7a730 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java @@ -1022,7 +1022,7 @@ public class Javadoc final File source = resolveFile( list[ j ] ); fs.setDir( source ); - final DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + final DirectoryScanner ds = fs.getDirectoryScanner(); final String[] packageDirs = ds.getIncludedDirectories(); for( int i = 0; i < packageDirs.length; i++ ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Cab.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Cab.java index 55c7fdf94..d3c0854ed 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Cab.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Cab.java @@ -204,7 +204,7 @@ public class Cab extends MatchingTask FileSet fs = (FileSet)filesets.get( i ); if( fs != null ) { - appendFiles( files, fs.getDirectoryScanner( getProject() ) ); + appendFiles( files, fs.getDirectoryScanner() ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java index 271014251..641c765d9 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java @@ -559,8 +559,8 @@ public class GenericDeploymentTool for( Iterator i = config.supportFileSets.iterator(); i.hasNext(); ) { FileSet supportFileSet = (FileSet)i.next(); - File supportBaseDir = supportFileSet.getDir( project ); - DirectoryScanner supportScanner = supportFileSet.getDirectoryScanner( project ); + File supportBaseDir = supportFileSet.getDir(); + DirectoryScanner supportScanner = supportFileSet.getDirectoryScanner(); supportScanner.scan(); String[] supportFiles = supportScanner.getIncludedFiles(); for( int j = 0; j < supportFiles.length; ++j ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java index 9af0dc104..e484ce1a4 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java @@ -518,7 +518,7 @@ public class Translate for( int i = 0; i < filesets.size(); i++ ) { FileSet fs = (FileSet)filesets.get( i ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); String[] srcFiles = ds.getIncludedFiles(); for( int j = 0; j < srcFiles.length; j++ ) { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java index 8a86d00f8..f2136e32a 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java @@ -224,7 +224,7 @@ public class VAJImport extends VAJTask */ protected void importFileset( FileSet fileset ) { - DirectoryScanner ds = fileset.getDirectoryScanner( this.getProject() ); + DirectoryScanner ds = fileset.getDirectoryScanner(); if( ds.getIncludedFiles().length == 0 ) { return; diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java index e5459953f..dfe4d075e 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java @@ -127,7 +127,7 @@ public final class BatchTest extends BaseTest for( int j = 0; j < size; j++ ) { FileSet fs = (FileSet)filesets.get( j ); - DirectoryScanner ds = fs.getDirectoryScanner( project ); + DirectoryScanner ds = fs.getDirectoryScanner(); ds.scan(); String[] f = ds.getIncludedFiles(); for( int k = 0; k < f.length; k++ ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java index 39bd0657e..912d4d89c 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java @@ -200,7 +200,7 @@ public class XMLResultAggregator extends Task implements XMLConstants for( int i = 0; i < size; i++ ) { FileSet fs = (FileSet)filesets.get( i ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); ds.scan(); String[] f = ds.getIncludedFiles(); for( int j = 0; j < f.length; j++ ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java index 34b30101c..f7e19df11 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java @@ -365,7 +365,7 @@ public abstract class AbstractMetamataTask extends Task for( int i = 0; i < fileSets.size(); i++ ) { FileSet fs = (FileSet)fileSets.get( i ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); ds.scan(); String[] f = ds.getIncludedFiles(); getLogger().debug( i + ") Adding " + f.length + " files from directory " + ds.getBasedir() ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/FTP.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/FTP.java index a9c740dd5..af41dcd7a 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/FTP.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/FTP.java @@ -792,12 +792,12 @@ public class FTP if( action == SEND_FILES ) { - ds = fs.getDirectoryScanner( getProject() ); + ds = fs.getDirectoryScanner(); } else { ds = new FTPDirectoryScanner( ftp ); - fs.setupDirectoryScanner( ds, getProject() ); + fs.setupDirectoryScanner( ds ); ds.scan(); } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java index 333c8cf7c..d98fe62c9 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java @@ -307,7 +307,7 @@ public class MimeMail extends Task FileSet fs = (FileSet)filesets.get( i ); if( fs != null ) { - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); String[] dsfiles = ds.getIncludedFiles(); File baseDir = ds.getBasedir(); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4Add.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4Add.java index 10e2dbbd2..5a6558631 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4Add.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4Add.java @@ -123,7 +123,7 @@ public class P4Add extends P4Base for( int i = 0; i < filesets.size(); i++ ) { FileSet fs = (FileSet)filesets.get( i ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); //File fromDir = fs.getDir(project); String[] srcFiles = ds.getIncludedFiles(); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java index 5ee156716..823c7f88f 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java @@ -152,7 +152,7 @@ public class CovMerge extends Task for( int i = 0; i < size; i++ ) { FileSet fs = (FileSet)filesets.get( i ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); ds.scan(); String[] f = ds.getIncludedFiles(); for( int j = 0; j < f.length; j++ ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/security/SignJar.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/security/SignJar.java index 1b85b8847..567d85f3b 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/security/SignJar.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/security/SignJar.java @@ -151,12 +151,12 @@ public class SignJar for( int i = 0; i < m_filesets.size(); i++ ) { final FileSet fileSet = (FileSet)m_filesets.get( i ); - final DirectoryScanner scanner = fileSet.getDirectoryScanner( null ); + final DirectoryScanner scanner = fileSet.getDirectoryScanner(); final String[] jarFiles = scanner.getIncludedFiles(); for( int j = 0; j < jarFiles.length; j++ ) { final File file = - new File( fileSet.getDir( null ), jarFiles[ j ] ); + new File( fileSet.getDir(), jarFiles[ j ] ); doOneJar( file, null ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/text/ReplaceRegExp.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/text/ReplaceRegExp.java index 6364379ae..0455b5462 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/text/ReplaceRegExp.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/text/ReplaceRegExp.java @@ -205,7 +205,7 @@ public class ReplaceRegExp extends Task for( int i = 0; i < sz; i++ ) { FileSet fs = (FileSet)( filesets.get( i ) ); - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); String files[] = ds.getIncludedFiles(); for( int j = 0; j < files.length; j++ ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/unix/Chmod.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/unix/Chmod.java index 56e6ff5ae..f442d2744 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/unix/Chmod.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/unix/Chmod.java @@ -152,14 +152,14 @@ public class Chmod extends ExecuteOn public void execute() throws TaskException { - if( defaultSetDefined || defaultSet.getDir( getProject() ) == null ) + if( defaultSetDefined || defaultSet.getDir() == null ) { super.execute(); } else if( isValidOs() ) { // we are chmodding the given directory - createArg().setValue( defaultSet.getDir( getProject() ).getPath() ); + createArg().setValue( defaultSet.getDir().getPath() ); Execute execute = prepareExec(); try { @@ -191,7 +191,7 @@ public class Chmod extends ExecuteOn throw new TaskException( "Required attribute perm not set in chmod" ); } - if( defaultSetDefined && defaultSet.getDir( getProject() ) != null ) + if( defaultSetDefined && defaultSet.getDir() != null ) { addFileset( defaultSet ); } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FileSet.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FileSet.java index 6bc143424..f73ed3da4 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FileSet.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FileSet.java @@ -9,11 +9,9 @@ package org.apache.tools.ant.types; import java.io.File; import java.util.ArrayList; -import java.util.Stack; import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.FileScanner; -import org.apache.tools.ant.Project; /** * Moved out of MatchingTask to make it a standalone object that could be @@ -31,64 +29,36 @@ public class FileSet extends DataType implements Cloneable { - private PatternSet defaultPatterns = new PatternSet(); - private ArrayList additionalPatterns = new ArrayList(); - private boolean useDefaultExcludes = true; - private boolean isCaseSensitive = true; - - private File dir; + private PatternSet m_defaultPatterns = new PatternSet(); + private ArrayList m_additionalPatterns = new ArrayList(); + private boolean m_useDefaultExcludes = true; + private boolean m_isCaseSensitive = true; + private File m_dir; public FileSet() { - super(); - } - - protected FileSet( FileSet fileset ) - { - this.dir = fileset.dir; - this.defaultPatterns = fileset.defaultPatterns; - this.additionalPatterns = fileset.additionalPatterns; - this.useDefaultExcludes = fileset.useDefaultExcludes; - this.isCaseSensitive = fileset.isCaseSensitive; } /** * Sets case sensitivity of the file system - * - * @param isCaseSensitive "true"|"on"|"yes" if file system is case - * sensitive, "false"|"off"|"no" when not. */ - public void setCaseSensitive( boolean isCaseSensitive ) + public void setCaseSensitive( final boolean isCaseSensitive ) { - this.isCaseSensitive = isCaseSensitive; + m_isCaseSensitive = isCaseSensitive; } /** * Sets whether default exclusions should be used or not. - * - * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions - * should be used, "false"|"off"|"no" when they shouldn't be used. */ - public void setDefaultexcludes( boolean useDefaultExcludes ) - throws TaskException + public void setDefaultexcludes( final boolean useDefaultExcludes ) { - if( isReference() ) - { - throw tooManyAttributes(); - } - - this.useDefaultExcludes = useDefaultExcludes; + m_useDefaultExcludes = useDefaultExcludes; } - public void setDir( File dir ) + public void setDir( final File dir ) throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } - - this.dir = dir; + m_dir = dir; } /** @@ -97,32 +67,19 @@ public class FileSet * * @param excludes the string containing the exclude patterns */ - public void setExcludes( String excludes ) - throws TaskException + public void setExcludes( final String excludes ) { - if( isReference() ) - { - throw tooManyAttributes(); - } - - defaultPatterns.setExcludes( excludes ); + m_defaultPatterns.setExcludes( excludes ); } /** * Sets the name of the file containing the includes patterns. * * @param excl The file to fetch the exclude patterns from. - * @exception TaskException Description of Exception */ - public void setExcludesfile( File excl ) - throws TaskException + public void setExcludesfile( final File excl ) { - if( isReference() ) - { - throw tooManyAttributes(); - } - - defaultPatterns.setExcludesfile( excl ); + m_defaultPatterns.setExcludesfile( excl ); } /** @@ -132,250 +89,118 @@ public class FileSet * @param includes the string containing the include patterns */ public void setIncludes( String includes ) - throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } - - defaultPatterns.setIncludes( includes ); + m_defaultPatterns.setIncludes( includes ); } /** * Sets the name of the file containing the includes patterns. * * @param incl The file to fetch the include patterns from. - * @exception TaskException Description of Exception */ public void setIncludesfile( File incl ) - throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } - - defaultPatterns.setIncludesfile( incl ); + m_defaultPatterns.setIncludesfile( incl ); } - /** - * Makes this instance in effect a reference to another PatternSet instance. - *

- * - * You must not set another attribute or nest elements inside this element - * if you make it a reference.

- * - * @param r The new Refid value - * @exception TaskException Description of Exception - */ - public void setRefid( Reference r ) + public void setupDirectoryScanner( final FileScanner ds ) throws TaskException { - if( dir != null || defaultPatterns.hasPatterns() ) + if( null == ds ) { - throw tooManyAttributes(); + final String message = "ds cannot be null"; + throw new IllegalArgumentException( message ); } - if( !additionalPatterns.isEmpty() ) - { - throw noChildrenAllowed(); - } - super.setRefid( r ); - } - public void setupDirectoryScanner( FileScanner ds, Project p ) - throws TaskException - { - if( ds == null ) - { - throw new IllegalArgumentException( "ds cannot be null" ); - } - - ds.setBasedir( dir ); + ds.setBasedir( m_dir ); - for( int i = 0; i < additionalPatterns.size(); i++ ) + final int size = m_additionalPatterns.size(); + for( int i = 0; i < size; i++ ) { - Object o = additionalPatterns.get( i ); - defaultPatterns.append( (PatternSet)o, p ); + final Object o = m_additionalPatterns.get( i ); + m_defaultPatterns.append( (PatternSet)o ); } - getLogger().debug( "FileSet: Setup file scanner in dir " + dir + " with " + defaultPatterns ); + final String message = "FileSet: Setup file scanner in dir " + + m_dir + " with " + m_defaultPatterns; + getLogger().debug( message ); - ds.setIncludes( defaultPatterns.getIncludePatterns( p ) ); - ds.setExcludes( defaultPatterns.getExcludePatterns( p ) ); - if( useDefaultExcludes ) + ds.setIncludes( m_defaultPatterns.getIncludePatterns( null ) ); + ds.setExcludes( m_defaultPatterns.getExcludePatterns( null ) ); + if( m_useDefaultExcludes ) + { ds.addDefaultExcludes(); - ds.setCaseSensitive( isCaseSensitive ); + } + ds.setCaseSensitive( m_isCaseSensitive ); } - public File getDir( Project p ) - throws TaskException + public File getDir() { - if( isReference() ) - { - return getRef( p ).getDir( p ); - } - return dir; + return m_dir; } /** * Returns the directory scanner needed to access the files to process. - * - * @param p Description of Parameter - * @return The DirectoryScanner value */ - public DirectoryScanner getDirectoryScanner( Project p ) + public DirectoryScanner getDirectoryScanner() throws TaskException { - if( isReference() ) - { - return getRef( p ).getDirectoryScanner( p ); - } - - if( dir == null ) + if( m_dir == null ) { throw new TaskException( "No directory specified for fileset." ); } - if( !dir.exists() ) + if( !m_dir.exists() ) { - throw new TaskException( dir.getAbsolutePath() + " not found." ); + throw new TaskException( m_dir.getAbsolutePath() + " not found." ); } - if( !dir.isDirectory() ) + if( !m_dir.isDirectory() ) { - throw new TaskException( dir.getAbsolutePath() + " is not a directory." ); + throw new TaskException( m_dir.getAbsolutePath() + " is not a directory." ); } - DirectoryScanner ds = new DirectoryScanner(); - setupDirectoryScanner( ds, p ); - ds.scan(); - return ds; - } - - /** - * Return a FileSet that has the same basedir and same patternsets as this - * one. - * - * @return Description of the Returned Value - */ - public Object clone() - { - try - { - if( isReference() ) - { - return new FileSet( getRef( getProject() ) ); - } - else - { - return new FileSet( this ); - } - } - catch( TaskException e ) - { - throw new IllegalStateException( e.getMessage() ); - } + final DirectoryScanner scanner = new DirectoryScanner(); + setupDirectoryScanner( scanner ); + scanner.scan(); + return scanner; } /** * add a name entry on the exclude list - * - * @return Description of the Returned Value */ public PatternSet.NameEntry createExclude() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - return defaultPatterns.createExclude(); + return m_defaultPatterns.createExclude(); } /** * add a name entry on the include files list - * - * @return Description of the Returned Value */ public PatternSet.NameEntry createExcludesFile() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - return defaultPatterns.createExcludesFile(); + return m_defaultPatterns.createExcludesFile(); } /** * add a name entry on the include list - * - * @return Description of the Returned Value */ public PatternSet.NameEntry createInclude() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - return defaultPatterns.createInclude(); + return m_defaultPatterns.createInclude(); } /** * add a name entry on the include files list - * - * @return Description of the Returned Value */ public PatternSet.NameEntry createIncludesFile() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - return defaultPatterns.createIncludesFile(); + return m_defaultPatterns.createIncludesFile(); } public PatternSet createPatternSet() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - PatternSet patterns = new PatternSet(); - additionalPatterns.add( patterns ); + final PatternSet patterns = new PatternSet(); + m_additionalPatterns.add( patterns ); return patterns; } - - /** - * Performs the check for circular references and returns the referenced - * FileSet. - * - * @param p Description of Parameter - * @return The Ref value - */ - protected FileSet getRef( Project p ) - throws TaskException - { - if( !checked ) - { - Stack stk = new Stack(); - stk.push( this ); - dieOnCircularReference( stk, p ); - } - - Object o = ref.getReferencedObject( p ); - if( !( o instanceof FileSet ) ) - { - String msg = ref.getRefId() + " doesn\'t denote a fileset"; - throw new TaskException( msg ); - } - else - { - return (FileSet)o; - } - } - } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/Path.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/Path.java index fac5ca02d..c457fe659 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/Path.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/Path.java @@ -588,9 +588,9 @@ public class Path else if( o instanceof FileSet ) { FileSet fs = (FileSet)o; - DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); + DirectoryScanner ds = fs.getDirectoryScanner(); String[] s = ds.getIncludedFiles(); - File dir = fs.getDir( getProject() ); + File dir = fs.getDir(); for( int j = 0; j < s.length; j++ ) { File f = new File( dir, s[ j ] ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/PatternSet.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/PatternSet.java index f7224e86c..14a349eee 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/PatternSet.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/PatternSet.java @@ -13,7 +13,6 @@ import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; -import java.util.Stack; import java.util.StringTokenizer; import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.Project; @@ -31,12 +30,13 @@ import org.apache.tools.ant.Project; * @author Jon S. Stevens jon@clearink.com * @author Stefan Bodewig */ -public class PatternSet extends DataType +public class PatternSet + extends DataType { - private ArrayList includeList = new ArrayList(); - private ArrayList excludeList = new ArrayList(); - private ArrayList includesFileList = new ArrayList(); - private ArrayList excludesFileList = new ArrayList(); + private ArrayList m_includeList = new ArrayList(); + private ArrayList m_excludeList = new ArrayList(); + private ArrayList m_includesFileList = new ArrayList(); + private ArrayList m_excludesFileList = new ArrayList(); public PatternSet() { @@ -50,12 +50,7 @@ public class PatternSet extends DataType * @param excludes the string containing the exclude patterns */ public void setExcludes( String excludes ) - throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } if( excludes != null && excludes.length() > 0 ) { StringTokenizer tok = new StringTokenizer( excludes, ", ", false ); @@ -73,12 +68,7 @@ public class PatternSet extends DataType * @exception TaskException Description of Exception */ public void setExcludesfile( File excludesFile ) - throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } createExcludesFile().setName( excludesFile.getAbsolutePath() ); } @@ -89,12 +79,7 @@ public class PatternSet extends DataType * @param includes the string containing the include patterns */ public void setIncludes( String includes ) - throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } if( includes != null && includes.length() > 0 ) { StringTokenizer tok = new StringTokenizer( includes, ", ", false ); @@ -112,53 +97,18 @@ public class PatternSet extends DataType * @exception TaskException Description of Exception */ public void setIncludesfile( File includesFile ) - throws TaskException { - if( isReference() ) - { - throw tooManyAttributes(); - } createIncludesFile().setName( includesFile.getAbsolutePath() ); } - /** - * Makes this instance in effect a reference to another PatternSet instance. - *

- * - * You must not set another attribute or nest elements inside this element - * if you make it a reference.

- * - * @param r The new Refid value - * @exception TaskException Description of Exception - */ - public void setRefid( Reference r ) - throws TaskException - { - if( !includeList.isEmpty() || !excludeList.isEmpty() ) - { - throw tooManyAttributes(); - } - super.setRefid( r ); - } - /** * Returns the filtered include patterns. - * - * @param p Description of Parameter - * @return The ExcludePatterns value */ public String[] getExcludePatterns( Project p ) throws TaskException { - if( isReference() ) - { - return getRef( p ).getExcludePatterns( p ); - } - else - { - readFiles( p ); - return makeArray( excludeList, p ); - } + readFiles( p ); + return makeArray( m_excludeList ); } /** @@ -170,32 +120,17 @@ public class PatternSet extends DataType public String[] getIncludePatterns( Project p ) throws TaskException { - if( isReference() ) - { - return getRef( p ).getIncludePatterns( p ); - } - else - { - readFiles( p ); - return makeArray( includeList, p ); - } + readFiles( p ); + return makeArray( m_includeList ); } /** * Adds the patterns of the other instance to this set. - * - * @param other Description of Parameter - * @param p Description of Parameter */ - public void append( PatternSet other, Project p ) + protected void append( PatternSet other ) throws TaskException { - if( isReference() ) - { - throw new TaskException( "Cannot append to a reference" ); - } - - String[] incl = other.getIncludePatterns( p ); + String[] incl = other.getIncludePatterns( null ); if( incl != null ) { for( int i = 0; i < incl.length; i++ ) @@ -204,7 +139,7 @@ public class PatternSet extends DataType } } - String[] excl = other.getExcludePatterns( p ); + String[] excl = other.getExcludePatterns( null ); if( excl != null ) { for( int i = 0; i < excl.length; i++ ) @@ -220,13 +155,8 @@ public class PatternSet extends DataType * @return Description of the Returned Value */ public NameEntry createExclude() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - return addPatternToList( excludeList ); + return addPatternToList( m_excludeList ); } /** @@ -235,121 +165,66 @@ public class PatternSet extends DataType * @return Description of the Returned Value */ public NameEntry createExcludesFile() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - return addPatternToList( excludesFileList ); + return addPatternToList( m_excludesFileList ); } /** * add a name entry on the include list - * - * @return Description of the Returned Value */ public NameEntry createInclude() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - return addPatternToList( includeList ); + return addPatternToList( m_includeList ); } /** * add a name entry on the include files list - * - * @return Description of the Returned Value */ public NameEntry createIncludesFile() - throws TaskException { - if( isReference() ) - { - throw noChildrenAllowed(); - } - return addPatternToList( includesFileList ); + return addPatternToList( m_includesFileList ); } public String toString() { - return "patternSet{ includes: " + includeList + - " excludes: " + excludeList + " }"; + return "patternSet{ includes: " + m_includeList + + " excludes: " + m_excludeList + " }"; } /** * helper for FileSet. - * - * @return Description of the Returned Value */ boolean hasPatterns() { - return includesFileList.size() > 0 || excludesFileList.size() > 0 - || includeList.size() > 0 || excludeList.size() > 0; - } - - /** - * Performs the check for circular references and returns the referenced - * PatternSet. - * - * @param p Description of Parameter - * @return The Ref value - */ - private PatternSet getRef( Project p ) - throws TaskException - { - if( !checked ) - { - Stack stk = new Stack(); - stk.push( this ); - dieOnCircularReference( stk, p ); - } - - Object o = ref.getReferencedObject( p ); - if( !( o instanceof PatternSet ) ) - { - String msg = ref.getRefId() + " doesn\'t denote a patternset"; - throw new TaskException( msg ); - } - else - { - return (PatternSet)o; - } + return m_includesFileList.size() > 0 || m_excludesFileList.size() > 0 || + m_includeList.size() > 0 || m_excludeList.size() > 0; } /** * add a name entry to the given list - * - * @param list The feature to be added to the PatternToList attribute - * @return Description of the Returned Value */ - private NameEntry addPatternToList( ArrayList list ) + private NameEntry addPatternToList( final ArrayList list ) { - NameEntry result = new NameEntry(); + final NameEntry result = new NameEntry(); list.add( result ); return result; } /** * Convert a vector of NameEntry elements into an array of Strings. - * - * @param list Description of Parameter - * @param p Description of Parameter - * @return Description of the Returned Value */ - private String[] makeArray( ArrayList list, Project p ) + private String[] makeArray( final ArrayList list ) { if( list.size() == 0 ) + { return null; + } - ArrayList tmpNames = new ArrayList(); + final ArrayList tmpNames = new ArrayList(); for( Iterator e = list.iterator(); e.hasNext(); ) { - NameEntry ne = (NameEntry)e.next(); - String pattern = ne.evalName( p ); + final NameEntry ne = (NameEntry)e.next(); + final String pattern = ne.evalName( null ); if( pattern != null && pattern.length() > 0 ) { tmpNames.add( pattern ); @@ -362,15 +237,13 @@ public class PatternSet extends DataType /** * Read includesfile ot excludesfile if not already done so. - * - * @param p Description of Parameter */ private void readFiles( Project p ) throws TaskException { - if( includesFileList.size() > 0 ) + if( m_includesFileList.size() > 0 ) { - Iterator e = includesFileList.iterator(); + Iterator e = m_includesFileList.iterator(); while( e.hasNext() ) { NameEntry ne = (NameEntry)e.next(); @@ -382,15 +255,15 @@ public class PatternSet extends DataType throw new TaskException( "Includesfile " + inclFile.getAbsolutePath() + " not found." ); - readPatterns( inclFile, includeList, p ); + readPatterns( inclFile, m_includeList, p ); } } - includesFileList.clear(); + m_includesFileList.clear(); } - if( excludesFileList.size() > 0 ) + if( m_excludesFileList.size() > 0 ) { - Iterator e = excludesFileList.iterator(); + Iterator e = m_excludesFileList.iterator(); while( e.hasNext() ) { NameEntry ne = (NameEntry)e.next(); @@ -402,10 +275,10 @@ public class PatternSet extends DataType throw new TaskException( "Excludesfile " + exclFile.getAbsolutePath() + " not found." ); - readPatterns( exclFile, excludeList, p ); + readPatterns( exclFile, m_excludeList, p ); } } - excludesFileList.clear(); + m_excludesFileList.clear(); } } @@ -538,5 +411,4 @@ public class PatternSet extends DataType return true; } } - } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/ZipFileSet.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/ZipFileSet.java index b941aab80..a02497ade 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/ZipFileSet.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/ZipFileSet.java @@ -38,16 +38,14 @@ public class ZipFileSet /** * Set the directory for the fileset. Prevents both "dir" and "src" from * being specified. - * - * @param dir The new Dir value - * @exception TaskException Description of Exception */ - public void setDir( File dir ) + public void setDir( final File dir ) throws TaskException { if( srcFile != null ) { - throw new TaskException( "Cannot set both dir and src attributes" ); + final String message = "Cannot set both dir and src attributes"; + throw new TaskException( message ); } else { @@ -104,22 +102,18 @@ public class ZipFileSet public DirectoryScanner getDirectoryScanner( Project p ) throws TaskException { - if( isReference() ) - { - return getRef( p ).getDirectoryScanner( p ); - } if( srcFile != null ) { ZipScanner zs = new ZipScanner(); zs.setSrc( srcFile ); super.setDir( p.getBaseDir() ); - setupDirectoryScanner( zs, p ); + setupDirectoryScanner( zs ); zs.init(); return zs; } else { - return super.getDirectoryScanner( p ); + return super.getDirectoryScanner(); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/optional/depend/ClassfileSet.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/optional/depend/ClassfileSet.java index 8e07a0744..c4cbbb0bf 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/optional/depend/ClassfileSet.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/optional/depend/ClassfileSet.java @@ -47,7 +47,7 @@ public class ClassfileSet extends FileSet public DirectoryScanner getDirectoryScanner( Project p ) { DependScanner scanner = new DependScanner(); - scanner.setBasedir( getDir( p ) ); + scanner.setBasedir( getDir() ); scanner.setRootClasses( rootClasses ); scanner.scan(); return scanner;