| java.lang.Object | |
| ↳ | com.atlassian.bitbucket.scm.AbstractCommandBuilder<B extends com.atlassian.bitbucket.scm.CommandBuilder<B>> | 
|  Known Direct Subclasses 
          
            
              AbstractScmCommandBuilder<B extends ScmCommandBuilder<B>>
            
          
       | 
Provides a basic implementation of most CommandBuilder functionality, to simplify creating builders.
 All CommandBuilder and CommandBuilderSupport methods are implemented except for the actual
 build method.
| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| arguments | Maintains an ordered list of arguments. | ||||||||||
| binary | The binary to execute when the command is run. | ||||||||||
| environment | Maintains a map of environment variables and their values. | ||||||||||
| errorHandler | The CommandErrorHandler to receive and process the InputStreamfor reading data from the
 command's error stream. | ||||||||||
| exitHandler | The CommandExitHandler to be invoked when the command runs. | ||||||||||
| i18nService | The I18nService, used to internationalise error messages for exceptions thrown during processing. | ||||||||||
| inputHandler | The CommandInputHandler to receive and process the OutputStreamfor feeding data into the
 command. | ||||||||||
| workingDirectory | The working directory in which the command should be run. | ||||||||||
| Protected Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Constructs a new  AbstractCommandBuilderand sets theI18nServiceto use for internationalising
 error messages and thebinaryto execute. | |||||||||||
| Constructs a new  AbstractCommandBuilder, sets theI18nServiceto use for internationalising
 error messages and thebinaryto execute, and optionally sets theworkingDirectorywhere it
 should be executed. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Finds the index of the specified  anchorand inserts the providedargumentimmediately after it
 in thearguments. | |||||||||||
| Finds the index of the specified  anchorand inserts the providedargumentdirectly before it in
 thearguments. | |||||||||||
| Clears the  arguments, but does notnullor replace the list instance. | |||||||||||
| Clears the  environment, but does notnullor replace the map instance. | |||||||||||
| Clears the  inputHandler, setting it tonull. | |||||||||||
| Indicates the default CommandErrorHandler should be applied when  build(CommandOutputHandler)is
 called by setting theerrorHandlertonull. | |||||||||||
| Indicates the default CommandExitHandler should be applied when  build(CommandOutputHandler)is
 called by setting theexitHandlertonull. | |||||||||||
| Indicates the default working directory should be used when  build(CommandOutputHandler)is called by
 setting theworkingDirectorytonull. | |||||||||||
| Sets the provided  valueas theerrorHandlerto use for processing the standard error stream
 when the built command is executed. | |||||||||||
| Sets the provided  valueas theexitHandlerto be called when the built command exits or is
 canceled. | |||||||||||
| Sets the provided  valueas theinputHandlerto use for providing data on the standard input
 stream when the built command is executed. | |||||||||||
| Clears the environment variable of the provided  nameif it has been set | |||||||||||
| Puts the provided  valuein theenvironmentmap with the specifiedname, after ensuring
 both thenameandvaluearenot blank. | |||||||||||
| Sets the provided  valueas theworkingDirectoryto use when the built command is executed. | |||||||||||
| Sets the provided  valueas theworkingDirectoryto use when the built command is executed. | |||||||||||
| Constructs a  Filefrom the providedvalueandsets itas the
 working directory to use when the built command is executed. | |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Ensures the provided  Fileis notnull, exists and is a directory. | |||||||||||
| Ensures the provided  Fileisnull, or that it exists and is a directory. | |||||||||||
| Ensures the provided value is not  null, empty or blank. | |||||||||||
| Ensures the provided argument is not  null, empty or blank. | |||||||||||
| Returns a reference to the current builder, typed correctly to appease Java generics. | |||||||||||
| [Expand] Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|  From class
  java.lang.Object | |||||||||||
|  From interface
  com.atlassian.bitbucket.scm.CommandBuilder | |||||||||||
|  From interface
  com.atlassian.bitbucket.scm.CommandBuilderSupport | |||||||||||
Maintains an ordered list of arguments. LinkedList is used to optimise insertion, since the argument
 list is modified more than it is read.
 
