Class CommandLineBuilder


  • public class CommandLineBuilder
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addArg​(java.lang.String arg)
      Add a simple argument to the command line.
      void addEqualsArg​(java.lang.String name, java.lang.String value)
      Similar to addArg(String) but concats both name + value with an "=" sign, quoting were needed, and excluding the "=" portion if the value is undefined or empty.
      void addRawArg​(java.lang.String arg)
      Add a simple argument to the command line.
      void debug()  
      static java.io.File findExecutable​(java.io.File root, java.lang.String path)  
      static java.lang.String findJavaBin()  
      java.util.List<java.lang.String> getArgs()  
      static java.lang.String quote​(java.lang.String arg)
      Perform an optional quoting of the argument, being intelligent with spaces and quotes as needed.
      java.lang.String toString()  
      java.lang.String toString​(java.lang.String delim)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CommandLineBuilder

        public CommandLineBuilder()
      • CommandLineBuilder

        public CommandLineBuilder​(java.lang.String bin)
    • Method Detail

      • findExecutable

        public static java.io.File findExecutable​(java.io.File root,
                                                  java.lang.String path)
      • findJavaBin

        public static java.lang.String findJavaBin()
      • quote

        public static java.lang.String quote​(java.lang.String arg)
        Perform an optional quoting of the argument, being intelligent with spaces and quotes as needed. If a subString is set in quotes it won't the subString won't be escaped.
        Parameters:
        arg - the argument to quote
        Returns:
        the quoted and escaped argument
      • addArg

        public void addArg​(java.lang.String arg)
        Add a simple argument to the command line.

        Will quote arguments that have a space in them.

        Parameters:
        arg - the simple argument to add
      • addEqualsArg

        public void addEqualsArg​(java.lang.String name,
                                 java.lang.String value)
        Similar to addArg(String) but concats both name + value with an "=" sign, quoting were needed, and excluding the "=" portion if the value is undefined or empty.
           addEqualsArg("-Dname", "value") = "-Dname=value"
           addEqualsArg("-Djetty.home", "/opt/company inc/jetty (7)/") = "-Djetty.home=/opt/company\ inc/jetty\ (7)/"
           addEqualsArg("-Djenkins.workspace", "/opt/workspaces/jetty jdk7/") = "-Djenkins.workspace=/opt/workspaces/jetty\ jdk7/"
           addEqualsArg("-Dstress", null) = "-Dstress"
           addEqualsArg("-Dstress", "") = "-Dstress"
         
        Parameters:
        name - the name
        value - the value
      • addRawArg

        public void addRawArg​(java.lang.String arg)
        Add a simple argument to the command line.

        Will NOT quote/escape arguments that have a space in them.

        Parameters:
        arg - the simple argument to add
      • getArgs

        public java.util.List<java.lang.String> getArgs()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toString

        public java.lang.String toString​(java.lang.String delim)
      • debug

        public void debug()