From 2bb0b8b340ce431f8f949951079aa5c57a8a2add Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Sat, 22 Dec 2001 22:01:58 +0000 Subject: [PATCH] Moved Commandline.Argument/Marker to top level classes. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270322 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/taskdefs/ExecuteOn.java | 9 +- .../org/apache/tools/ant/taskdefs/Java.java | 5 +- .../org/apache/tools/ant/taskdefs/Javac.java | 3 +- .../tools/ant/taskdefs/exec/ExecTask.java | 3 +- .../tools/ant/taskdefs/optional/ANTLR.java | 3 +- .../optional/ejb/BorlandDeploymentTool.java | 3 +- .../ant/taskdefs/optional/ejb/DDCreator.java | 3 +- .../tools/ant/taskdefs/optional/ejb/Ejbc.java | 3 +- .../optional/ejb/WebsphereDeploymentTool.java | 3 +- .../ant/taskdefs/optional/javacc/JJTree.java | 3 +- .../ant/taskdefs/optional/javacc/JavaCC.java | 3 +- .../optional/jdepend/JDependTask.java | 3 +- .../taskdefs/optional/junit/JUnitTask.java | 3 +- .../metamata/AbstractMetamataTask.java | 7 +- .../taskdefs/optional/metamata/MParse.java | 7 +- .../taskdefs/optional/sitraka/Coverage.java | 5 +- .../org/apache/tools/ant/types/Argument.java | 72 ++++++++++ .../apache/tools/ant/types/Commandline.java | 125 ++---------------- .../tools/ant/types/CommandlineJava.java | 4 +- .../tools/ant/types/EnvironmentData.java | 1 - .../org/apache/tools/ant/types/Marker.java | 53 ++++++++ .../apache/tools/ant/taskdefs/ExecuteOn.java | 9 +- .../org/apache/tools/ant/taskdefs/Java.java | 5 +- .../org/apache/tools/ant/taskdefs/Javac.java | 3 +- .../tools/ant/taskdefs/exec/ExecTask.java | 3 +- .../tools/ant/taskdefs/optional/ANTLR.java | 3 +- .../optional/ejb/BorlandDeploymentTool.java | 3 +- .../ant/taskdefs/optional/ejb/DDCreator.java | 3 +- .../tools/ant/taskdefs/optional/ejb/Ejbc.java | 3 +- .../optional/ejb/WebsphereDeploymentTool.java | 3 +- .../ant/taskdefs/optional/javacc/JJTree.java | 3 +- .../ant/taskdefs/optional/javacc/JavaCC.java | 3 +- .../optional/jdepend/JDependTask.java | 3 +- .../taskdefs/optional/junit/JUnitTask.java | 3 +- .../metamata/AbstractMetamataTask.java | 7 +- .../taskdefs/optional/metamata/MParse.java | 7 +- .../taskdefs/optional/sitraka/Coverage.java | 5 +- .../org/apache/tools/ant/types/Argument.java | 72 ++++++++++ .../apache/tools/ant/types/Commandline.java | 125 ++---------------- .../tools/ant/types/CommandlineJava.java | 4 +- .../tools/ant/types/EnvironmentData.java | 1 - .../org/apache/tools/ant/types/Marker.java | 53 ++++++++ 42 files changed, 358 insertions(+), 284 deletions(-) create mode 100644 proposal/myrmidon/src/main/org/apache/tools/ant/types/Argument.java create mode 100644 proposal/myrmidon/src/main/org/apache/tools/ant/types/Marker.java create mode 100644 proposal/myrmidon/src/todo/org/apache/tools/ant/types/Argument.java create mode 100644 proposal/myrmidon/src/todo/org/apache/tools/ant/types/Marker.java 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 344d78c60..1c86274a9 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 @@ -20,6 +20,7 @@ import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.Mapper; +import org.apache.tools.ant.types.Marker; import org.apache.tools.ant.util.FileNameMapper; import org.apache.tools.ant.util.SourceFileScanner; @@ -36,9 +37,9 @@ public class ExecuteOn extends ExecTask private boolean relative = false; private boolean parallel = false; protected String type = "file"; - protected Commandline.Marker srcFilePos = null; + protected Marker srcFilePos = null; private boolean skipEmpty = false; - protected Commandline.Marker targetFilePos = null; + protected Marker targetFilePos = null; protected Mapper mapperElement = null; protected FileNameMapper mapper = null; protected File destDir = null; @@ -132,7 +133,7 @@ public class ExecuteOn extends ExecTask * * @return Description of the Returned Value */ - public Commandline.Marker createSrcfile() + public Marker createSrcfile() throws TaskException { if( srcFilePos != null ) @@ -149,7 +150,7 @@ public class ExecuteOn extends ExecTask * * @return Description of the Returned Value */ - public Commandline.Marker createTargetfile() + public Marker createTargetfile() throws TaskException { if( targetFilePos != null ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java index f95200d5c..7b3f2e36b 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java @@ -24,6 +24,7 @@ import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.types.EnvironmentVariable; +import org.apache.tools.ant.types.Argument; /** * This task acts as a loader for java applications but allows to use the same @@ -185,7 +186,7 @@ public class Java extends Task * * @return Description of the Returned Value */ - public Commandline.Argument createArg() + public Argument createArg() { return cmdl.createArgument(); } @@ -206,7 +207,7 @@ public class Java extends Task * * @return Description of the Returned Value */ - public Commandline.Argument createJvmarg() + public Argument createJvmarg() { return cmdl.createVmArgument(); } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java index 473c59c39..1f641e7ce 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java @@ -19,6 +19,7 @@ import org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; +import org.apache.tools.ant.types.Argument; import org.apache.tools.ant.util.GlobPatternMapper; import org.apache.tools.ant.util.SourceFileScanner; @@ -914,7 +915,7 @@ public class Javac extends MatchingTask * @author RT */ public class ImplementationSpecificArgument - extends Commandline.Argument + extends Argument { private String impl; diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecTask.java index a2253b448..6b04016dd 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecTask.java @@ -22,6 +22,7 @@ import org.apache.tools.ant.Task; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.EnvironmentVariable; +import org.apache.tools.ant.types.Argument; /** * Executes a given command if the os platform is appropriate. @@ -186,7 +187,7 @@ public class ExecTask extends Task * * @return Description of the Returned Value */ - public Commandline.Argument createArg() + public Argument createArg() { return cmdl.createArgument(); } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java index 53280ce12..ecb7cf222 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java @@ -21,6 +21,7 @@ import org.apache.tools.ant.taskdefs.exec.LogStreamHandler; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Argument; /** * ANTLR task. @@ -104,7 +105,7 @@ public class ANTLR extends Task * the JVM. * @see #setFork(boolean) */ - public Commandline.Argument createJvmarg() + public Argument createJvmarg() { return commandline.createVmArgument(); } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java index e5ff74888..bab295fda 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java @@ -23,6 +23,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute; import org.apache.tools.ant.taskdefs.exec.ExecuteStreamHandler; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Argument; /** * BorlandDeploymentTool is dedicated to the Borland Application Server 4.5 and @@ -491,7 +492,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exec javaTask = (Java)getTask().getProject().createTask( "java" ); javaTask.setClassname( VERIFY ); - Commandline.Argument arguments = javaTask.createArg(); + Argument arguments = javaTask.createArg(); arguments.setLine( args ); Path classpath = getCombinedClasspath(); if( classpath != null ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DDCreator.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DDCreator.java index 3c9e44064..bcb46a530 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DDCreator.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DDCreator.java @@ -14,6 +14,7 @@ import org.apache.tools.ant.taskdefs.Java; import org.apache.tools.ant.taskdefs.MatchingTask; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Argument; /** * Build a serialised deployment descriptor given a text file description of the @@ -122,7 +123,7 @@ public class DDCreator extends MatchingTask Java ddCreatorTask = (Java)getProject().createTask( "java" ); ddCreatorTask.setFork( true ); ddCreatorTask.setClassname( "org.apache.tools.ant.taskdefs.optional.ejb.DDCreatorHelper" ); - Commandline.Argument arguments = ddCreatorTask.createArg(); + Argument arguments = ddCreatorTask.createArg(); arguments.setLine( args ); ddCreatorTask.setClasspath( new Path( getProject(), execClassPath ) ); if( ddCreatorTask.executeJava() != 0 ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/Ejbc.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/Ejbc.java index 83c11e814..7fd8bbb74 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/Ejbc.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/Ejbc.java @@ -14,6 +14,7 @@ import org.apache.tools.ant.taskdefs.Java; import org.apache.tools.ant.taskdefs.MatchingTask; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Argument; /** * Build EJB support classes using Weblogic's ejbc tool from a directory @@ -181,7 +182,7 @@ public class Ejbc extends MatchingTask args += " " + files[ i ]; } - Commandline.Argument arguments = helperTask.createArg(); + Argument arguments = helperTask.createArg(); arguments.setLine( args ); helperTask.setClasspath( new Path( getProject(), execClassPath ) ); if( helperTask.executeJava() != 0 ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java index 07ba2f48c..354cba773 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java @@ -25,6 +25,7 @@ import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.EnvironmentVariable; +import org.apache.tools.ant.types.Argument; /** * Websphere deployment tool that augments the ejbjar task. @@ -982,7 +983,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool // Set the Java class name javaTask.setClassname( "com.ibm.etools.ejbdeploy.EJBDeploy" ); - Commandline.Argument arguments = javaTask.createArg(); + Argument arguments = javaTask.createArg(); arguments.setLine( args ); Path classpath = wasClasspath; if( classpath == null ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java index fdc46a7fe..3dac2cd0b 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java @@ -19,6 +19,7 @@ import org.apache.tools.ant.taskdefs.exec.LogStreamHandler; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Argument; /** * Taskdef for the JJTree compiler compiler. @@ -180,7 +181,7 @@ public class JJTree extends Task "/JavaCC.zip" ); classpath.addJavaRuntime(); - final Commandline.Argument arg = cmdl.createVmArgument(); + final Argument arg = cmdl.createVmArgument(); arg.setValue( "-mx140M" ); arg.setValue( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java index c36fe7688..850187637 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java @@ -17,6 +17,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Argument; /** * Taskdef for the JavaCC compiler compiler. @@ -230,7 +231,7 @@ public class JavaCC extends Task "/JavaCC.zip" ); classpath.addJavaRuntime(); - final Commandline.Argument arg = cmdl.createVmArgument(); + final Argument arg = cmdl.createVmArgument(); arg.setValue( "-mx140M" ); arg.setValue( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java index 2ccb3947d..fa5bc118f 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java @@ -23,6 +23,7 @@ import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; +import org.apache.tools.ant.types.Argument; /** * Ant task to run JDepend tests.

@@ -219,7 +220,7 @@ public class JDependTask extends Task * the JVM. * @see #setFork(boolean) */ - public Commandline.Argument createJvmarg( CommandlineJava commandline ) + public Argument createJvmarg( CommandlineJava commandline ) { return commandline.createVmArgument(); } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index ade21f89b..49156097a 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -31,6 +31,7 @@ import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.EnvironmentVariable; +import org.apache.tools.ant.types.Argument; /** * Ant task to run JUnit tests.

@@ -367,7 +368,7 @@ public class JUnitTask extends Task * the JVM. * @see #setFork(boolean) */ - public Commandline.Argument createJvmarg() + public Argument createJvmarg() { return commandline.createVmArgument(); } 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 d75b37424..794a1e8fe 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 @@ -25,6 +25,7 @@ import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Argument; /** * Somewhat abstract framework to be used for other metama 2.0 tasks. This @@ -169,7 +170,7 @@ public abstract class AbstractMetamataTask extends Task * * @return Description of the Returned Value */ - public Commandline.Argument createJvmarg() + public Argument createJvmarg() { return cmdl.createVmArgument(); } @@ -226,7 +227,7 @@ public abstract class AbstractMetamataTask extends Task classPath.createPathElement().setLocation( jar ); // set the metamata.home property - final Commandline.Argument vmArgs = cmdl.createVmArgument(); + final Argument vmArgs = cmdl.createVmArgument(); vmArgs.setValue( "-Dmetamata.home=" + metamataHome.getAbsolutePath() ); // retrieve all the files we want to scan @@ -237,7 +238,7 @@ public abstract class AbstractMetamataTask extends Task ArrayList options = getOptions(); optionsFile = createTmpFile(); generateOptionsFile( optionsFile, options ); - Commandline.Argument args = cmdl.createArgument(); + Argument args = cmdl.createArgument(); args.setLine( "-arguments " + optionsFile.getAbsolutePath() ); } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java index 2b8e5d8f4..eee34a457 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java @@ -22,6 +22,7 @@ import org.apache.tools.ant.taskdefs.exec.LogStreamHandler; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Argument; /** * Simple Metamata MParse task based on the original written by 0 ) { @@ -206,11 +205,11 @@ public class Commandline * * @param executable The new Executable value */ - public void setExecutable( String executable ) + public void setExecutable( final String executable ) { if( executable == null || executable.length() == 0 ) return; - this.m_executable = executable.replace( '/', File.separatorChar ) + m_executable = executable.replace( '/', File.separatorChar ) .replace( '\\', File.separatorChar ); } @@ -222,11 +221,12 @@ public class Commandline */ public String[] getArguments() { - ArrayList result = new ArrayList( m_arguments.size() * 2 ); - for( int i = 0; i < m_arguments.size(); i++ ) + final int size = m_arguments.size(); + final ArrayList result = new ArrayList( size * 2 ); + for( int i = 0; i < size; i++ ) { - Argument arg = (Argument)m_arguments.get( i ); - String[] s = arg.getParts(); + final Argument arg = (Argument)m_arguments.get( i ); + final String[] s = arg.getParts(); for( int j = 0; j < s.length; j++ ) { result.add( s[ j ] ); @@ -246,7 +246,9 @@ public class Commandline { final String[] args = getArguments(); if( m_executable == null ) + { return args; + } final String[] result = new String[ args.length + 1 ]; result[ 0 ] = m_executable; System.arraycopy( args, 0, result, 1, args.length ); @@ -315,7 +317,7 @@ public class Commandline */ public Marker createMarker() { - return new Marker( m_arguments.size() ); + return new Marker( this, m_arguments.size() ); } public int size() @@ -328,109 +330,4 @@ public class Commandline return toString( getCommandline() ); } - /** - * Used for nested xml command line definitions. - * - * @author RT - */ - public static class Argument - { - - private String[] parts; - - /** - * Sets a single commandline argument to the absolute filename of the - * given file. - * - * @param value a single commandline argument. - */ - public void setFile( File value ) - { - parts = new String[]{value.getAbsolutePath()}; - } - - /** - * Line to split into several commandline arguments. - * - * @param line line to split into several commandline arguments - */ - public void setLine( String line ) - throws TaskException - { - parts = translateCommandline( line ); - } - - /** - * Sets a single commandline argument and treats it like a PATH - - * ensures the right separator for the local platform is used. - * - * @param value a single commandline argument. - */ - public void setPath( Path value ) - { - parts = new String[]{value.toString()}; - } - - /** - * Sets a single commandline argument. - * - * @param value a single commandline argument. - */ - public void setValue( String value ) - { - parts = new String[]{value}; - } - - /** - * Returns the parts this Argument consists of. - * - * @return The Parts value - */ - public String[] getParts() - { - return parts; - } - } - - /** - * Class to keep track of the position of an Argument. - * - * @author RT - */ - //

This class is there to support the srcfile and targetfile - // elements of <execon> and <transform> - don't know - // whether there might be additional use cases.

--SB - public class Marker - { - private int realPos = -1; - - private int position; - - Marker( int position ) - { - this.position = position; - } - - /** - * Return the number of arguments that preceeded this marker.

- * - * The name of the executable - if set - is counted as the very first - * argument.

- * - * @return The Position value - */ - public int getPosition() - { - if( realPos == -1 ) - { - realPos = ( m_executable == null ? 0 : 1 ); - for( int i = 0; i < position; i++ ) - { - Argument arg = (Argument)m_arguments.get( i ); - realPos += arg.getParts().length; - } - } - return realPos; - } - } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/CommandlineJava.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/CommandlineJava.java index 75f014581..3850a217a 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/CommandlineJava.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/CommandlineJava.java @@ -218,7 +218,7 @@ public class CommandlineJava implements Cloneable return c; } - public Commandline.Argument createArgument() + public Argument createArgument() { return javaCommand.createArgument(); } @@ -232,7 +232,7 @@ public class CommandlineJava implements Cloneable return classpath; } - public Commandline.Argument createVmArgument() + public Argument createVmArgument() { return vmCommand.createArgument(); } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/EnvironmentData.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/EnvironmentData.java index 9dc427a3b..0516352a4 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/EnvironmentData.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/EnvironmentData.java @@ -38,5 +38,4 @@ public class EnvironmentData { m_variables.add( var ); } - } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/Marker.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/Marker.java new file mode 100644 index 000000000..a1a5703a8 --- /dev/null +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/Marker.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) The Apache Software Foundation. All rights reserved. + * + * This software is published under the terms of the Apache Software License + * version 1.1, a copy of which has been included with this distribution in + * the LICENSE.txt file. + */ +package org.apache.tools.ant.types; + +import java.util.ArrayList; + +/** + * Class to keep track of the position of an Argument. + * + *

This class is there to support the srcfile and targetfile + * elements of <execon> and <transform> - don't know + * whether there might be additional use cases.

--SB + */ +public class Marker +{ + private int m_realPos = -1; + private int m_position; + private Commandline m_commandline; + + Marker( Commandline commandline, int position ) + { + m_commandline = commandline; + m_position = position; + } + + /** + * Return the number of arguments that preceeded this marker.

+ * + * The name of the executable - if set - is counted as the very first + * argument.

+ * + * @return The Position value + */ + public int getPosition() + { + if( m_realPos == -1 ) + { + m_realPos = ( m_commandline.getExecutable() == null ? 0 : 1 ); + final ArrayList arguments = m_commandline.m_arguments; + for( int i = 0; i < m_position; i++ ) + { + final Argument arg = (Argument)arguments.get( i ); + m_realPos += arg.getParts().length; + } + } + return m_realPos; + } +} 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 344d78c60..1c86274a9 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 @@ -20,6 +20,7 @@ import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.Mapper; +import org.apache.tools.ant.types.Marker; import org.apache.tools.ant.util.FileNameMapper; import org.apache.tools.ant.util.SourceFileScanner; @@ -36,9 +37,9 @@ public class ExecuteOn extends ExecTask private boolean relative = false; private boolean parallel = false; protected String type = "file"; - protected Commandline.Marker srcFilePos = null; + protected Marker srcFilePos = null; private boolean skipEmpty = false; - protected Commandline.Marker targetFilePos = null; + protected Marker targetFilePos = null; protected Mapper mapperElement = null; protected FileNameMapper mapper = null; protected File destDir = null; @@ -132,7 +133,7 @@ public class ExecuteOn extends ExecTask * * @return Description of the Returned Value */ - public Commandline.Marker createSrcfile() + public Marker createSrcfile() throws TaskException { if( srcFilePos != null ) @@ -149,7 +150,7 @@ public class ExecuteOn extends ExecTask * * @return Description of the Returned Value */ - public Commandline.Marker createTargetfile() + public Marker createTargetfile() throws TaskException { if( targetFilePos != null ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Java.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Java.java index f95200d5c..7b3f2e36b 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Java.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Java.java @@ -24,6 +24,7 @@ import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.types.EnvironmentVariable; +import org.apache.tools.ant.types.Argument; /** * This task acts as a loader for java applications but allows to use the same @@ -185,7 +186,7 @@ public class Java extends Task * * @return Description of the Returned Value */ - public Commandline.Argument createArg() + public Argument createArg() { return cmdl.createArgument(); } @@ -206,7 +207,7 @@ public class Java extends Task * * @return Description of the Returned Value */ - public Commandline.Argument createJvmarg() + public Argument createJvmarg() { return cmdl.createVmArgument(); } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Javac.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Javac.java index 473c59c39..1f641e7ce 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Javac.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Javac.java @@ -19,6 +19,7 @@ import org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; +import org.apache.tools.ant.types.Argument; import org.apache.tools.ant.util.GlobPatternMapper; import org.apache.tools.ant.util.SourceFileScanner; @@ -914,7 +915,7 @@ public class Javac extends MatchingTask * @author RT */ public class ImplementationSpecificArgument - extends Commandline.Argument + extends Argument { private String impl; diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/ExecTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/ExecTask.java index a2253b448..6b04016dd 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/ExecTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/exec/ExecTask.java @@ -22,6 +22,7 @@ import org.apache.tools.ant.Task; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.EnvironmentVariable; +import org.apache.tools.ant.types.Argument; /** * Executes a given command if the os platform is appropriate. @@ -186,7 +187,7 @@ public class ExecTask extends Task * * @return Description of the Returned Value */ - public Commandline.Argument createArg() + public Argument createArg() { return cmdl.createArgument(); } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ANTLR.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ANTLR.java index 53280ce12..ecb7cf222 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ANTLR.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ANTLR.java @@ -21,6 +21,7 @@ import org.apache.tools.ant.taskdefs.exec.LogStreamHandler; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Argument; /** * ANTLR task. @@ -104,7 +105,7 @@ public class ANTLR extends Task * the JVM. * @see #setFork(boolean) */ - public Commandline.Argument createJvmarg() + public Argument createJvmarg() { return commandline.createVmArgument(); } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java index e5ff74888..bab295fda 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java @@ -23,6 +23,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute; import org.apache.tools.ant.taskdefs.exec.ExecuteStreamHandler; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Argument; /** * BorlandDeploymentTool is dedicated to the Borland Application Server 4.5 and @@ -491,7 +492,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exec javaTask = (Java)getTask().getProject().createTask( "java" ); javaTask.setClassname( VERIFY ); - Commandline.Argument arguments = javaTask.createArg(); + Argument arguments = javaTask.createArg(); arguments.setLine( args ); Path classpath = getCombinedClasspath(); if( classpath != null ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/DDCreator.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/DDCreator.java index 3c9e44064..bcb46a530 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/DDCreator.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/DDCreator.java @@ -14,6 +14,7 @@ import org.apache.tools.ant.taskdefs.Java; import org.apache.tools.ant.taskdefs.MatchingTask; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Argument; /** * Build a serialised deployment descriptor given a text file description of the @@ -122,7 +123,7 @@ public class DDCreator extends MatchingTask Java ddCreatorTask = (Java)getProject().createTask( "java" ); ddCreatorTask.setFork( true ); ddCreatorTask.setClassname( "org.apache.tools.ant.taskdefs.optional.ejb.DDCreatorHelper" ); - Commandline.Argument arguments = ddCreatorTask.createArg(); + Argument arguments = ddCreatorTask.createArg(); arguments.setLine( args ); ddCreatorTask.setClasspath( new Path( getProject(), execClassPath ) ); if( ddCreatorTask.executeJava() != 0 ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/Ejbc.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/Ejbc.java index 83c11e814..7fd8bbb74 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/Ejbc.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/Ejbc.java @@ -14,6 +14,7 @@ import org.apache.tools.ant.taskdefs.Java; import org.apache.tools.ant.taskdefs.MatchingTask; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Argument; /** * Build EJB support classes using Weblogic's ejbc tool from a directory @@ -181,7 +182,7 @@ public class Ejbc extends MatchingTask args += " " + files[ i ]; } - Commandline.Argument arguments = helperTask.createArg(); + Argument arguments = helperTask.createArg(); arguments.setLine( args ); helperTask.setClasspath( new Path( getProject(), execClassPath ) ); if( helperTask.executeJava() != 0 ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java index 07ba2f48c..354cba773 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java @@ -25,6 +25,7 @@ import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.EnvironmentVariable; +import org.apache.tools.ant.types.Argument; /** * Websphere deployment tool that augments the ejbjar task. @@ -982,7 +983,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool // Set the Java class name javaTask.setClassname( "com.ibm.etools.ejbdeploy.EJBDeploy" ); - Commandline.Argument arguments = javaTask.createArg(); + Argument arguments = javaTask.createArg(); arguments.setLine( args ); Path classpath = wasClasspath; if( classpath == null ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java index fdc46a7fe..3dac2cd0b 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java @@ -19,6 +19,7 @@ import org.apache.tools.ant.taskdefs.exec.LogStreamHandler; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Argument; /** * Taskdef for the JJTree compiler compiler. @@ -180,7 +181,7 @@ public class JJTree extends Task "/JavaCC.zip" ); classpath.addJavaRuntime(); - final Commandline.Argument arg = cmdl.createVmArgument(); + final Argument arg = cmdl.createVmArgument(); arg.setValue( "-mx140M" ); arg.setValue( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java index c36fe7688..850187637 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java @@ -17,6 +17,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Argument; /** * Taskdef for the JavaCC compiler compiler. @@ -230,7 +231,7 @@ public class JavaCC extends Task "/JavaCC.zip" ); classpath.addJavaRuntime(); - final Commandline.Argument arg = cmdl.createVmArgument(); + final Argument arg = cmdl.createVmArgument(); arg.setValue( "-mx140M" ); arg.setValue( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java index 2ccb3947d..fa5bc118f 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java @@ -23,6 +23,7 @@ import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; +import org.apache.tools.ant.types.Argument; /** * Ant task to run JDepend tests.

@@ -219,7 +220,7 @@ public class JDependTask extends Task * the JVM. * @see #setFork(boolean) */ - public Commandline.Argument createJvmarg( CommandlineJava commandline ) + public Argument createJvmarg( CommandlineJava commandline ) { return commandline.createVmArgument(); } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index ade21f89b..49156097a 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -31,6 +31,7 @@ import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.EnvironmentData; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.EnvironmentVariable; +import org.apache.tools.ant.types.Argument; /** * Ant task to run JUnit tests.

@@ -367,7 +368,7 @@ public class JUnitTask extends Task * the JVM. * @see #setFork(boolean) */ - public Commandline.Argument createJvmarg() + public Argument createJvmarg() { return commandline.createVmArgument(); } 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 d75b37424..794a1e8fe 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 @@ -25,6 +25,7 @@ import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Argument; /** * Somewhat abstract framework to be used for other metama 2.0 tasks. This @@ -169,7 +170,7 @@ public abstract class AbstractMetamataTask extends Task * * @return Description of the Returned Value */ - public Commandline.Argument createJvmarg() + public Argument createJvmarg() { return cmdl.createVmArgument(); } @@ -226,7 +227,7 @@ public abstract class AbstractMetamataTask extends Task classPath.createPathElement().setLocation( jar ); // set the metamata.home property - final Commandline.Argument vmArgs = cmdl.createVmArgument(); + final Argument vmArgs = cmdl.createVmArgument(); vmArgs.setValue( "-Dmetamata.home=" + metamataHome.getAbsolutePath() ); // retrieve all the files we want to scan @@ -237,7 +238,7 @@ public abstract class AbstractMetamataTask extends Task ArrayList options = getOptions(); optionsFile = createTmpFile(); generateOptionsFile( optionsFile, options ); - Commandline.Argument args = cmdl.createArgument(); + Argument args = cmdl.createArgument(); args.setLine( "-arguments " + optionsFile.getAbsolutePath() ); } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java index 2b8e5d8f4..eee34a457 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java @@ -22,6 +22,7 @@ import org.apache.tools.ant.taskdefs.exec.LogStreamHandler; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Argument; /** * Simple Metamata MParse task based on the original written by 0 ) { @@ -206,11 +205,11 @@ public class Commandline * * @param executable The new Executable value */ - public void setExecutable( String executable ) + public void setExecutable( final String executable ) { if( executable == null || executable.length() == 0 ) return; - this.m_executable = executable.replace( '/', File.separatorChar ) + m_executable = executable.replace( '/', File.separatorChar ) .replace( '\\', File.separatorChar ); } @@ -222,11 +221,12 @@ public class Commandline */ public String[] getArguments() { - ArrayList result = new ArrayList( m_arguments.size() * 2 ); - for( int i = 0; i < m_arguments.size(); i++ ) + final int size = m_arguments.size(); + final ArrayList result = new ArrayList( size * 2 ); + for( int i = 0; i < size; i++ ) { - Argument arg = (Argument)m_arguments.get( i ); - String[] s = arg.getParts(); + final Argument arg = (Argument)m_arguments.get( i ); + final String[] s = arg.getParts(); for( int j = 0; j < s.length; j++ ) { result.add( s[ j ] ); @@ -246,7 +246,9 @@ public class Commandline { final String[] args = getArguments(); if( m_executable == null ) + { return args; + } final String[] result = new String[ args.length + 1 ]; result[ 0 ] = m_executable; System.arraycopy( args, 0, result, 1, args.length ); @@ -315,7 +317,7 @@ public class Commandline */ public Marker createMarker() { - return new Marker( m_arguments.size() ); + return new Marker( this, m_arguments.size() ); } public int size() @@ -328,109 +330,4 @@ public class Commandline return toString( getCommandline() ); } - /** - * Used for nested xml command line definitions. - * - * @author RT - */ - public static class Argument - { - - private String[] parts; - - /** - * Sets a single commandline argument to the absolute filename of the - * given file. - * - * @param value a single commandline argument. - */ - public void setFile( File value ) - { - parts = new String[]{value.getAbsolutePath()}; - } - - /** - * Line to split into several commandline arguments. - * - * @param line line to split into several commandline arguments - */ - public void setLine( String line ) - throws TaskException - { - parts = translateCommandline( line ); - } - - /** - * Sets a single commandline argument and treats it like a PATH - - * ensures the right separator for the local platform is used. - * - * @param value a single commandline argument. - */ - public void setPath( Path value ) - { - parts = new String[]{value.toString()}; - } - - /** - * Sets a single commandline argument. - * - * @param value a single commandline argument. - */ - public void setValue( String value ) - { - parts = new String[]{value}; - } - - /** - * Returns the parts this Argument consists of. - * - * @return The Parts value - */ - public String[] getParts() - { - return parts; - } - } - - /** - * Class to keep track of the position of an Argument. - * - * @author RT - */ - //

This class is there to support the srcfile and targetfile - // elements of <execon> and <transform> - don't know - // whether there might be additional use cases.

--SB - public class Marker - { - private int realPos = -1; - - private int position; - - Marker( int position ) - { - this.position = position; - } - - /** - * Return the number of arguments that preceeded this marker.

- * - * The name of the executable - if set - is counted as the very first - * argument.

- * - * @return The Position value - */ - public int getPosition() - { - if( realPos == -1 ) - { - realPos = ( m_executable == null ? 0 : 1 ); - for( int i = 0; i < position; i++ ) - { - Argument arg = (Argument)m_arguments.get( i ); - realPos += arg.getParts().length; - } - } - return realPos; - } - } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/CommandlineJava.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/CommandlineJava.java index 75f014581..3850a217a 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/CommandlineJava.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/CommandlineJava.java @@ -218,7 +218,7 @@ public class CommandlineJava implements Cloneable return c; } - public Commandline.Argument createArgument() + public Argument createArgument() { return javaCommand.createArgument(); } @@ -232,7 +232,7 @@ public class CommandlineJava implements Cloneable return classpath; } - public Commandline.Argument createVmArgument() + public Argument createVmArgument() { return vmCommand.createArgument(); } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/EnvironmentData.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/EnvironmentData.java index 9dc427a3b..0516352a4 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/EnvironmentData.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/EnvironmentData.java @@ -38,5 +38,4 @@ public class EnvironmentData { m_variables.add( var ); } - } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/Marker.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/Marker.java new file mode 100644 index 000000000..a1a5703a8 --- /dev/null +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/Marker.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) The Apache Software Foundation. All rights reserved. + * + * This software is published under the terms of the Apache Software License + * version 1.1, a copy of which has been included with this distribution in + * the LICENSE.txt file. + */ +package org.apache.tools.ant.types; + +import java.util.ArrayList; + +/** + * Class to keep track of the position of an Argument. + * + *

This class is there to support the srcfile and targetfile + * elements of <execon> and <transform> - don't know + * whether there might be additional use cases.

--SB + */ +public class Marker +{ + private int m_realPos = -1; + private int m_position; + private Commandline m_commandline; + + Marker( Commandline commandline, int position ) + { + m_commandline = commandline; + m_position = position; + } + + /** + * Return the number of arguments that preceeded this marker.

+ * + * The name of the executable - if set - is counted as the very first + * argument.

+ * + * @return The Position value + */ + public int getPosition() + { + if( m_realPos == -1 ) + { + m_realPos = ( m_commandline.getExecutable() == null ? 0 : 1 ); + final ArrayList arguments = m_commandline.m_arguments; + for( int i = 0; i < m_position; i++ ) + { + final Argument arg = (Argument)arguments.get( i ); + m_realPos += arg.getParts().length; + } + } + return m_realPos; + } +}