Class DefaultCommandLine

java.lang.Object
com.anrisoftware.globalpom.exec.internal.command.DefaultCommandLine
All Implemented Interfaces:
CommandLine

public class DefaultCommandLine extends Object implements CommandLine
Quotes command line arguments.
Since:
1.11
Author:
Erwin Mueller, erwin.mueller@deventm.org
  • Method Details

    • createCommandLine

      public static CommandLine createCommandLine(File executable)
      Parameters:
      executable - the File executable.
      Returns:
      the CommandLine
      See Also:
    • createCommandLine

      public static CommandLine createCommandLine(String executable)
      Parameters:
      executable - the String executable.
      Returns:
      the CommandLine
      See Also:
    • getCommand

      public List<String> getCommand()
      Description copied from interface: CommandLine
      Returns the of the command list.
      Specified by:
      getCommand in interface CommandLine
      Returns:
      the unmodifiable List of String that contains the executable as the first item and the command arguments as the rest.
    • getExecutable

      public String getExecutable()
      Description copied from interface: CommandLine
      Returns the executable.
      Specified by:
      getExecutable in interface CommandLine
      Returns:
      the Object executable 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: CommandLine
      Returns the arguments.
      Specified by:
      getArguments in interface CommandLine
      Returns:
      the unmodifiable List of arguments.
    • add

      public CommandLine add(Object... arguments)
      Description copied from interface: CommandLine
      Adds the specified command line arguments.
      Specified by:
      add in interface CommandLine
      Parameters:
      arguments - the Object array arguments.
      Returns:
      this DefaultCommandLine.
    • add

      public CommandLine add(boolean quote, Object... arguments)
      Description copied from interface: CommandLine
      Adds the specified command line arguments.
      Specified by:
      add in interface CommandLine
      Parameters:
      quote - set to true to quote the argument.
      arguments - the Object array arguments.
      Returns:
      this DefaultCommandLine.
    • add

      public CommandLine add(Object argument)
      Description copied from interface: CommandLine
      Adds the specified command line argument.
      Specified by:
      add in interface CommandLine
      Parameters:
      argument - the Object argument.
      Returns:
      this DefaultCommandLine.
    • add

      public CommandLine add(boolean quote, Object argument)
      Description copied from interface: CommandLine
      Adds the specified command line argument. If the quote arguments is set then the arguments is quoted in double/single quotes.
      • aaa -> aaa
      • aaa bbb -> "aaa bbb"
      • "aaa" bbb -> '"aaa" bbb'
      • "aaa ccc" bbb -> '"aaa ccc" bbb'
      • "aaa"bbb -> '"aaa"bbb'
      Specified by:
      add in interface CommandLine
      Parameters:
      quote - set to true to quote the argument.
      argument - the Object argument.
      Returns:
      this DefaultCommandLine.
    • addSub

      public CommandLine addSub(String name, Object value)
      Description copied from interface: CommandLine
      Adds 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:
      addSub in interface CommandLine
      Parameters:
      name - the String name of the variable.
      value - the Object value of the variable.
      Returns:
      this DefaultCommandLine.
    • setWorkingDir

      public void setWorkingDir(File dir)
      Description copied from interface: CommandLine
      Sets the working directory.
      Specified by:
      setWorkingDir in interface CommandLine
      Parameters:
      dir - the File directory or null to use the working directory of the current Java process.
    • getWorkingDir

      public File getWorkingDir()
      Description copied from interface: CommandLine
      Returns the working directory.
      Specified by:
      getWorkingDir in interface CommandLine
      Returns:
      the File directory or null to use the working directory of the current Java process.
    • setVariableStartChar

      public void setVariableStartChar(char character)
      Description copied from interface: CommandLine
      Sets the variable substitution start character. The start character defaults to "<".
      Specified by:
      setVariableStartChar in interface CommandLine
      Parameters:
      character - the character.
    • setVariableStopChar

      public void setVariableStopChar(char character)
      Description copied from interface: CommandLine
      Sets the variable substitution stop character. The stop character defaults to ">".
      Specified by:
      setVariableStopChar in interface CommandLine
      Parameters:
      character - the character.
    • toString

      public String toString()
      Specified by:
      toString in interface CommandLine
      Overrides:
      toString in class Object