tbennett    2004/04/19 17:03:32

  Modified:    composition/impl/src/java/org/apache/avalon/composition/model/impl
                        DefaultClassLoaderModel.java
                        DefaultFilesetModel.java DirectoryScanner.java
  Log:
  finalizing the fileset implementation...
  
  Revision  Changes    Path
  1.17      +2 -2      
avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultClassLoaderModel.java
  
  Index: DefaultClassLoaderModel.java
  ===================================================================
  RCS file: 
/home/cvs/avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultClassLoaderModel.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- DefaultClassLoaderModel.java      17 Apr 2004 19:05:14 -0000      1.16
  +++ DefaultClassLoaderModel.java      20 Apr 2004 00:03:32 -0000      1.17
  @@ -647,7 +647,7 @@
       *   file references will be resolved
       * @return the classpath
       */
  -    public File[] expandFileSetDirectives( 
  +    public File[] expandFileSetDirectives ( 
         File base, FilesetDirective[] filesets ) throws IOException, 
IllegalStateException
       {
           getLocalLogger().debug("base=[" + base + "]");
  
  
  
  1.2       +66 -2     
avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultFilesetModel.java
  
  Index: DefaultFilesetModel.java
  ===================================================================
  RCS file: 
/home/cvs/avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultFilesetModel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultFilesetModel.java  17 Apr 2004 19:05:14 -0000      1.1
  +++ DefaultFilesetModel.java  20 Apr 2004 00:03:32 -0000      1.2
  @@ -18,6 +18,7 @@
   package org.apache.avalon.composition.model.impl;
   
   import java.io.File;
  +import java.io.IOException;
   import java.util.ArrayList;
   
   import org.apache.avalon.composition.data.ExcludeDirective;
  @@ -180,7 +181,70 @@
        * the base directory anchor and produces an array of files
        * to include in the classpath.
        */
  -    public void resolveFileset() throws IllegalStateException {
  +    public void resolveFileset() throws IOException, IllegalStateException {
  +/*        
  +
  +        // New stuff...
  +        DirectoryScanner ds = new DirectoryScanner();
  +
  +        // Supply the directory scanner with our base directory anchor
  +        ds.setBasedir( m_anchor );
  +        m_logger.debug( "ds.basedir=[" + ds.getBasedir() + "]" );
  +
  +        // Any default excludes to add?
  +        for (int i = 0; i < m_defaultExcludes.length; i++ )
  +        {
  +            ds.addDefaultExclude( m_defaultExcludes[i] );
  +        }
  +
  +        // Supply the directory scanner with our set of includes.
  +        // The scanner wants the includes in the form of String[],
  +        // but we have them in the form of IncludeDirective[].
  +        // So.. we need to first convert...
  +        String[] includes = new String[ m_includes.length ];
  +        if (m_includes.length == 0)
  +        {
  +            for (int i = 0; i < m_defaultIncludes.length; i++)
  +            {
  +                includes[i] = m_defaultIncludes[i];
  +            }
  +        }
  +        else
  +        {
  +            for (int i = 0; i < m_includes.length; i++ )
  +            {
  +                includes[i] = m_includes[i].getPath();
  +            }
  +        }
  +        ds.setIncludes( includes );
  +
  +        // Same thing for the set of excludes...
  +        String[] excludes = new String[ m_excludes.length ];
  +        for (int i = 0; i < m_excludes.length; i++ )
  +        {
  +            excludes[i] = m_excludes[i].getPath();
  +        }
  +        ds.setExcludes( excludes );
  +
  +
  +        // Make the scanner pay attention to filesystem case sensitivity
  +        ds.setCaseSensitive( true );
  +
  +        // Scan the directory (which doesn't do much right now) and output
  +        // some stuff to debug
  +        ds.scan();
  +        m_logger.debug( ds.toString() );
  +        String[] candidates = ds.getIncludedFiles();
  +        if ( candidates.length > 0 ) {
  +            for (int i = 0; i < candidates.length; i++) {
  +                File file = new File( m_anchor, candidates[i] );
  +                m_list.add( file );
  +            }
  +        } else {
  +            m_list.add( m_anchor );
  +        }
  +*/
  +        // Original stuff...
           if( m_includes.length > 0 ) {
               for( int j=0; j<m_includes.length; j++ ) {
                   File file = new File( m_anchor, m_includes[j].getPath() );
  
  
  
  1.4       +81 -5     
avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DirectoryScanner.java
  
  Index: DirectoryScanner.java
  ===================================================================
  RCS file: 
/home/cvs/avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DirectoryScanner.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DirectoryScanner.java     19 Apr 2004 18:13:09 -0000      1.3
  +++ DirectoryScanner.java     20 Apr 2004 00:03:32 -0000      1.4
  @@ -19,6 +19,7 @@
   
   import java.io.File;
   import java.io.IOException;
  +import java.util.Arrays;
   import java.util.Enumeration;
   import java.util.HashMap;
   import java.util.HashSet;
  @@ -41,7 +42,6 @@
    */
   public class DirectoryScanner {
   
  -    /** Is OpenVMS the operating system we're running on? */
       private static final boolean ON_VMS = Env.isOpenVMS();
       
       /**
  @@ -143,6 +143,9 @@
        */
       protected Vector dirsDeselected;
       
  +    /** Whether or not our results were built by a slow scan. */
  +    protected boolean haveSlowResults = false;
  +
       /**
        * Whether or not the file system should be treated as a case sensitive
        * one.
  @@ -218,6 +221,21 @@
        *                <code>null</code>.
        * @param str     The path to match, as a String. Must not be
        *                <code>null</code>.
  +     *
  +     * @return <code>true</code> if the pattern matches against the string,
  +     *         or <code>false</code> otherwise.
  +     */
  +    protected static boolean matchPath(String pattern, String str) {
  +        return ScannerUtils.matchPath(pattern, str);
  +    }
  +
  +    /**
  +     * Tests whether or not a given path matches a given pattern.
  +     *
  +     * @param pattern The pattern to match against. Must not be
  +     *                <code>null</code>.
  +     * @param str     The path to match, as a String. Must not be
  +     *                <code>null</code>.
        * @param isCaseSensitive Whether or not matching should be performed
        *                        case sensitively.
        *
  @@ -248,6 +266,28 @@
       }
   
       /**
  +     * Tests whether or not a string matches against a pattern.
  +     * The pattern may contain two special characters:<br>
  +     * '*' means zero or more characters<br>
  +     * '?' means one and only one character
  +     *
  +     * @param pattern The pattern to match against.
  +     *                Must not be <code>null</code>.
  +     * @param str     The string which must be matched against the pattern.
  +     *                Must not be <code>null</code>.
  +     * @param isCaseSensitive Whether or not matching should be performed
  +     *                        case sensitively.
  +     *
  +     *
  +     * @return <code>true</code> if the string matches against the pattern,
  +     *         or <code>false</code> otherwise.
  +     */
  +    protected static boolean match(String pattern, String str,
  +                                   boolean isCaseSensitive) {
  +        return ScannerUtils.match(pattern, str, isCaseSensitive);
  +    }
  +
  +    /**
        * Get the list of patterns that should be excluded by default.
        *
        * @return An array of <code>String</code> based on the current
  @@ -436,6 +476,27 @@
       }
   
       /**
  +     * Sets the selectors that will select the filelist.
  +     *
  +     * @param selectors specifies the selectors to be invoked on a scan
  +     */
  +    public void setSelectors(FileSelector[] selectors) {
  +        this.selectors = selectors;
  +    }
  +
  +
  +    /**
  +     * Returns whether or not the scanner has included all the files or
  +     * directories it has come across so far.
  +     *
  +     * @return <code>true</code> if all files and directories which have
  +     *         been found so far have been included.
  +     */
  +    public boolean isEverythingIncluded() {
  +        return everythingIncluded;
  +    }
  +
  +    /**
        * Scans the base directory for files which match at least one include
        * pattern and don't match any exclude patterns. If there are selectors
        * then the files must pass muster there, as well.
  @@ -614,7 +675,9 @@
        * @see #dirsExcluded
        * @see #slowScan
        */
  -    protected void scandir(File dir, String vpath, boolean fast) throws IOException 
{
  +    protected void scandir(File dir, String vpath, boolean fast)
  +        throws IOException
  +    {
           if (dir == null) {
               throw new IOException("dir must not be null.");
           } else if (!dir.exists()) {
  @@ -855,9 +918,22 @@
       }
   
       /**
  +     * Returns the names of the files which matched at least one of the
  +     * include patterns and none of the exclude patterns.
  +     * The names are relative to the base directory.
  +     *
  +     * @return the names of the files which matched at least one of the
  +     *         include patterns and none of the exclude patterns.
  +     */
  +    public String[] getIncludedFiles() {
  +        String[] files = new String[filesIncluded.size()];
  +        filesIncluded.copyInto(files);
  +        Arrays.sort(files);
  +        return files;
  +    }
  +
  +    /**
        * temporary table to speed up the various scanning methods below
  -     *
  -     * @since Ant 1.6
        */
       private Map fileListMap = new HashMap();
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to