类 CommandLine

java.lang.Object
com.sh.common.exec.CommandLine

public class CommandLine extends Object
Description: Title:首亨软件 - CRM、TSS、ERP等信息化管理软件
  • 构造器详细资料

    • CommandLine

      public CommandLine(String executable)
      Create a command line without any arguments.
      参数:
      executable - the executable
    • CommandLine

      public CommandLine(File executable)
      Create a command line without any arguments.
      参数:
      executable - the executable file
    • CommandLine

      public CommandLine(CommandLine other)
      Copy constructor.
      参数:
      other - the instance to copy
  • 方法详细资料

    • parse

      public static CommandLine parse(String line)
      Create a command line from a string.
      参数:
      line - the first element becomes the executable, the rest the arguments
      返回:
      the parsed command line
      抛出:
      IllegalArgumentException - If line is null or all whitespace
    • parse

      public static CommandLine parse(String line, Map substitutionMap)
      Create a command line from a string.
      参数:
      line - the first element becomes the executable, the rest the arguments
      substitutionMap - the name/value pairs used for substitution
      返回:
      the parsed command line
      抛出:
      IllegalArgumentException - If line is null or all whitespace
    • getExecutable

      public String getExecutable()
      Returns the executable.
      返回:
      The executable
    • isFile

      public boolean isFile()
      Was a file being used to set the executable?
      返回:
      true if a file was used for setting the executable
    • addArguments

      public CommandLine addArguments(String[] arguments)
      Add multiple arguments. Handles parsing of quotes and whitespace.
      参数:
      arguments - An array of arguments
      返回:
      The command line itself
    • addArguments

      public CommandLine addArguments(String[] arguments, boolean handleQuoting)
      Add multiple arguments.
      参数:
      arguments - An array of arguments
      handleQuoting - Add the argument with/without handling quoting
      返回:
      The command line itself
    • addArguments

      public CommandLine addArguments(String arguments)
      Add multiple arguments. Handles parsing of quotes and whitespace. Please note that the parsing can have undesired side-effects therefore it is recommended to build the command line incrementally.
      参数:
      arguments - An string containing multiple arguments.
      返回:
      The command line itself
    • addArguments

      public CommandLine addArguments(String arguments, boolean handleQuoting)
      Add multiple arguments. Handles parsing of quotes and whitespace. Please note that the parsing can have undesired side-effects therefore it is recommended to build the command line incrementally.
      参数:
      arguments - An string containing multiple arguments.
      handleQuoting - Add the argument with/without handling quoting
      返回:
      The command line itself
    • addArgument

      public CommandLine addArgument(String argument)
      Add a single argument. Handles quoting.
      参数:
      argument - The argument to add
      返回:
      The command line itself
      抛出:
      IllegalArgumentException - If argument contains both single and double quotes
    • addArgument

      public CommandLine addArgument(String argument, boolean handleQuoting)
      Add a single argument.
      参数:
      argument - The argument to add
      handleQuoting - Add the argument with/without handling quoting
      返回:
      The command line itself
    • getArguments

      public String[] getArguments()
      Returns the expanded and quoted command line arguments.
      返回:
      The quoted arguments
    • getSubstitutionMap

      public Map getSubstitutionMap()
      返回:
      the substitution map
    • setSubstitutionMap

      public void setSubstitutionMap(Map substitutionMap)
      Set the substitutionMap to expand variables in the command line.
      参数:
      substitutionMap - the map
    • toStrings

      public String[] toStrings()
      Returns the command line as an array of strings.
      返回:
      The command line as an string array
    • toString

      public String toString()
      Stringify operator returns the command line as a string. Parameters are correctly quoted when containing a space or left untouched if the are already quoted.
      覆盖:
      toString 在类中 Object
      返回:
      the command line as single string