Hi,

This is the first patch of the looong process of refactoring the
setX()/createX() and setX()/addX() method pairs into a single setX() or
addX() method.  I've started with Path, to get rid of some its inertia.


Adam
Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Available.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Available.java,v
retrieving revision 1.16
diff -u -r1.16 Available.java
--- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Available.java     
15 Jan 2002 09:51:07 -0000      1.16
+++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Available.java     
16 Jan 2002 12:10:51 -0000
@@ -48,10 +48,20 @@
         }
     }
 
-    public void setClasspath( Path classpath )
+    /**
+     * Adds a classpath element.
+     */
+    public void addClasspath( Path classpath )
         throws TaskException
     {
-        createClasspath().append( classpath );
+        if ( m_classpath == null )
+        {
+            m_classpath = classpath;
+        }
+        else
+        {
+            m_classpath.addPath(classpath);
+        }
     }
 
     public void setFile( String file )
@@ -59,12 +69,6 @@
         m_file = file;
     }
 
-    public void setFilepath( Path filepath )
-        throws TaskException
-    {
-        createFilepath().append( filepath );
-    }
-
     public void setProperty( String property )
     {
         m_property = property;
@@ -85,30 +89,20 @@
         m_value = value;
     }
 
-    public Path createClasspath()
+    /**
+     * Adds a file search path element.
+     */
+    public void addFilepath( Path path )
         throws TaskException
     {
-        if( m_classpath == null )
+        if( m_filepath == null )
         {
-            m_classpath = new Path();
+            m_filepath = path;
         }
-        Path path1 = m_classpath;
-        final Path path = new Path();
-        path1.addPath( path );
-        return path;
-    }
-
-    public Path createFilepath()
-        throws TaskException
-    {
-        if( m_filepath == null )
+        else
         {
-            m_filepath = new Path();
+            m_filepath.addPath( path );
         }
-        Path path1 = m_filepath;
-        final Path path = new Path();
-        path1.addPath( path );
-        return path;
     }
 
     public boolean eval()
Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java,v
retrieving revision 1.22
diff -u -r1.22 Java.java
--- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java  15 Jan 
2002 09:51:07 -0000      1.22
+++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java  16 Jan 
2002 12:10:51 -0000
@@ -45,12 +45,12 @@
     }
 
     /**
-     * Set the classpath to be used for this compilation.
+     * Add a classpath element.
      */
-    public void setClasspath( final Path classpath )
+    public void addClasspath( final Path classpath )
         throws TaskException
     {
-        createClasspath().append( classpath );
+        m_cmdl.createClasspath().addPath( classpath );
     }
 
     /**
@@ -109,18 +109,6 @@
     public Argument createArg()
     {
         return m_cmdl.createArgument();
-    }
-
-    /**
-     * Creates a nested classpath element
-     */
-    public Path createClasspath()
-        throws TaskException
-    {
-        Path path1 = m_cmdl.createClasspath();
-        final Path path = new Path();
-        path1.addPath( path );
-        return path;
     }
 
     /**
Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java,v
retrieving revision 1.24
diff -u -r1.24 Javac.java
--- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java 15 Jan 
2002 09:51:07 -0000      1.24
+++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java 16 Jan 
2002 12:10:52 -0000
@@ -88,11 +88,12 @@
     private String target;
 
     /**
-     * Sets the bootclasspath that will be used to compile the classes against.
+     * Adds an element to the bootclasspath that will be used to compile the
+     * classes against.
      *
      * @param bootclasspath The new Bootclasspath value
      */
-    public void setBootclasspath( Path bootclasspath )
+    public void addBootclasspath( Path bootclasspath )
         throws TaskException
     {
         if( this.bootclasspath == null )
@@ -101,16 +102,16 @@
         }
         else
         {
-            this.bootclasspath.append( bootclasspath );
+            this.bootclasspath.addPath( bootclasspath );
         }
     }
 
     /**
-     * Set the classpath to be used for this compilation.
+     * Adds an element to the classpath to be used for this compilation.
      *
      * @param classpath The new Classpath value
      */
-    public void setClasspath( Path classpath )
+    public void addClasspath( Path classpath )
         throws TaskException
     {
         if( compileClasspath == null )
@@ -119,7 +120,7 @@
         }
         else
         {
-            compileClasspath.append( classpath );
+            compileClasspath.addPath( classpath );
         }
     }
 
@@ -185,11 +186,12 @@
     }
 
     /**
-     * Sets the extension directories that will be used during the compilation.
+     * Adds an element to the extension directories that will be used during
+     * the compilation.
      *
      * @param extdirs The new Extdirs value
      */
-    public void setExtdirs( Path extdirs )
+    public void addExtdirs( Path extdirs )
         throws TaskException
     {
         if( this.extdirs == null )
@@ -198,7 +200,7 @@
         }
         else
         {
-            this.extdirs.append( extdirs );
+            this.extdirs.addPath( extdirs );
         }
     }
 
