Interface CommandLine

  • All Known Implementing Classes:
    DefaultCommandLine, ScriptCommandLine

    public interface CommandLine
    Quotes command line arguments.
    Since:
    2.0
    Author:
    Erwin Mueller, erwin.mueller@deventm.org
    • Method Detail

      • getCommand

        List<String> getCommand()
                         throws CommandExecException
        Returns the of the command list.
        Returns:
        the unmodifiable List of String that 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

        Object getExecutable()
        Returns the executable.
        Returns:
        the Object executable to run, can be the name of the executable or the path or any other abstract object.
      • getArguments

        List<String> getArguments()
        Returns the arguments.
        Returns:
        the unmodifiable List of arguments.
      • add

        CommandLine add​(boolean quote,
                        Object... arguments)
        Adds the specified command line arguments.
        Parameters:
        quote - set to true to quote the argument.
        arguments - the Object array arguments.
        Returns:
        this DefaultCommandLine.
      • add

        CommandLine add​(boolean quote,
                        Object argument)
        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'
        Parameters:
        argument - the Object argument.
        quote - set to true to quote the argument.
        Returns:
        this DefaultCommandLine.
      • addSub

        CommandLine addSub​(String name,
                           Object value)
        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>".
        Parameters:
        name - the String name of the variable.
        value - the Object value of the variable.
        Returns:
        this DefaultCommandLine.
      • setWorkingDir

        void setWorkingDir​(File dir)
        Sets the working directory.
        Parameters:
        dir - the File directory or null to use the working directory of the current Java process.
      • getWorkingDir

        File getWorkingDir()
        Returns the working directory.
        Returns:
        the File directory or null to use the working directory of the current Java process.
      • setVariableStartChar

        void setVariableStartChar​(char character)
        Sets the variable substitution start character. The start character defaults to "<".
        Parameters:
        character - the character.
      • setVariableStopChar

        void setVariableStopChar​(char character)
        Sets the variable substitution stop character. The stop character defaults to ">".
        Parameters:
        character - the character.