Class ScriptCommandLine
- java.lang.Object
-
- com.anrisoftware.globalpom.exec.internal.script.ScriptCommandLine
-
- All Implemented Interfaces:
CommandLine
public class ScriptCommandLine extends Object implements CommandLine
Quotes command line arguments.- Since:
- 2.0
- Author:
- Erwin Mueller, erwin.mueller@deventm.org
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CommandLineadd(boolean quote, Object argument)Adds the specified command line argument.CommandLineadd(boolean quote, Object... arguments)Adds the specified command line arguments.CommandLineadd(Object argument)Adds the specified command line argument.CommandLineadd(Object... arguments)Adds the specified command line arguments.CommandLineaddSub(String name, Object value)Adds a variable substitution for the arguments.static CommandLinecreateScriptCommandLine(String name, com.anrisoftware.resources.templates.external.TemplateResource template)List<String>getArguments()Returns the arguments.List<String>getCommand()Returns the of the command list.ObjectgetExecutable()Returns the executable.com.anrisoftware.resources.templates.external.TemplateResourcegetTemplate()FilegetWorkingDir()Returns the working directory.voidsetVariableStartChar(char character)Sets the variable substitution start character.voidsetVariableStopChar(char character)Sets the variable substitution stop character.voidsetWorkingDir(File dir)Sets the working directory.StringtoString()
-
-
-
Method Detail
-
createScriptCommandLine
public static CommandLine createScriptCommandLine(String name, com.anrisoftware.resources.templates.external.TemplateResource template)
- Parameters:
name- theStringtemplate name.template- theTemplateResourcetemplate resource.- Returns:
- the
CommandLine - See Also:
ScriptCommandLineFactory.create(String, TemplateResource)
-
getCommand
public List<String> getCommand() throws CommandExecException
Description copied from interface:CommandLineReturns the of the command list.- Specified by:
getCommandin interfaceCommandLine- Returns:
- the unmodifiable
ListofStringthat contains the executable as the first item and the command arguments as the rest. - Throws:
CommandExecException- if there was an error create the command.
-
getExecutable
public Object getExecutable()
Description copied from interface:CommandLineReturns the executable.- Specified by:
getExecutablein interfaceCommandLine- Returns:
- the
Objectexecutable to run, can be the name of the executable or the path or any other abstract object.
-
getArguments
public List<String> getArguments()
Description copied from interface:CommandLineReturns the arguments.- Specified by:
getArgumentsin interfaceCommandLine- Returns:
- the unmodifiable
Listof arguments.
-
add
public CommandLine add(Object... arguments)
Description copied from interface:CommandLineAdds the specified command line arguments.- Specified by:
addin interfaceCommandLine- Parameters:
arguments- theObjectarray arguments.- Returns:
- this
DefaultCommandLine.
-
add
public CommandLine add(boolean quote, Object... arguments)
Description copied from interface:CommandLineAdds the specified command line arguments.- Specified by:
addin interfaceCommandLine- Parameters:
quote- set totrueto quote the argument.arguments- theObjectarray arguments.- Returns:
- this
DefaultCommandLine.
-
add
public CommandLine add(Object argument)
Description copied from interface:CommandLineAdds the specified command line argument.- Specified by:
addin interfaceCommandLine- Parameters:
argument- theObjectargument.- Returns:
- this
DefaultCommandLine.
-
add
public CommandLine add(boolean quote, Object argument)
Description copied from interface:CommandLineAdds the specified command line argument. If the quote arguments is set then the arguments is quoted in double/single quotes.aaa->aaaaaa bbb->"aaa bbb""aaa" bbb->'"aaa" bbb'"aaa ccc" bbb->'"aaa ccc" bbb'"aaa"bbb->'"aaa"bbb'
- Specified by:
addin interfaceCommandLine- Parameters:
quote- set totrueto quote the argument.argument- theObjectargument.- Returns:
- this
DefaultCommandLine.
-
addSub
public CommandLine addSub(String name, Object value)
Description copied from interface:CommandLineAdds a variable substitution for the arguments. The variables are only substituted when the arguments are returned. The variables must be enclosed in the enclose"<", ">", for example:"foo=<bar>".- Specified by:
addSubin interfaceCommandLine- Parameters:
name- theStringname of the variable.value- theObjectvalue of the variable.- Returns:
- this
DefaultCommandLine.
-
setWorkingDir
public void setWorkingDir(File dir)
Description copied from interface:CommandLineSets the working directory.- Specified by:
setWorkingDirin interfaceCommandLine- Parameters:
dir- theFiledirectory ornullto use the working directory of the current Java process.
-
getWorkingDir
public File getWorkingDir()
Description copied from interface:CommandLineReturns the working directory.- Specified by:
getWorkingDirin interfaceCommandLine- Returns:
- the
Filedirectory ornullto use the working directory of the current Java process.
-
setVariableStartChar
public void setVariableStartChar(char character)
Description copied from interface:CommandLineSets the variable substitution start character. The start character defaults to"<".- Specified by:
setVariableStartCharin interfaceCommandLine- Parameters:
character- the character.
-
setVariableStopChar
public void setVariableStopChar(char character)
Description copied from interface:CommandLineSets the variable substitution stop character. The stop character defaults to">".- Specified by:
setVariableStopCharin interfaceCommandLine- Parameters:
character- the character.
-
getTemplate
public com.anrisoftware.resources.templates.external.TemplateResource getTemplate()
-
toString
public String toString()
- Specified by:
toStringin interfaceCommandLine- Overrides:
toStringin classObject
-
-