com.xebialabs.deployit.hostsession
Class CapturingCommandExecutionCallbackHandler

java.lang.Object
  extended by com.xebialabs.deployit.hostsession.CapturingCommandExecutionCallbackHandler
All Implemented Interfaces:
CommandExecutionCallbackHandler

public final class CapturingCommandExecutionCallbackHandler
extends java.lang.Object
implements CommandExecutionCallbackHandler

An implementation of the CommandExecutionCallbackHandler that captures the output in variables.


Constructor Summary
CapturingCommandExecutionCallbackHandler()
          Creates a CommandExecutionCallbackHandler.
CapturingCommandExecutionCallbackHandler(boolean debug)
          Creates a CommandExecutionCallbackHandler that can be configured to debug the output.
 
Method Summary
 java.lang.String getAll()
          Returns the captured regular and error output, with the lines separated by "\n".
 java.util.List<java.lang.String> getAllLines()
          Returns the captured regular and error output lines.
 java.lang.String getError()
          Returns the captured error output, with the lines separated by "\n".
 java.util.List<java.lang.String> getErrorLines()
          Returns the captured error output lines.
 java.lang.String getOutput()
          Returns the captured regular output, with the lines separated by "\n".
 java.util.List<java.lang.String> getOutputLines()
          Returns the captured regular output lines.
 void handleErrorLine(java.lang.String line)
          Invoked when an executed command generated a line of error (stderr).
 void handleOutput(char c)
          Invoked when an executed command generates a character of output (stdout).
 void handleOutputLine(java.lang.String line)
          Invoked when an executed command generated a line of output (stdout).
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CapturingCommandExecutionCallbackHandler

public CapturingCommandExecutionCallbackHandler()
Creates a CommandExecutionCallbackHandler.


CapturingCommandExecutionCallbackHandler

public CapturingCommandExecutionCallbackHandler(boolean debug)
Creates a CommandExecutionCallbackHandler that can be configured to debug the output.

Parameters:
debug - if true, output is printed to System.out and System.err in addition to being captured.
Method Detail

handleOutputLine

public void handleOutputLine(java.lang.String line)
Description copied from interface: CommandExecutionCallbackHandler
Invoked when an executed command generated a line of output (stdout).

Specified by:
handleOutputLine in interface CommandExecutionCallbackHandler
Parameters:
line - the line of output generated.

handleErrorLine

public void handleErrorLine(java.lang.String line)
Description copied from interface: CommandExecutionCallbackHandler
Invoked when an executed command generated a line of error (stderr).

Specified by:
handleErrorLine in interface CommandExecutionCallbackHandler
Parameters:
line - the line of output generated.

handleOutput

public void handleOutput(char c)
Description copied from interface: CommandExecutionCallbackHandler
Invoked when an executed command generates a character of output (stdout).

Specified by:
handleOutput in interface CommandExecutionCallbackHandler
Parameters:
c - the character of output generated.

getOutputLines

public java.util.List<java.lang.String> getOutputLines()
Returns the captured regular output lines.

Returns:
a list of captured regular output lines.

getOutput

public java.lang.String getOutput()
Returns the captured regular output, with the lines separated by "\n".

Returns:
the captured regular output as one string.

getErrorLines

public java.util.List<java.lang.String> getErrorLines()
Returns the captured error output lines.

Returns:
a list of captured error output lines.

getError

public java.lang.String getError()
Returns the captured error output, with the lines separated by "\n".

Returns:
the captured error output as one string.

getAllLines

public java.util.List<java.lang.String> getAllLines()
Returns the captured regular and error output lines.

Returns:
a list of captured error regular and output lines.

getAll

public java.lang.String getAll()
Returns the captured regular and error output, with the lines separated by "\n".

Returns:
the captured regular and error output as one string.

toString

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


Copyright © 2010. All Rights Reserved.