Derived classes may add and remove arguments, but they may not replace the list reference.
The binary to execute when the command is run. This must be provided to the constructor, cannot be null
 and may not be updated.
 
 Note: When constructing the Command in build(CommandOutputHandler), the derived class may opt
 to use an alternative, equivalent binary. For example, when using git, give a binary of "git" and a first
 argument of "http-backend", the builder may opt to call git-http-backend (from libexec/git-core)
 rather than git http-backend.
Maintains a map of environment variables and their values.
Derived classes may add, replace and remove keys and their values, but they may not replace the map reference.
 Note: Java's ProcessBuilder.environment does not support null keys or values. Derived
 classes should validate entries before they are put into the map to ensure they do not violate that contract.
The CommandErrorHandler to receive and process the InputStream for reading data from the
 command's error stream. This field may be null, but when it is implementations should apply a default
 when building the Command. The default should be accumulate error stream output to provide to the
 CommandExitHandler.
The CommandExitHandler to be invoked when the command runs. This field may be null, but when it
 is implementations should apply a default when building the Command.
The I18nService, used to internationalise error messages for exceptions thrown during processing.
The CommandInputHandler to receive and process the OutputStream for feeding data into the
 command. Not all commands will support input, so this field may be null.
The working directory in which the command should be run. Per the contract for ProcessBuilder.directory,
 this field may be null to use the Java process's working directory.
Constructs a new AbstractCommandBuilder and sets the I18nService to use for internationalising
 error messages and the binary to execute.
| i18nService | the I18nServicefor internationalising error messages | 
|---|---|
| binary | the binary to execute | 
| IllegalArgumentException | if the provided binaryis empty or blank | 
|---|---|
| NullPointerException | if the provided i18nServiceorbinaryisnull | 
Constructs a new AbstractCommandBuilder, sets the I18nService to use for internationalising
 error messages and the binary to execute, and optionally sets the workingDirectory where it
 should be executed.
| i18nService | the I18nServicefor internationalising error messages | 
|---|---|
| binary | the binary to execute | 
| workingDirectory | the working directory for the command, or nullfor the default | 
| IllegalArgumentException | if the provided binaryis empty or blank, or if a working directory
                                  is provided which does not exist or is not a directory | 
|---|---|
| NullPointerException | if the provided i18nServiceorbinaryisnull | 
| argument | the argument to append to the command | 
|---|
| IllegalArgumentException | if the provided argumentis empty or blank | 
|---|---|
| NullPointerException | if the privided argumentisnull | 
Finds the index of the specified anchor and inserts the provided argument immediately after it
 in the arguments. If the anchor is not found, the provided argument is appended at the
 end of the argument list.
| anchor | the argument serving as the anchor for the new argument | 
|---|---|
| argument | the argument to add immediately after the specified anchor | 
| IllegalArgumentException | if the provided anchororargumentis empty or blank | 
|---|---|
| NullPointerException | if the provided anchororargumentisnull | 
Inserts the provided argument at the specified index in the arguments, after ensuring
 it is not blank.
| index | the index at which the argument should be inserted | 
|---|---|
| argument | the argument to insert at the specified index | 
| IllegalArgumentException | if the provided argumentis empty or blank | 
|---|---|
| IndexOutOfBoundsException | if the specified indexis out of range for the argument list | 
| NullPointerException | if the provided argumentisnull | 
Finds the index of the specified anchor and inserts the provided argument directly before it in
 the arguments. If the anchor is not found, the provided argument is appended at the end
 of the argument list.
| anchor | the argument serving as the anchor for the new argument | 
|---|---|
| argument | the argument to add immediately before the specified anchor | 
| IllegalArgumentException | if the provided anchororargumentis empty or blank | 
|---|---|
| NullPointerException | if the provided anchororargumentisnull | 
Clears the environment, but does not null or replace the map instance.
Indicates the default CommandErrorHandler should be applied when build(CommandOutputHandler) is
 called by setting the errorHandler to null.
 
 Derived classes may override this to preemptively set the default error handler, or they may apply the default
 in build(CommandOutputHandler) when the errorHandler field is null. The latter is the
 preferred approach, as it does not require code using the builder to call this method to trigger applying the
 default handler.
