sbailliez    02/02/24 04:11:04

  Modified:    src/java/org/apache/maven/importscrubber/filechooser
                        AllInDirectoryFileChooser.java
                        DualRootSingleFileChooser.java IFileChooser.java
                        RecursiveFileChooser.java SingleFileChooser.java
  Log:
  Apply Turbine coding style
  
  Revision  Changes    Path
  1.3       +34 -30    
jakarta-turbine-maven/src/java/org/apache/maven/importscrubber/filechooser/AllInDirectoryFileChooser.java
  
  Index: AllInDirectoryFileChooser.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/importscrubber/filechooser/AllInDirectoryFileChooser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AllInDirectoryFileChooser.java    21 Feb 2002 14:00:17 -0000      1.2
  +++ AllInDirectoryFileChooser.java    24 Feb 2002 12:11:03 -0000      1.3
  @@ -54,49 +54,53 @@
    * <http://www.apache.org/>.
    */
   
  -import org.apache.maven.importscrubber.Resources;
   import java.io.File;
   import java.util.ArrayList;
   import java.util.List;
   import java.util.ResourceBundle;
  +
   import org.apache.maven.importscrubber.FilePair;
   import org.apache.maven.importscrubber.ImportScrubber;
   import org.apache.maven.importscrubber.JavaFileFilter;
  +import org.apache.maven.importscrubber.Resources;
   
   /**
    * This class encapsulates a file chooser that gets everything in the indicated 
directory
    */
   public class AllInDirectoryFileChooser implements IFileChooser
   {
  -   private String _root;
  +    private String _root;
   
  -   public void setRoot(String root)
  -   {
  -      File file = new File(root);
  -      ResourceBundle res = 
ResourceBundle.getBundle("org.apache.maven.importscrubber.Resources");
  -      if (!file.isDirectory()) {
  -        throw new IllegalArgumentException(res.getString(Resources.ERR_NOT_DIR));
  -      }
  -      if (!file.exists()) {
  -        throw new IllegalArgumentException(Resources.ERR_DIR_NOT_EXIST);
  -      }
  -      _root = root;
  -   }
  +    public void setRoot(String root)
  +    {
  +        File file = new File(root);
  +        ResourceBundle res = 
ResourceBundle.getBundle("org.apache.maven.importscrubber.Resources");
  +        if (!file.isDirectory())
  +        {
  +            throw new 
IllegalArgumentException(res.getString(Resources.ERR_NOT_DIR));
  +        }
  +        if (!file.exists())
  +        {
  +            throw new IllegalArgumentException(Resources.ERR_DIR_NOT_EXIST);
  +        }
  +        _root = root;
  +    }
   
  -   public List getFiles()
  -   {
  -      File file = new File(_root);
  -      String[] sourceFiles = file.list(new JavaFileFilter());
  -      List list = new ArrayList(sourceFiles.length);
  -      for (int i=0; i<sourceFiles.length; i++)
  -      {
  -         File sourceFile = new File(_root + ImportScrubber.FILE_SEPARATOR + 
sourceFiles[i]);
  -         if (sourceFile.isDirectory()) {
  -            continue;
  -         }
  -         File destFile = new File(_root + ImportScrubber.FILE_SEPARATOR + 
sourceFiles[i].substring(0, sourceFiles[i].length()-5) + ".class");
  -         list.add(new FilePair(sourceFile, destFile));
  -      }
  -      return list;
  -   }
  +    public List getFiles()
  +    {
  +        File file = new File(_root);
  +        String[] sourceFiles = file.list(new JavaFileFilter());
  +        List list = new ArrayList(sourceFiles.length);
  +        for (int i = 0; i < sourceFiles.length; i++)
  +        {
  +            File sourceFile = new File(_root + ImportScrubber.FILE_SEPARATOR + 
sourceFiles[i]);
  +            if (sourceFile.isDirectory())
  +            {
  +                continue;
  +            }
  +            File destFile = new File(_root + ImportScrubber.FILE_SEPARATOR + 
sourceFiles[i].substring(0, sourceFiles[i].length() - 5) + ".class");
  +            list.add(new FilePair(sourceFile, destFile));
  +        }
  +        return list;
  +    }
   }
  
  
  
  1.3       +80 -75    
