terp - the Codemesh Modular
Template Interpreter v1.3.337

com.codemesh.terp.eval.executors
Class ProcessExecutor.Result

java.lang.Object
  extended by com.codemesh.terp.eval.executors.ProcessExecutor.Result
Enclosing class:
ProcessExecutor

public static class ProcessExecutor.Result
extends java.lang.Object

The result of any ProcessExecutor invocation. This type wraps all outcomes of a process invocation. You have access to the exitCode, the stdout and stderr outputs in line and raw form, and a potssibly thrown exception.

When executing in the context of ANT, you usually use instances of this type in <terp.fail> or <terp.property> tasks after a <terp.exec>. The <terp.exec> sets an instance of this type into a result property and you can then query its members for additional information.

Example

In the following example, the listing output will be available in the 'listing' property together with all other information about the result of the shell command execution.
 <terp.exec  expression="^shell()('ls -la .')"
             result="listing"
             failonerror="false"
             if="os.family!='windows'"
 />
 <terp.property name="output" expression="listing.outraw" />
 


Constructor Summary
ProcessExecutor.Result(java.io.OutputStream os, java.io.OutputStream es, java.lang.Throwable t, int exitCode)
           
 
Method Summary
 java.lang.String[] getErr()
          Returns the output written by the process to stderr as an array of lines without eols.
 java.lang.String getErrRaw()
          Returns the output written by the process to stderr as one string.
 java.lang.Throwable getException()
          Returns the exception thrown by the Java process APIs or null if no exception was thrown.
 int getExitCode()
          Returns the process' exit code.
 java.lang.String[] getOut()
          Returns the output written by the process to stdout as an array of lines without eols.
 java.lang.String getOutRaw()
          Returns the output written by the process to stdout as one string.
 java.lang.String toString()
          Returns a string representation of the entire ProcessResult instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProcessExecutor.Result

public ProcessExecutor.Result(java.io.OutputStream os,
                              java.io.OutputStream es,
                              java.lang.Throwable t,
                              int exitCode)
Method Detail

getExitCode

public int getExitCode()
Returns the process' exit code. Most processes return 0 to represent success. Any other value is usually indicative of some kind of failure.

Returns:
the integer value returned by the process.

getException

public java.lang.Throwable getException()
Returns the exception thrown by the Java process APIs or null if no exception was thrown.

Returns:
an exception or null.

getOutRaw

public java.lang.String getOutRaw()
Returns the output written by the process to stdout as one string.

Returns:
the process' stdout output.

getOut

public java.lang.String[] getOut()
Returns the output written by the process to stdout as an array of lines without eols.

Returns:
the process' stdout output.

getErrRaw

public java.lang.String getErrRaw()
Returns the output written by the process to stderr as one string.

Returns:
the process' stderr output.

getErr

public java.lang.String[] getErr()
Returns the output written by the process to stderr as an array of lines without eols.

Returns:
the process' stderr output.

toString

public java.lang.String toString()
Returns a string representation of the entire ProcessResult instance.

Overrides:
toString in class java.lang.Object
Returns:
an informative string representation of the object.

terp - the Codemesh Modular
Template Interpreter v1.3.337

Copyright © 2008-2016 by Codemesh, Inc. All Rights Reserved.