ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types FileSet.java Path.java ScannerUtil.java ZipFileSet.java
Date Sat, 26 Jan 2002 02:07:36 GMT
donaldp     02/01/25 18:07:36

  Modified:    proposal/myrmidon/src/main/org/apache/tools/ant/types
                        FileSet.java Path.java ScannerUtil.java
                        ZipFileSet.java
  Log:
  Move FileSet logic into a ScannerUtil class
  
  Revision  Changes    Path
  1.18      +30 -79    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java
  
  Index: FileSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- FileSet.java	25 Jan 2002 23:21:21 -0000	1.17
  +++ FileSet.java	26 Jan 2002 02:07:36 -0000	1.18
  @@ -8,11 +8,9 @@
   package org.apache.tools.ant.types;
   
   import java.io.File;
  -import java.util.ArrayList;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.framework.Pattern;
   import org.apache.myrmidon.framework.PatternSet;
  -import org.apache.tools.ant.ProjectComponent;
   
   /**
    * Moved out of MatchingTask to make it a standalone object that could be
  @@ -27,14 +25,11 @@
    * @author <a href="mailto:umagesh@rediffmail.com">Magesh Umasankar</a>
    */
   public class FileSet
  -    extends ProjectComponent
  -    implements Cloneable
   {
  -    private PatternSet m_defaultPatterns = new PatternSet();
  -    private ArrayList m_additionalPatterns = new ArrayList();
  +    private File m_dir;
  +    private PatternSet m_patternSet = new PatternSet();
       private boolean m_useDefaultExcludes = true;
       private boolean m_isCaseSensitive = true;
  -    private File m_dir;
   
       /**
        * Sets case sensitivity of the file system
  @@ -66,102 +61,58 @@
        */
       public void setExcludes( final String excludes )
       {
  -        m_defaultPatterns.setExcludes( excludes );
  +        m_patternSet.setExcludes( excludes );
       }
   
       /**
  -     * Sets the set of include patterns. Patterns may be separated by a comma or
  -     * a space.
  -     *
  -     * @param includes the string containing the include patterns
  +     * add a name entry on the exclude list
        */
  -    public void setIncludes( final String includes )
  +    public void addExclude( final Pattern pattern )
       {
  -        m_defaultPatterns.setIncludes( includes );
  +        m_patternSet.addExclude( pattern );
       }
   
  -    public void setupDirectoryScanner( final FileScanner ds )
  -        throws TaskException
  +    /**
  +     * add a name entry on the include list
  +     */
  +    public void addInclude( final Pattern pattern )
       {
  -        if( null == ds )
  -        {
  -            final String message = "ds cannot be null";
  -            throw new IllegalArgumentException( message );
  -        }
  -
  -        ds.setBasedir( m_dir );
  -
  -        final int size = m_additionalPatterns.size();
  -        for( int i = 0; i < size; i++ )
  -        {
  -            final Object o = m_additionalPatterns.get( i );
  -            m_defaultPatterns.append( (PatternSet)o );
  -        }
  -
  -        final String message = "FileSet: Setup file scanner in dir " +
  -            m_dir + " with " + m_defaultPatterns;
  -        getLogger().debug( message );
  -
  -        ds.setIncludes( m_defaultPatterns.getIncludePatterns( getContext() ) );
  -        ds.setExcludes( m_defaultPatterns.getExcludePatterns( getContext() ) );
  -        if( m_useDefaultExcludes )
  -        {
  -            ds.addDefaultExcludes();
  -        }
  -        ds.setCaseSensitive( m_isCaseSensitive );
  +        m_patternSet.addInclude( pattern );
       }
   
  -    public File getDir()
  +    public void addPatternSet( final PatternSet set )
       {
  -        return m_dir;
  +        m_patternSet.append( set );
       }
   
       /**
  -     * Returns the directory scanner needed to access the files to process.
  +     * Sets the set of include patterns. Patterns may be separated by a comma or
  +     * a space.
  +     *
  +     * @param includes the string containing the include patterns
        */
  -    public DirectoryScanner getDirectoryScanner()
  -        throws TaskException
  +    public void setIncludes( final String includes )
       {
  -        if( m_dir == null )
  -        {
  -            throw new TaskException( "No directory specified for fileset." );
  -        }
  -
  -        if( !m_dir.exists() )
  -        {
  -            throw new TaskException( m_dir.getAbsolutePath() + " not found." );
  -        }
  -        if( !m_dir.isDirectory() )
  -        {
  -            throw new TaskException( m_dir.getAbsolutePath() + " is not a directory." );
  -        }
  -
  -        final DirectoryScanner scanner = new DirectoryScanner();
  -        setupDirectoryScanner( scanner );
  -        scanner.scan();
  -        return scanner;
  +        m_patternSet.setIncludes( includes );
       }
   
  -    /**
  -     * add a name entry on the exclude list
  -     */
  -    public void addExclude( final Pattern pattern )
  +    public final PatternSet getPatternSet()
       {
  -        m_defaultPatterns.addExclude( pattern );
  +        return m_patternSet;
       }
   
  -    /**
  -     * add a name entry on the include list
  -     */
  -    public void addInclude( final Pattern pattern )
  +    public boolean isCaseSensitive()
  +    {
  +        return m_isCaseSensitive;
  +    }
  +
  +    public boolean useDefaultExcludes()
       {
  -        m_defaultPatterns.addInclude( pattern );
  +        return m_useDefaultExcludes;
       }
   
  -    public PatternSet createPatternSet()
  +    public File getDir()
       {
  -        final PatternSet patterns = new PatternSet();
  -        m_additionalPatterns.add( patterns );
  -        return patterns;
  +        return m_dir;
       }
   }
  
  
  
  1.21      +1 -1      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java
  
  Index: Path.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- Path.java	20 Jan 2002 17:35:00 -0000	1.20
  +++ Path.java	26 Jan 2002 02:07:36 -0000	1.21
  @@ -205,7 +205,7 @@
               else if( o instanceof FileSet )
               {
                   final FileSet fs = (FileSet)o;
  -                final DirectoryScanner ds = fs.getDirectoryScanner();
  +                final DirectoryScanner ds = ScannerUtil.getDirectoryScanner( fs );
                   final String[] s = ds.getIncludedFiles();
                   final File dir = fs.getDir();
                   for( int j = 0; j < s.length; j++ )
  
  
  
  1.3       +57 -1     jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/ScannerUtil.java
  
  Index: ScannerUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/ScannerUtil.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ScannerUtil.java	25 Jan 2002 23:59:35 -0000	1.2
  +++ ScannerUtil.java	26 Jan 2002 02:07:36 -0000	1.3
  @@ -10,6 +10,9 @@
   import java.io.File;
   import java.util.ArrayList;
   import java.util.StringTokenizer;
  +import org.apache.myrmidon.api.TaskContext;
  +import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.framework.PatternUtil;
   
   /**
    *
  @@ -17,7 +20,7 @@
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author Arnout J. Kuiper <a href="mailto:ajkuiper@wxs.nl">ajkuiper@wxs.nl</a>
    * @author <a href="mailto:umagesh@rediffmail.com">Magesh Umasankar</a>
  - * @version $Revision: 1.2 $ $Date: 2002/01/25 23:59:35 $
  + * @version $Revision: 1.3 $ $Date: 2002/01/26 02:07:36 $
    */
   public class ScannerUtil
   {
  @@ -523,5 +526,58 @@
               // this will generate false positives but we can live with that.
               return true;
           }
  +    }
  +
  +    public static void setupDirectoryScanner( final FileSet set,
  +                                              final FileScanner scanner,
  +                                              final TaskContext context )
  +        throws TaskException
  +    {
  +        if( null == scanner )
  +        {
  +            final String message = "ds cannot be null";
  +            throw new IllegalArgumentException( message );
  +        }
  +
  +        scanner.setBasedir( set.getDir() );
  +
  +        final String message = "FileSet: Setup file scanner in dir " +
  +            set.getDir() + " with " + set.getPatternSet();
  +        //getLogger().debug( message );
  +
  +        scanner.setIncludes( PatternUtil.getIncludePatterns( set.getPatternSet(), context
) );
  +        scanner.setExcludes( PatternUtil.getExcludePatterns( set.getPatternSet(), context
) );
  +        if( set.useDefaultExcludes() )
  +        {
  +            scanner.addDefaultExcludes();
  +        }
  +        scanner.setCaseSensitive( set.isCaseSensitive() );
  +    }
  +
  +    public static DirectoryScanner getDirectoryScanner( final FileSet set )
  +        throws TaskException
  +    {
  +        final File dir = set.getDir();
  +        if( null == dir )
  +        {
  +            final String message = "No directory specified for fileset.";
  +            throw new TaskException( message );
  +        }
  +
  +        if( !dir.exists() )
  +        {
  +            final String message = dir.getAbsolutePath() + " not found.";
  +            throw new TaskException( message );
  +        }
  +        if( !dir.isDirectory() )
  +        {
  +            final String message = dir.getAbsolutePath() + " is not a directory.";
  +            throw new TaskException( message );
  +        }
  +
  +        final DirectoryScanner scanner = new DirectoryScanner();
  +        setupDirectoryScanner( set, scanner, null );
  +        scanner.scan();
  +        return scanner;
       }
   }
  
  
  
  1.7       +4 -3      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/ZipFileSet.java
  
  Index: ZipFileSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/ZipFileSet.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ZipFileSet.java	12 Jan 2002 23:56:33 -0000	1.6
  +++ ZipFileSet.java	26 Jan 2002 02:07:36 -0000	1.7
  @@ -9,6 +9,7 @@
   
   import java.io.File;
   import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.api.TaskContext;
   import org.apache.tools.ant.Project;
   
   /**
  @@ -103,16 +104,16 @@
       {
           if( srcFile != null )
           {
  -            ZipScanner zs = new ZipScanner();
  +            final ZipScanner zs = new ZipScanner();
               zs.setSrc( srcFile );
               super.setDir( p.getBaseDir() );
  -            setupDirectoryScanner( zs );
  +            ScannerUtil.setupDirectoryScanner( this, zs, null );
               zs.init();
               return zs;
           }
           else
           {
  -            return super.getDirectoryScanner();
  +            return ScannerUtil.getDirectoryScanner( this );
           }
       }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message