Indicates the default CommandExitHandler should be applied when build(CommandOutputHandler) is
 called by setting the exitHandler to null.
 
 Derived classes may override this to preemptively set the default exit handler, or they may apply the default
 in build(CommandOutputHandler) when the exitHandler field is null. The latter is the
 preferred approach, as it does not require code using the builder to call this method to trigger applying the
 default handler.
Indicates the default working directory should be used when build(CommandOutputHandler) is called by
 setting the workingDirectory to null. This is consistent with ProcessBuilder.
Sets the provided value as the errorHandler to use for processing the standard error stream
 when the built command is executed.
 
 Note: As described on the CommandErrorHandler and CommandExitHandler interfaces, providing an
 error handler will prevent the exit handler from receiving any output
 written to the standard error stream.
| value | the handler to receive and process the command's error stream | 
|---|
| NullPointerException | if the provided valueisnull | 
|---|
Sets the provided value as the exitHandler to be called when the built command exits or is
 canceled.
 
 Note: As described on the CommandErrorHandler and CommandExitHandler interfaces, providing an
 error handler will prevent the exit handler from receiving any output
 written to the standard error stream.
| value | the handler which should be invoked when the command exits | 
|---|
| NullPointerException | if the provided valueisnull | 
|---|
Sets the provided value as the inputHandler to use for providing data on the standard input
 stream when the built command is executed.
| value | the handler to receive and process the command's input stream | 
|---|
| NullPointerException | if the provided valueisnull | 
|---|
Clears the environment variable of the provided name if it has been set
| name | the name of the environment variable to clear | 
|---|
Puts the provided value in the environment map with the specified name, after ensuring
 both the name and value are not blank.
| name | the name of the environment variable to set | 
|---|---|
| value | the value to set for the environment variable | 
| IllegalArgumentException | if the provided nameorvalueis empty or blank | 
|---|---|
| NullPointerException | if the provided nameorvalueisnull | 
Sets the provided value as the workingDirectory to use when the built command is executed.
| value | the desired working directory | 
|---|
| IllegalArgumentException | if the provided valuedoes not exist, or does not reference a directory | 
|---|---|
| NullPointerException | if the provided valueisnull | 
Sets the provided value as the workingDirectory to use when the built command is executed.
| value | the desired working directory | 
|---|
| IllegalArgumentException | if the provided valuedoes not exist, or does not reference a directory | 
|---|---|
| NullPointerException | if the provided valueisnull | 
Constructs a File from the provided value and sets it as the
 working directory to use when the built command is executed.
| value | the absolute path to the desired working directory | 
|---|
| IllegalArgumentException | if the provided valuedoes not exist, or does not reference a directory | 
|---|---|
| NullPointerException | if the provided valueisnull | 
Ensures the provided File is not null, exists and is a directory.
| value | the Fileto validate | 
|---|
value| IllegalArgumentException | if the provided valuedoes not exist, or does not reference a directory | 
|---|---|
| NullPointerException | if the provided valueisnull | 
Ensures the provided File is null, or that it exists and is a directory.
| value | the Fileto validate | 
|---|
value, which may be null| IllegalArgumentException | if the provided valueis notnullbut does not exist, or does
                                  not reference a directory | 
|---|
Ensures the provided value is not null, empty or blank. The returned value is trimmed to remove
 both leading and trailing whitespace.
| value | the value to validate | 
|---|---|
| name | the value's name, used in exception messages | 
value, trimmed| IllegalArgumentException | if the provided valueis empty or blank | 
|---|---|
| NullPointerException | if the provided valueisnull | 
Ensures the provided argument is not null, empty or blank. The returned argument is trimmed to remove
 both leading and trailing whitespace.
| argument | the argument to validate | 
|---|
argument, trimmed| IllegalArgumentException | if the provided argumentis empty or blank | 
|---|---|
| NullPointerException | if the provided argumentisnull | 
Returns a reference to the current builder, typed correctly to appease Java generics.
 Implementations of this method on derived builders are encouraged to use a covariant return type to return the
 actual implementation class. For example:
 
     public interface MyBuilder extends CommandBuilder<MyBuilder> {
         //Implementation omitted
     }
     public class DefaultMyBuilder extends AbstractCommandBuilder<MyBuilder> implements MyBuilder {
         //Implementation omitted
         @Override
         protected DefaultMyBuilder self() {
             return this;
         }
     }
 
this, in a derived class