git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270716 13f79535-47bb-0310-9956-ffa450edef68master
@@ -21,7 +21,7 @@ import java.util.ArrayList; | |||
import java.util.Enumeration; | |||
import java.util.Hashtable; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.taskdefs.condition.Condition; | |||
import org.apache.tools.ant.types.FileSet; | |||
@@ -13,7 +13,7 @@ import java.util.Date; | |||
import java.util.Iterator; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.aut.nativelib.Os; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.types.FileList; | |||
import org.apache.tools.ant.types.FileSet; | |||
@@ -19,7 +19,7 @@ import java.util.zip.ZipEntry; | |||
import java.util.zip.ZipInputStream; | |||
import org.apache.avalon.excalibur.io.FileUtil; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.types.FileSet; | |||
import org.apache.tools.ant.types.PatternSet; | |||
@@ -200,7 +200,7 @@ public class Expand extends MatchingTask | |||
for( int v = 0; v < patternsets.size(); v++ ) | |||
{ | |||
PatternSet p = (PatternSet)patternsets.get( v ); | |||
String[] incls = p.getIncludePatterns( getProject() ); | |||
String[] incls = p.getIncludePatterns( null ); | |||
if( incls != null ) | |||
{ | |||
for( int w = 0; w < incls.length; w++ ) | |||
@@ -213,7 +213,7 @@ public class Expand extends MatchingTask | |||
} | |||
} | |||
} | |||
String[] excls = p.getExcludePatterns( getProject() ); | |||
String[] excls = p.getExcludePatterns( null ); | |||
if( excls != null ) | |||
{ | |||
for( int w = 0; w < excls.length; w++ ) | |||
@@ -20,7 +20,7 @@ import java.io.Reader; | |||
import java.util.Enumeration; | |||
import java.util.Iterator; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.FileScanner; | |||
import org.apache.tools.ant.types.FileScanner; | |||
import org.apache.tools.ant.types.ZipFileSet; | |||
import org.apache.tools.zip.ZipOutputStream; | |||
@@ -13,13 +13,13 @@ import java.util.Iterator; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.myrmidon.framework.JavaVersion; | |||
import org.apache.aut.nativelib.Os; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.taskdefs.compilers.CompilerAdapter; | |||
import org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory; | |||
import org.apache.tools.ant.types.Argument; | |||
import org.apache.tools.ant.types.Path; | |||
import org.apache.tools.ant.util.GlobPatternMapper; | |||
import org.apache.tools.ant.util.SourceFileScanner; | |||
import org.apache.tools.ant.types.SourceFileScanner; | |||
/** | |||
* Task to compile Java source files. This task can take the following | |||
@@ -9,7 +9,7 @@ package org.apache.tools.ant.taskdefs; | |||
import java.io.File; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.types.FileSet; | |||
import org.apache.tools.ant.types.PatternSet; | |||
@@ -14,12 +14,12 @@ import java.rmi.Remote; | |||
import java.util.ArrayList; | |||
import org.apache.avalon.excalibur.io.FileUtil; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.taskdefs.rmic.RmicAdapter; | |||
import org.apache.tools.ant.taskdefs.rmic.RmicAdapterFactory; | |||
import org.apache.tools.ant.types.Path; | |||
import org.apache.tools.ant.util.FileNameMapper; | |||
import org.apache.tools.ant.util.SourceFileScanner; | |||
import org.apache.tools.ant.types.SourceFileScanner; | |||
/** | |||
* Task to compile RMI stubs and skeletons. This task can take the following | |||
@@ -32,7 +32,7 @@ import java.util.Iterator; | |||
import java.util.Properties; | |||
import java.util.StringTokenizer; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.types.EnumeratedAttribute; | |||
import org.apache.tools.ant.types.FileSet; | |||
@@ -14,11 +14,11 @@ import java.io.IOException; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.types.EnumeratedAttribute; | |||
import org.apache.tools.ant.types.FileSet; | |||
import org.apache.tools.ant.util.MergingMapper; | |||
import org.apache.tools.ant.util.SourceFileScanner; | |||
import org.apache.tools.ant.types.SourceFileScanner; | |||
import org.apache.tools.tar.TarConstants; | |||
import org.apache.tools.tar.TarEntry; | |||
import org.apache.tools.tar.TarOutputStream; | |||
@@ -11,13 +11,13 @@ import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.taskdefs.condition.Condition; | |||
import org.apache.tools.ant.types.FileSet; | |||
import org.apache.tools.ant.types.Mapper; | |||
import org.apache.tools.ant.util.FileNameMapper; | |||
import org.apache.tools.ant.util.MergingMapper; | |||
import org.apache.tools.ant.util.SourceFileScanner; | |||
import org.apache.tools.ant.types.SourceFileScanner; | |||
/** | |||
* Will set the given property if the specified target has a timestamp greater | |||
@@ -21,14 +21,14 @@ import java.util.Stack; | |||
import java.util.zip.CRC32; | |||
import java.util.zip.ZipInputStream; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.FileScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.types.FileScanner; | |||
import org.apache.tools.ant.types.EnumeratedAttribute; | |||
import org.apache.tools.ant.types.FileSet; | |||
import org.apache.tools.ant.types.ZipFileSet; | |||
import org.apache.tools.ant.types.ZipScanner; | |||
import org.apache.tools.ant.util.MergingMapper; | |||
import org.apache.tools.ant.util.SourceFileScanner; | |||
import org.apache.tools.ant.types.SourceFileScanner; | |||
import org.apache.tools.zip.ZipEntry; | |||
import org.apache.tools.zip.ZipOutputStream; | |||
@@ -9,8 +9,7 @@ package org.apache.tools.ant.types; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.StringTokenizer; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.avalon.excalibur.util.StringUtil; | |||
/** | |||
* Commandline objects help handling command lines specifying processes to | |||
@@ -33,154 +32,10 @@ import org.apache.myrmidon.api.TaskException; | |||
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | |||
*/ | |||
public class Commandline | |||
implements Cloneable | |||
{ | |||
protected final ArrayList m_arguments = new ArrayList(); | |||
private String m_executable; | |||
/** | |||
* Put quotes around the given String if necessary. <p> | |||
* | |||
* If the argument doesn't include spaces or quotes, return it as is. If it | |||
* contains double quotes, use single quotes - else surround the argument by | |||
* double quotes.</p> | |||
* | |||
* @param argument Description of Parameter | |||
* @return Description of the Returned Value | |||
*/ | |||
public static String quoteArgument( String argument ) | |||
throws TaskException | |||
{ | |||
if( argument.indexOf( "\"" ) > -1 ) | |||
{ | |||
if( argument.indexOf( "\'" ) > -1 ) | |||
{ | |||
throw new TaskException( "Can\'t handle single and double quotes in same argument" ); | |||
} | |||
else | |||
{ | |||
return '\'' + argument + '\''; | |||
} | |||
} | |||
else if( argument.indexOf( "\'" ) > -1 || argument.indexOf( " " ) > -1 ) | |||
{ | |||
return '\"' + argument + '\"'; | |||
} | |||
else | |||
{ | |||
return argument; | |||
} | |||
} | |||
public static String toString( String[] line ) | |||
{ | |||
// empty path return empty string | |||
if( line == null || line.length == 0 ) | |||
return ""; | |||
// path containing one or more elements | |||
final StringBuffer result = new StringBuffer(); | |||
for( int i = 0; i < line.length; i++ ) | |||
{ | |||
if( i > 0 ) | |||
{ | |||
result.append( ' ' ); | |||
} | |||
try | |||
{ | |||
result.append( quoteArgument( line[ i ] ) ); | |||
} | |||
catch( TaskException e ) | |||
{ | |||
} | |||
} | |||
return result.toString(); | |||
} | |||
public static String[] translateCommandline( String to_process ) | |||
throws TaskException | |||
{ | |||
if( to_process == null || to_process.length() == 0 ) | |||
{ | |||
return new String[ 0 ]; | |||
} | |||
// parse with a simple finite state machine | |||
final int normal = 0; | |||
final int inQuote = 1; | |||
final int inDoubleQuote = 2; | |||
int state = normal; | |||
StringTokenizer tok = new StringTokenizer( to_process, "\"\' ", true ); | |||
ArrayList v = new ArrayList(); | |||
StringBuffer current = new StringBuffer(); | |||
while( tok.hasMoreTokens() ) | |||
{ | |||
String nextTok = tok.nextToken(); | |||
switch( state ) | |||
{ | |||
case inQuote: | |||
if( "\'".equals( nextTok ) ) | |||
{ | |||
state = normal; | |||
} | |||
else | |||
{ | |||
current.append( nextTok ); | |||
} | |||
break; | |||
case inDoubleQuote: | |||
if( "\"".equals( nextTok ) ) | |||
{ | |||
state = normal; | |||
} | |||
else | |||
{ | |||
current.append( nextTok ); | |||
} | |||
break; | |||
default: | |||
if( "\'".equals( nextTok ) ) | |||
{ | |||
state = inQuote; | |||
} | |||
else if( "\"".equals( nextTok ) ) | |||
{ | |||
state = inDoubleQuote; | |||
} | |||
else if( " ".equals( nextTok ) ) | |||
{ | |||
if( current.length() != 0 ) | |||
{ | |||
v.add( current.toString() ); | |||
current.setLength( 0 ); | |||
} | |||
} | |||
else | |||
{ | |||
current.append( nextTok ); | |||
} | |||
break; | |||
} | |||
} | |||
if( current.length() != 0 ) | |||
{ | |||
v.add( current.toString() ); | |||
} | |||
if( state == inQuote || state == inDoubleQuote ) | |||
{ | |||
throw new TaskException( "unbalanced quotes in " + to_process ); | |||
} | |||
final String[] args = new String[ v.size() ]; | |||
return (String[])v.toArray( args ); | |||
} | |||
/** | |||
* Sets the executable to run. | |||
* | |||
@@ -249,32 +104,6 @@ public class Commandline | |||
} | |||
} | |||
/** | |||
* Clear out the whole command line. | |||
*/ | |||
public void clear() | |||
{ | |||
m_executable = null; | |||
m_arguments.clear(); | |||
} | |||
/** | |||
* Clear out the arguments but leave the executable in place for another | |||
* operation. | |||
*/ | |||
public void clearArgs() | |||
{ | |||
m_arguments.clear(); | |||
} | |||
public Object clone() | |||
{ | |||
final Commandline commandline = new Commandline(); | |||
commandline.setExecutable( m_executable ); | |||
commandline.addArguments( getArguments() ); | |||
return commandline; | |||
} | |||
/** | |||
* Creates an argument object. Each commandline object has at most one | |||
* instance of the argument class. | |||
@@ -308,7 +137,6 @@ public class Commandline | |||
public String toString() | |||
{ | |||
return toString( getCommandline() ); | |||
return StringUtil.join( getCommandline(), " " ); | |||
} | |||
} |
@@ -21,7 +21,7 @@ import java.util.ArrayList; | |||
import java.util.Enumeration; | |||
import java.util.Hashtable; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.taskdefs.condition.Condition; | |||
import org.apache.tools.ant.types.FileSet; | |||
@@ -13,7 +13,7 @@ import java.util.Date; | |||
import java.util.Iterator; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.aut.nativelib.Os; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.types.FileList; | |||
import org.apache.tools.ant.types.FileSet; | |||
@@ -19,7 +19,7 @@ import java.util.zip.ZipEntry; | |||
import java.util.zip.ZipInputStream; | |||
import org.apache.avalon.excalibur.io.FileUtil; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.types.FileSet; | |||
import org.apache.tools.ant.types.PatternSet; | |||
@@ -200,7 +200,7 @@ public class Expand extends MatchingTask | |||
for( int v = 0; v < patternsets.size(); v++ ) | |||
{ | |||
PatternSet p = (PatternSet)patternsets.get( v ); | |||
String[] incls = p.getIncludePatterns( getProject() ); | |||
String[] incls = p.getIncludePatterns( null ); | |||
if( incls != null ) | |||
{ | |||
for( int w = 0; w < incls.length; w++ ) | |||
@@ -213,7 +213,7 @@ public class Expand extends MatchingTask | |||
} | |||
} | |||
} | |||
String[] excls = p.getExcludePatterns( getProject() ); | |||
String[] excls = p.getExcludePatterns( null ); | |||
if( excls != null ) | |||
{ | |||
for( int w = 0; w < excls.length; w++ ) | |||
@@ -20,7 +20,7 @@ import java.io.Reader; | |||
import java.util.Enumeration; | |||
import java.util.Iterator; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.FileScanner; | |||
import org.apache.tools.ant.types.FileScanner; | |||
import org.apache.tools.ant.types.ZipFileSet; | |||
import org.apache.tools.zip.ZipOutputStream; | |||
@@ -13,13 +13,13 @@ import java.util.Iterator; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.myrmidon.framework.JavaVersion; | |||
import org.apache.aut.nativelib.Os; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.taskdefs.compilers.CompilerAdapter; | |||
import org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory; | |||
import org.apache.tools.ant.types.Argument; | |||
import org.apache.tools.ant.types.Path; | |||
import org.apache.tools.ant.util.GlobPatternMapper; | |||
import org.apache.tools.ant.util.SourceFileScanner; | |||
import org.apache.tools.ant.types.SourceFileScanner; | |||
/** | |||
* Task to compile Java source files. This task can take the following | |||
@@ -9,7 +9,7 @@ package org.apache.tools.ant.taskdefs; | |||
import java.io.File; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.types.FileSet; | |||
import org.apache.tools.ant.types.PatternSet; | |||
@@ -14,12 +14,12 @@ import java.rmi.Remote; | |||
import java.util.ArrayList; | |||
import org.apache.avalon.excalibur.io.FileUtil; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.taskdefs.rmic.RmicAdapter; | |||
import org.apache.tools.ant.taskdefs.rmic.RmicAdapterFactory; | |||
import org.apache.tools.ant.types.Path; | |||
import org.apache.tools.ant.util.FileNameMapper; | |||
import org.apache.tools.ant.util.SourceFileScanner; | |||
import org.apache.tools.ant.types.SourceFileScanner; | |||
/** | |||
* Task to compile RMI stubs and skeletons. This task can take the following | |||
@@ -32,7 +32,7 @@ import java.util.Iterator; | |||
import java.util.Properties; | |||
import java.util.StringTokenizer; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.types.EnumeratedAttribute; | |||
import org.apache.tools.ant.types.FileSet; | |||
@@ -14,11 +14,11 @@ import java.io.IOException; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.types.EnumeratedAttribute; | |||
import org.apache.tools.ant.types.FileSet; | |||
import org.apache.tools.ant.util.MergingMapper; | |||
import org.apache.tools.ant.util.SourceFileScanner; | |||
import org.apache.tools.ant.types.SourceFileScanner; | |||
import org.apache.tools.tar.TarConstants; | |||
import org.apache.tools.tar.TarEntry; | |||
import org.apache.tools.tar.TarOutputStream; | |||
@@ -11,13 +11,13 @@ import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.taskdefs.condition.Condition; | |||
import org.apache.tools.ant.types.FileSet; | |||
import org.apache.tools.ant.types.Mapper; | |||
import org.apache.tools.ant.util.FileNameMapper; | |||
import org.apache.tools.ant.util.MergingMapper; | |||
import org.apache.tools.ant.util.SourceFileScanner; | |||
import org.apache.tools.ant.types.SourceFileScanner; | |||
/** | |||
* Will set the given property if the specified target has a timestamp greater | |||
@@ -21,14 +21,14 @@ import java.util.Stack; | |||
import java.util.zip.CRC32; | |||
import java.util.zip.ZipInputStream; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.tools.ant.DirectoryScanner; | |||
import org.apache.tools.ant.FileScanner; | |||
import org.apache.tools.ant.types.DirectoryScanner; | |||
import org.apache.tools.ant.types.FileScanner; | |||
import org.apache.tools.ant.types.EnumeratedAttribute; | |||
import org.apache.tools.ant.types.FileSet; | |||
import org.apache.tools.ant.types.ZipFileSet; | |||
import org.apache.tools.ant.types.ZipScanner; | |||
import org.apache.tools.ant.util.MergingMapper; | |||
import org.apache.tools.ant.util.SourceFileScanner; | |||
import org.apache.tools.ant.types.SourceFileScanner; | |||
import org.apache.tools.zip.ZipEntry; | |||
import org.apache.tools.zip.ZipOutputStream; | |||
@@ -9,8 +9,7 @@ package org.apache.tools.ant.types; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.StringTokenizer; | |||
import org.apache.myrmidon.api.TaskException; | |||
import org.apache.avalon.excalibur.util.StringUtil; | |||
/** | |||
* Commandline objects help handling command lines specifying processes to | |||
@@ -33,154 +32,10 @@ import org.apache.myrmidon.api.TaskException; | |||
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | |||
*/ | |||
public class Commandline | |||
implements Cloneable | |||
{ | |||
protected final ArrayList m_arguments = new ArrayList(); | |||
private String m_executable; | |||
/** | |||
* Put quotes around the given String if necessary. <p> | |||
* | |||
* If the argument doesn't include spaces or quotes, return it as is. If it | |||
* contains double quotes, use single quotes - else surround the argument by | |||
* double quotes.</p> | |||
* | |||
* @param argument Description of Parameter | |||
* @return Description of the Returned Value | |||
*/ | |||
public static String quoteArgument( String argument ) | |||
throws TaskException | |||
{ | |||
if( argument.indexOf( "\"" ) > -1 ) | |||
{ | |||
if( argument.indexOf( "\'" ) > -1 ) | |||
{ | |||
throw new TaskException( "Can\'t handle single and double quotes in same argument" ); | |||
} | |||
else | |||
{ | |||
return '\'' + argument + '\''; | |||
} | |||
} | |||
else if( argument.indexOf( "\'" ) > -1 || argument.indexOf( " " ) > -1 ) | |||
{ | |||
return '\"' + argument + '\"'; | |||
} | |||
else | |||
{ | |||
return argument; | |||
} | |||
} | |||
public static String toString( String[] line ) | |||
{ | |||
// empty path return empty string | |||
if( line == null || line.length == 0 ) | |||
return ""; | |||
// path containing one or more elements | |||
final StringBuffer result = new StringBuffer(); | |||
for( int i = 0; i < line.length; i++ ) | |||
{ | |||
if( i > 0 ) | |||
{ | |||
result.append( ' ' ); | |||
} | |||
try | |||
{ | |||
result.append( quoteArgument( line[ i ] ) ); | |||
} | |||
catch( TaskException e ) | |||
{ | |||
} | |||
} | |||
return result.toString(); | |||
} | |||
public static String[] translateCommandline( String to_process ) | |||
throws TaskException | |||
{ | |||
if( to_process == null || to_process.length() == 0 ) | |||
{ | |||
return new String[ 0 ]; | |||
} | |||
// parse with a simple finite state machine | |||
final int normal = 0; | |||
final int inQuote = 1; | |||
final int inDoubleQuote = 2; | |||
int state = normal; | |||
StringTokenizer tok = new StringTokenizer( to_process, "\"\' ", true ); | |||
ArrayList v = new ArrayList(); | |||
StringBuffer current = new StringBuffer(); | |||
while( tok.hasMoreTokens() ) | |||
{ | |||
String nextTok = tok.nextToken(); | |||
switch( state ) | |||
{ | |||
case inQuote: | |||
if( "\'".equals( nextTok ) ) | |||
{ | |||
state = normal; | |||
} | |||
else | |||
{ | |||
current.append( nextTok ); | |||
} | |||
break; | |||
case inDoubleQuote: | |||
if( "\"".equals( nextTok ) ) | |||
{ | |||
state = normal; | |||
} | |||
else | |||
{ | |||
current.append( nextTok ); | |||
} | |||
break; | |||
default: | |||
if( "\'".equals( nextTok ) ) | |||
{ | |||
state = inQuote; | |||
} | |||
else if( "\"".equals( nextTok ) ) | |||
{ | |||
state = inDoubleQuote; | |||
} | |||
else if( " ".equals( nextTok ) ) | |||
{ | |||
if( current.length() != 0 ) | |||
{ | |||
v.add( current.toString() ); | |||
current.setLength( 0 ); | |||
} | |||
} | |||
else | |||
{ | |||
current.append( nextTok ); | |||
} | |||
break; | |||
} | |||
} | |||
if( current.length() != 0 ) | |||
{ | |||
v.add( current.toString() ); | |||
} | |||
if( state == inQuote || state == inDoubleQuote ) | |||
{ | |||
throw new TaskException( "unbalanced quotes in " + to_process ); | |||
} | |||
final String[] args = new String[ v.size() ]; | |||
return (String[])v.toArray( args ); | |||
} | |||
/** | |||
* Sets the executable to run. | |||
* | |||
@@ -249,32 +104,6 @@ public class Commandline | |||
} | |||
} | |||
/** | |||
* Clear out the whole command line. | |||
*/ | |||
public void clear() | |||
{ | |||
m_executable = null; | |||
m_arguments.clear(); | |||
} | |||
/** | |||
* Clear out the arguments but leave the executable in place for another | |||
* operation. | |||
*/ | |||
public void clearArgs() | |||
{ | |||
m_arguments.clear(); | |||
} | |||
public Object clone() | |||
{ | |||
final Commandline commandline = new Commandline(); | |||
commandline.setExecutable( m_executable ); | |||
commandline.addArguments( getArguments() ); | |||
return commandline; | |||
} | |||
/** | |||
* Creates an argument object. Each commandline object has at most one | |||
* instance of the argument class. | |||
@@ -308,7 +137,6 @@ public class Commandline | |||
public String toString() | |||
{ | |||
return toString( getCommandline() ); | |||
return StringUtil.join( getCommandline(), " " ); | |||
} | |||
} |