org.apache.camel.component.exec
Class ExecResultConverter

java.lang.Object
  extended by org.apache.camel.component.exec.ExecResultConverter

@Converter
public final class ExecResultConverter
extends Object

Default converters for ExecResult. For details how to extend the converters check out the Camel docs for type converters.


Method Summary
static
<T> T
convertTo(Class<T> type, Exchange exchange, ExecResult result)
          Converts ExecResult to the type T.
static byte[] convertToByteArray(ExecResult result, Exchange exchange)
           
static Document convertToDocument(ExecResult result, Exchange exchange)
           
static InputStream convertToInputStream(ExecResult result)
           
static String convertToString(ExecResult result, Exchange exchange)
           
static InputStream toInputStream(ExecResult execResult)
          Returns InputStream object with the output of the executable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

convertToInputStream

@Converter
public static InputStream convertToInputStream(ExecResult result)
                                        throws FileNotFoundException
Throws:
FileNotFoundException

convertToByteArray

@Converter
public static byte[] convertToByteArray(ExecResult result,
                                                  Exchange exchange)
                                 throws FileNotFoundException,
                                        IOException
Throws:
FileNotFoundException
IOException

convertToString

@Converter
public static String convertToString(ExecResult result,
                                               Exchange exchange)
                              throws FileNotFoundException
Throws:
FileNotFoundException

convertToDocument

@Converter
public static Document convertToDocument(ExecResult result,
                                                   Exchange exchange)
                                  throws FileNotFoundException
Throws:
FileNotFoundException

convertTo

public static <T> T convertTo(Class<T> type,
                              Exchange exchange,
                              ExecResult result)
                   throws FileNotFoundException
Converts ExecResult to the type T.

Type Parameters:
T - The type to convert to
Parameters:
type - Class instance of the type to which to convert
exchange - a Camel exchange. If exchange is null, no conversion will be made
result - the exec result
Returns:
the converted ExecResult
Throws:
FileNotFoundException - if there is a file in the execResult, and the file can not be found

toInputStream

public static InputStream toInputStream(ExecResult execResult)
                                 throws FileNotFoundException
Returns InputStream object with the output of the executable. If there is ExecCommand.getOutFile(), its content is preferred to ExecResult.getStdout(). If no out file is set, and the stdout of the exec result is null returns the stderr of the exec result.
If the output stream is of type ByteArrayInputStream, its reset() method is called.

Parameters:
execResult - ExecResult object to convert to InputStream.
Returns:
InputStream object with the output of the executable. Returns null if both ExecResult.getStdout() and ExecResult.getStderr() are null , or if the execResult is null.
Throws:
FileNotFoundException - if the ExecCommand.getOutFile() can not be opened. In this case the out file must have had a not null value


Copyright © 2007-2010 The Apache Software Foundation. All Rights Reserved.