jakarta-turbine-maven/src/java/org/apache/maven/importscrubber/filechooser/DualRootSingleFileChooser.java
  
  Index: DualRootSingleFileChooser.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/importscrubber/filechooser/DualRootSingleFileChooser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DualRootSingleFileChooser.java    21 Feb 2002 14:00:17 -0000      1.2
  +++ DualRootSingleFileChooser.java    24 Feb 2002 12:11:03 -0000      1.3
  @@ -54,92 +54,97 @@
    * <http://www.apache.org/>.
    */
   
  -import org.apache.maven.importscrubber.Resources;
   import java.io.File;
  -import java.io.IOException;
   import java.util.ArrayList;
   import java.util.List;
   import java.util.ResourceBundle;
  +
   import org.apache.maven.importscrubber.FilePair;
   import org.apache.maven.importscrubber.ImportScrubber;
  +import org.apache.maven.importscrubber.Resources;
   
   /**
    * Encapsulates a file chooser that picks one file, but it takes the class and 
source file from different directories
    */
   public class DualRootSingleFileChooser implements IFileChooser
   {
  -  private String _sourcesRoot;
  -  private String _classesRoot;
  -  private String _sourceFilename;
  -
  -  public DualRootSingleFileChooser( String sourcesRoot,
  -                                    String classesRoot,
  -                                    String sourceFilename )
  -  {
  -    _sourcesRoot = sourcesRoot;
  -    _classesRoot = classesRoot;
  -    _sourceFilename = sourceFilename;
  -
  -    ResourceBundle res = 
ResourceBundle.getBundle("org.apache.maven.importscrubber.Resources");
  -    // Sanity check inputs
  -     File sourcesRootFile = new File(_sourcesRoot);
  -     if (!sourcesRootFile.isDirectory()) {
  -       throw new IllegalArgumentException(res.getString(Resources.ERR_NOT_DIR) + 
":" +_sourcesRoot);
  -     }
  -     File classesRootFile = new File(_classesRoot);
  -     if (!classesRootFile.isDirectory()) {
  -       throw new IllegalArgumentException(res.getString(Resources.ERR_NOT_DIR) + 
":" + _classesRoot);
  -     }
  -     File sourceFilenameFile = new File(_sourceFilename);
  -     if (sourceFilenameFile.isDirectory()) {
  -       throw new 
IllegalArgumentException(res.getString(Resources.ERR_MUST_NOT_BE_DIR) + 
_sourceFilename);
  -     }
  -     try
  -     {
  -       _sourceFilename = sourceFilenameFile.getCanonicalPath();
  -       _sourcesRoot = sourcesRootFile.getCanonicalPath();
  -       if( !_sourceFilename.startsWith( _sourcesRoot ) ) {
  -         throw new IllegalArgumentException("Input file '" + _sourceFilename + "' 
must be in a subdirectory of sourcesRoot: " + _sourcesRoot );
  -       }
  -     }
  -     catch( java.io.IOException e )
  -     {
  -         throw new IllegalArgumentException( e.toString() );
  -     }
  -  }
  -
  -   public void setRoot(String root)
  -   {
  -      throw new IllegalArgumentException("setRoot() is unused in this 
implementation of IFileChooser");
  -   }
  -
  -   public List getFiles()
  -   {
  -     File sourceFile = null;
  -
  -     try
  -     {
  -       sourceFile = new File(_sourceFilename).getCanonicalFile();
  -     }
  -     catch( java.io.IOException e )
  -     {
  -       throw new IllegalArgumentException( e.toString() );
  -     }
  -
  -     int relStart = _sourcesRoot.length();
  -     String relativeSourceFilename = sourceFile.getParent().substring( relStart );
  -
  -     String cfilename = sourceFile.getName().substring(0, 
sourceFile.getName().length()-5) + ".class";
  -     String classfilename = _classesRoot + relativeSourceFilename + 
ImportScrubber.FILE_SEPARATOR + cfilename;
  -     File classfile = new File( classfilename );
  -     if( !classfile.exists() ) {
  -        throw new IllegalArgumentException(Resources.ERR_CLASS_FILE_MUST_EXIST + 
classfilename);
  -     }
  -
  -     FilePair pair = new FilePair(sourceFile, classfile );
  -     List files = new ArrayList();
  -     files.add(pair);
  -     return files;
  -   }
  +    private String _sourcesRoot;
  +    private String _classesRoot;
  +    private String _sourceFilename;
  +
  +    public DualRootSingleFileChooser(String sourcesRoot,
  +                                     String classesRoot,
  +                                     String sourceFilename)
  +    {
  +        _sourcesRoot = sourcesRoot;
  +        _classesRoot = classesRoot;
  +        _sourceFilename = sourceFilename;
  +
  +        ResourceBundle res = 
ResourceBundle.getBundle("org.apache.maven.importscrubber.Resources");
  +        // Sanity check inputs
  +        File sourcesRootFile = new File(_sourcesRoot);
  +        if (!sourcesRootFile.isDirectory())
  +        {
  +            throw new IllegalArgumentException(res.getString(Resources.ERR_NOT_DIR) 
+ ":" + _sourcesRoot);
  +        }
  +        File classesRootFile = new File(_classesRoot);
  +        if (!classesRootFile.isDirectory())
  +        {
  +            throw new IllegalArgumentException(res.getString(Resources.ERR_NOT_DIR) 
+ ":" + _classesRoot);
  +        }
  +        File sourceFilenameFile = new File(_sourceFilename);
  +        if (sourceFilenameFile.isDirectory())
  +        {
  +            throw new 
IllegalArgumentException(res.getString(Resources.ERR_MUST_NOT_BE_DIR) + 
_sourceFilename);
  +        }
  +        try
  +        {
  +            _sourceFilename = sourceFilenameFile.getCanonicalPath();
  +            _sourcesRoot = sourcesRootFile.getCanonicalPath();
  +            if (!_sourceFilename.startsWith(_sourcesRoot))
  +            {
  +                throw new IllegalArgumentException("Input file '" + _sourceFilename 
+ "' must be in a subdirectory of sourcesRoot: " + _sourcesRoot);
  +            }
  +        }
  +        catch (java.io.IOException e)
  +        {
  +            throw new IllegalArgumentException(e.toString());
  +        }
  +    }
  +
  +    public void setRoot(String root)
  +    {
  +        throw new IllegalArgumentException("setRoot() is unused in this 
implementation of IFileChooser");
  +    }
  +
  +    public List getFiles()
  +    {
  +        File sourceFile = null;
  +
  +        try
  +        {
  +            sourceFile = new File(_sourceFilename).getCanonicalFile();
  +        }
  +        catch (java.io.IOException e)
  +        {
  +            throw new IllegalArgumentException(e.toString());
  +        }
  +
  +        int relStart = _sourcesRoot.length();
  +        String relativeSourceFilename = sourceFile.getParent().substring(relStart);
  +
  +        String cfilename = sourceFile.getName().substring(0, 
sourceFile.getName().length() - 5) + ".class";
  +        String classfilename = _classesRoot + relativeSourceFilename + 
ImportScrubber.FILE_SEPARATOR + cfilename;
  +        File classfile = new File(classfilename);
  +        if (!classfile.exists())
  +        {
  +            throw new IllegalArgumentException(Resources.ERR_CLASS_FILE_MUST_EXIST 
+ classfilename);
  +        }
  +
  +        FilePair pair = new FilePair(sourceFile, classfile);
  +        List files = new ArrayList();
  +        files.add(pair);
  +        return files;
  +    }
   
   }
  
  
  
  1.3       +8 -8      
jakarta-turbine-maven/src/java/org/apache/maven/importscrubber/filechooser/IFileChooser.java
  
  Index: IFileChooser.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/importscrubber/filechooser/IFileChooser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IFileChooser.java 21 Feb 2002 14:00:17 -0000      1.2
  +++ IFileChooser.java 24 Feb 2002 12:11:03 -0000      1.3
  @@ -61,13 +61,13 @@
    */
   public interface IFileChooser
   {
  -   /**
  -    * @return a List of FilePair objects
  -    */
  -   public List getFiles();
  +    /**
  +     * @return a List of FilePair objects
  +     */
  +    public List getFiles();
   
  -   /**
  -    * @param root the root of the file tree
  -    */
  -   public void setRoot(String root);
  +    /**
  +     * @param root the root of the file tree
  +     */
  +    public void setRoot(String root);
   }
  
  
  
  1.3       +39 -35    
jakarta-turbine-maven/src/java/org/apache/maven/importscrubber/filechooser/RecursiveFileChooser.java
  
  Index: RecursiveFileChooser.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/importscrubber/filechooser/RecursiveFileChooser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RecursiveFileChooser.java 21 Feb 2002 14:00:17 -0000      1.2
  +++ RecursiveFileChooser.java 24 Feb 2002 12:11:03 -0000      1.3
  @@ -54,55 +54,59 @@
    * <http://www.apache.org/>.
    */
   
  -import org.apache.maven.importscrubber.Resources;
   import java.io.File;
   import java.util.ArrayList;
   import java.util.List;
   import java.util.ResourceBundle;
  +
   import org.apache.maven.importscrubber.FilePair;
   import org.apache.maven.importscrubber.ImportScrubber;
   import org.apache.maven.importscrubber.JavaFileFilter;
  +import org.apache.maven.importscrubber.Resources;
   
   /**
    * Encapsulates a file chooser that recurses into subdirectories
    */
   public class RecursiveFileChooser implements IFileChooser
   {
  -   private String _root;
  +    private String _root;
   
  -   public void setRoot(String root)
  -   {
  -      File file = new File(root);
  -      ResourceBundle res = 
ResourceBundle.getBundle("org.apache.maven.importscrubber.Resources");
  -      if (!file.isDirectory()) {
  -        throw new IllegalArgumentException(Resources.ERR_NOT_DIR);
  -      }
  -      if (!file.exists()) {
  -        throw new IllegalArgumentException(Resources.ERR_DIR_NOT_EXIST);
  -      }
  -      _root = root;
  -   }
  +    public void setRoot(String root)
  +    {
  +        File file = new File(root);
  +        ResourceBundle res = 
ResourceBundle.getBundle("org.apache.maven.importscrubber.Resources");
  +        if (!file.isDirectory())
  +        {
  +            throw new IllegalArgumentException(Resources.ERR_NOT_DIR);
  +        }
  +        if (!file.exists())
  +        {
  +            throw new IllegalArgumentException(Resources.ERR_DIR_NOT_EXIST);
  +        }
  +        _root = root;
  +    }
   
  -   public List getFiles()
  -   {
  -      File root = new File(_root);
  -      List list = new ArrayList();
  -      scanDirectory(root, list);
  -      return list;
  -   }
  +    public List getFiles()
  +    {
  +        File root = new File(_root);
  +        List list = new ArrayList();
  +        scanDirectory(root, list);
  +        return list;
  +    }
   
  -   private void scanDirectory(File dir, List list)
  -   {
  -      String[] possibles = dir.list(new JavaFileFilter());
  -      for (int i=0; i<possibles.length; i++)
  -      {
  -         File tmp = new File(dir + ImportScrubber.FILE_SEPARATOR + possibles[i]);
  -         if (tmp.isDirectory()) {
  -            scanDirectory(tmp, list);
  -            continue;
  -         } 
  -         FilePair pair = new FilePair(new File(dir + ImportScrubber.FILE_SEPARATOR 
+ possibles[i]), new File(dir + ImportScrubber.FILE_SEPARATOR + 
possibles[i].substring(0, possibles[i].length()-5) + ".class"));
  -         list.add(pair);
  -      }
  -   }
  +    private void scanDirectory(File dir, List list)
  +    {
  +        String[] possibles = dir.list(new JavaFileFilter());
  +        for (int i = 0; i < possibles.length; i++)
  +        {
  +            File tmp = new File(dir + ImportScrubber.FILE_SEPARATOR + possibles[i]);
  +            if (tmp.isDirectory())
  +            {
  +                scanDirectory(tmp, list);
  +                continue;
  +            }
  +            FilePair pair = new FilePair(new File(dir + 
ImportScrubber.FILE_SEPARATOR + possibles[i]), new File(dir + 
ImportScrubber.FILE_SEPARATOR + possibles[i].substring(0, possibles[i].length() - 5) + 
".class"));
  +            list.add(pair);
  +        }
  +    }
   }
  
  
  
  1.3       +58 -51    
jakarta-turbine-maven/src/java/org/apache/maven/importscrubber/filechooser/SingleFileChooser.java
  
  Index: SingleFileChooser.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/importscrubber/filechooser/SingleFileChooser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SingleFileChooser.java    21 Feb 2002 14:00:17 -0000      1.2
  +++ SingleFileChooser.java    24 Feb 2002 12:11:03 -0000      1.3
  @@ -54,67 +54,74 @@
    * <http://www.apache.org/>.
    */
   
  -import org.apache.maven.importscrubber.Resources;
   import java.io.File;
   import java.util.ArrayList;
   import java.util.List;
   import java.util.ResourceBundle;
  +
   import org.apache.maven.importscrubber.FilePair;
  +import org.apache.maven.importscrubber.Resources;
   
   /**
    * Encapsulates a file chooser that only picks one file.
    */
   public class SingleFileChooser implements IFileChooser
   {
  -   private String _root;
  +    private String _root;
   
  -   public void setRoot(String root)
  -   {
  -      ResourceBundle res = 
ResourceBundle.getBundle("org.apache.maven.importscrubber.Resources");
  -      File file = new File(root);
  -      if (file.isDirectory()) {
  -        throw new 
IllegalArgumentException(res.getString(Resources.ERR_MUST_NOT_BE_DIR));
  -      }
  -
  -      File test = null;
  -      if (file.getName().endsWith(".java"))
  -      {
  -         test = new File(root);
  -      } else
  -      {
  -         test = new File(root + ".java");
  -      }
  -
  -      if (!test.exists()) {
  -        throw new IllegalArgumentException("Source file " + test.getAbsoluteFile()  
+ " doesn't exist!");
  -      }
  -
  -      if (file.getName().endsWith(".java"))
  -      {
  -         test = new File(root.substring(0, root.indexOf(".java")) + ".class");
  -      } else
  -      {
  -         test = new File(root + ".class");
  -      }
  -      if (!test.exists()) {
  -        throw new IllegalArgumentException("Class file " + test.getAbsoluteFile()  
+ " doesn't exist!");
  -      }
  -      
  -
  -      if (file.getName().endsWith(".java"))
  -      {
  -         _root = root.substring(0, root.indexOf(".java"));
  -      } else
  -      {
  -         _root = root;
  -      }
  -   }
  -
  -   public List getFiles()
  -   {
  -      FilePair pair = new FilePair(new File(_root + ".java"), new File(_root + 
".class"));
  -      List files = new ArrayList();
  -      files.add(pair);
  -      return files;
  -   }
  +    public void setRoot(String root)
  +    {
  +        ResourceBundle res = 
ResourceBundle.getBundle("org.apache.maven.importscrubber.Resources");
  +        File file = new File(root);
  +        if (file.isDirectory())
  +        {
  +            throw new 
IllegalArgumentException(res.getString(Resources.ERR_MUST_NOT_BE_DIR));
  +        }
  +
  +        File test = null;
  +        if (file.getName().endsWith(".java"))
  +        {
  +            test = new File(root);
  +        }
  +        else
  +        {
  +            test = new File(root + ".java");
  +        }
  +
  +        if (!test.exists())
  +        {
  +            throw new IllegalArgumentException("Source file " + 
test.getAbsoluteFile() + " doesn't exist!");
  +        }
  +
  +        if (file.getName().endsWith(".java"))
  +        {
  +            test = new File(root.substring(0, root.indexOf(".java")) + ".class");
  +        }
  +        else
  +        {
  +            test = new File(root + ".class");
  +        }
  +        if (!test.exists())
  +        {
  +            throw new IllegalArgumentException("Class file " + 
test.getAbsoluteFile() + " doesn't exist!");
  +        }
  +
  +
  +        if (file.getName().endsWith(".java"))
  +        {
  +            _root = root.substring(0, root.indexOf(".java"));
  +        }
  +        else
  +        {
  +            _root = root;
  +        }
  +    }
  +
  +    public List getFiles()
  +    {
  +        FilePair pair = new FilePair(new File(_root + ".java"), new File(_root + 
".class"));
  +        List files = new ArrayList();
  +        files.add(pair);
  +        return files;
  +    }
   }
  
  
  

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

Reply via email to