@@ -322,11 +324,11 @@
     }
 
     /**
-     * Set the source dirs to find the source Java files.
+     * Adds an element to the source dirs to find the source Java files.
      *
      * @param srcDir The new Srcdir value
      */
-    public void setSrcdir( Path srcDir )
+    public void addSrcdir( Path srcDir )
         throws TaskException
     {
         if( src == null )
@@ -335,7 +337,7 @@
         }
         else
         {
-            src.append( srcDir );
+            src.addPath( srcDir );
         }
     }
 
@@ -631,42 +633,6 @@
     }
 
     /**
-     * Maybe creates a nested classpath element.
-     *
-     * @return Description of the Returned Value
-     */
-    public Path createBootclasspath()
-        throws TaskException
-    {
-        if( bootclasspath == null )
-        {
-            bootclasspath = new Path();
-        }
-        Path path1 = bootclasspath;
-        final Path path = new Path();
-        path1.addPath( path );
-        return path;
-    }
-
-    /**
-     * Maybe creates a nested classpath element.
-     *
-     * @return Description of the Returned Value
-     */
-    public Path createClasspath()
-        throws TaskException
-    {
-        if( compileClasspath == null )
-        {
-            compileClasspath = new Path();
-        }
-        Path path1 = compileClasspath;
-        final Path path = new Path();
-        path1.addPath( path );
-        return path;
-    }
-
-    /**
      * Adds an implementation specific command line argument.
      *
      * @return Description of the Returned Value
@@ -677,42 +643,6 @@
             new ImplementationSpecificArgument();
         implementationSpecificArgs.add( arg );
         return arg;
-    }
-
-    /**
-     * Maybe creates a nested classpath element.
-     *
-     * @return Description of the Returned Value
-     */
-    public Path createExtdirs()
-        throws TaskException
-    {
-        if( extdirs == null )
-        {
-            extdirs = new Path();
-        }
-        Path path1 = extdirs;
-        final Path path = new Path();
-        path1.addPath( path );
-        return path;
-    }
-
-    /**
-     * Create a nested src element for multiple source path support.
-     *
-     * @return a nested src element.
-     */
-    public Path createSrc()
-        throws TaskException
-    {
-        if( src == null )
-        {
-            src = new Path();
-        }
-        Path path1 = src;
-        final Path path = new Path();
-        path1.addPath( path );
-        return path;
     }
 
     /**
Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/PathConvert.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/PathConvert.java,v
retrieving revision 1.11
diff -u -r1.11 PathConvert.java
--- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/PathConvert.java   
15 Jan 2002 09:51:07 -0000      1.11
+++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/PathConvert.java   
16 Jan 2002 12:10:53 -0000
@@ -96,19 +96,19 @@
     }
 
     /**
-     * Create a nested PATH element
+     * Adds a PATH element
      */
-    public Path createPath()
+    public void addPath( Path path )
         throws TaskException
     {
         if( m_path == null )
         {
-            m_path = new Path();
+            m_path = path;
+        }
+        else
+        {
+            m_path.addPath( path );
         }
-        Path path1 = m_path;
-        final Path path = new Path();
-        path1.addPath( path );
-        return path;
     }
 
     public void execute()
Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Property.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Property.java,v
retrieving revision 1.24
diff -u -r1.24 Property.java
--- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Property.java      
15 Jan 2002 09:51:07 -0000      1.24
+++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Property.java      
16 Jan 2002 12:10:53 -0000
@@ -35,7 +35,7 @@
     private String m_resource;
     private String m_value;
 
-    public void setClasspath( Path classpath )
+    public void addClasspath( Path classpath )
         throws TaskException
     {
         if( m_classpath == null )
@@ -44,7 +44,7 @@
         }
         else
         {
-            m_classpath.append( classpath );
+            m_classpath.addPath( classpath );
         }
     }
 
@@ -66,19 +66,6 @@
     public void setValue( String value )
     {
         m_value = value;
-    }
-
-    public Path createClasspath()
-        throws TaskException
-    {
-        if( m_classpath == null )
-        {
-            m_classpath = new Path();
-        }
-        Path path1 = m_classpath;
-        final Path path = new Path();
-        path1.addPath( path );
-        return path;
     }
 
     public void execute()
Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java,v
retrieving revision 1.22
diff -u -r1.22 Rmic.java
--- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java  15 Jan 
2002 09:51:07 -0000      1.22
+++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java  16 Jan 
2002 12:10:55 -0000
@@ -102,11 +102,11 @@
     }
 
     /**
-     * Set the classpath to be used for this compilation.
+     * Add an element to the classpath to be used for this compilation.
      *
      * @param classpath The new Classpath value
      */
-    public void setClasspath( Path classpath )
+    public void addClasspath( Path classpath )
         throws TaskException
     {
         if( compileClasspath == null )
@@ -115,7 +115,7 @@
         }
         else
         {
-            compileClasspath.append( classpath );
+            compileClasspath.addPath( classpath );
         }
     }
 
@@ -130,11 +130,12 @@
     }
 
     /**
-     * Sets the extension directories that will be used during the compilation.
+     * Adds an element to the extension directories that will be used during
+     * the compilation.
      *
      * @param extdirs The new Extdirs value
      */
-    public void setExtdirs( Path extdirs )
+    public void addExtdirs( Path extdirs )
         throws TaskException
     {
         if( this.extdirs == null )
@@ -143,7 +144,7 @@
         }
         else
         {
-            this.extdirs.append( extdirs );
+            this.extdirs.addPath( extdirs );
         }
     }
 
@@ -457,42 +458,6 @@
         }
         // we only get here if an exception has been thrown
         return false;
-    }
-
-    /**
-     * Creates a nested classpath element.
-     *
-     * @return Description of the Returned Value
-     */
-    public Path createClasspath()
-        throws TaskException
-    {
-        if( compileClasspath == null )
-        {
-            compileClasspath = new Path();
-        }
-        Path path1 = compileClasspath;
-        final Path path = new Path();
-        path1.addPath( path );
-        return path;
-    }
-
-    /**
-     * Maybe creates a nested extdirs element.
-     *
-     * @return Description of the Returned Value
-     */
-    public Path createExtdirs()
-        throws TaskException
-    {
-        if( extdirs == null )
-        {
-            extdirs = new Path();
-        }
-        Path path1 = extdirs;
-        final Path path = new Path();
-        path1.addPath( path );
-        return path;
     }
 
     public void execute()
Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SQLExec.java,v
retrieving revision 1.19
diff -u -r1.19 SQLExec.java
--- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SQLExec.java       
15 Jan 2002 09:51:07 -0000      1.19
+++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SQLExec.java       
16 Jan 2002 12:10:56 -0000
@@ -162,11 +162,11 @@
     }
 
     /**
-     * Set the classpath for loading the driver.
+     * Adds an element to the classpath for loading the driver.
      *
      * @param classpath The new Classpath value
      */
-    public void setClasspath( Path classpath )
+    public void addClasspath( Path classpath )
         throws TaskException
     {
         if( this.classpath == null )
@@ -175,7 +175,7 @@
         }
         else
         {
-            this.classpath.append( classpath );
+            this.classpath.addPath( classpath );
         }
     }
 
@@ -343,24 +343,6 @@
     public void addContent( String sql )
     {
         this.sqlCommand += sql;
-    }
-
-    /**
-     * Create the classpath for loading the driver.
-     *
-     * @return Description of the Returned Value
-     */
-    public Path createClasspath()
-        throws TaskException
-    {
-        if( this.classpath == null )
-        {
-            this.classpath = new Path();
-        }
-        Path path1 = this.classpath;
-        final Path path = new Path();
-        path1.addPath( path );
-        return path;
     }
 
     /**
Index: 
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandGenerateClient.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandGenerateClient.java,v
retrieving revision 1.14
diff -u -r1.14 BorlandGenerateClient.java
--- 
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandGenerateClient.java
    15 Jan 2002 09:51:08 -0000      1.14
+++ 
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandGenerateClient.java
    16 Jan 2002 12:10:57 -0000
@@ -215,7 +215,7 @@
             //classpath
             //add at the end of the classpath
             //the system classpath in order to find the tools.jar file
-            execTask.setClasspath( classpath.concatSystemClasspath() );
+            execTask.addClasspath( classpath.concatSystemClasspath() );
 
             execTask.setFork( true );
             execTask.createArg().setValue( "generateclient" );
Index: 
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java,v
retrieving revision 1.15
diff -u -r1.15 WLJspc.java
--- 
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java
   12 Jan 2002 23:52:15 -0000      1.15
+++ 
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java
   16 Jan 2002 12:10:59 -0000
@@ -229,7 +229,7 @@
 
             //helperTask.clearArgs();
             helperTask.createArg().setValue( arg );
-            helperTask.setClasspath( compileClasspath );
+            helperTask.addClasspath( compileClasspath );
             if( helperTask.executeJava() != 0 )
             {
                 getLogger().warn( files[ i ] + " failed to compile" );
Index: 
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java,v
retrieving revision 1.7
diff -u -r1.7 JasperC.java
--- 
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java
        12 Jan 2002 05:01:23 -0000      1.7
+++ 
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java
        16 Jan 2002 12:10:59 -0000
@@ -37,7 +37,7 @@
             //FIXME
             Java java = null;//(Java)( getJspc().getProject() ).createTask( 
"java" );
             if( getJspc().getClasspath() != null )
-                java.setClasspath( getJspc().getClasspath() );
+                java.addClasspath( getJspc().getClasspath() );
             java.setClassname( "org.apache.jasper.JspC" );
             String args[] = cmd.getArguments();
             for( int i = 0; i < args.length; i++ )

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

Reply via email to