Class ExternalContentTransformation

java.lang.Object
org.eclipse.epsilon.picto.transformers.ExternalContentTransformation
All Implemented Interfaces:
Runnable, Callable<byte[]>

public class ExternalContentTransformation extends Object implements Runnable, Callable<byte[]>
Utility class for using external programs in transforming content.
Since:
2.2
Author:
Sina Madani
  • Field Details

    • program

      protected final String program
    • args

      protected final String[] args
    • timeout

      protected Duration timeout
    • logFile

      protected Path logFile
    • outputFile

      protected Path outputFile
    • resultCode

      protected int resultCode
    • hasRun

      protected boolean hasRun
    • result

      protected byte[] result
    • processOutput

      protected String processOutput
  • Constructor Details

    • ExternalContentTransformation

      protected ExternalContentTransformation(String program, Object... arguments)
    • ExternalContentTransformation

      public ExternalContentTransformation(Path outputFile, String program, Object... arguments)
  • Method Details

    • createTempFile

      public static Path createTempFile(String extension, byte... contents) throws IOException
      Convenience method for temporary files used in intermediate transformations.
      Parameters:
      extension - The file extension.
      contents - The initial contents of the file. May be null.
      Returns:
      The absolute path of the temporary file.
      Throws:
      IOException - If the temp file couldn't be created.
    • resolveNodeProgram

      public static String resolveNodeProgram(String program)
      Parameters:
      program - The Node.js program name.
      Returns:
      The absolute path of the command needed to invoke the program.
    • getResultCode

      public int getResultCode()
    • screenRun

      protected void screenRun() throws IllegalStateException
      Throws:
      IllegalStateException
    • getResult

      public byte[] getResult() throws IOException
      Throws:
      IOException
    • run

      public final void run()
      Specified by:
      run in interface Runnable
    • call

      public byte[] call() throws IOException
      Specified by:
      call in interface Callable<byte[]>
      Throws:
      IOException
    • getException

      public IOException getException()
    • getLogFile

      public Path getLogFile()
    • setLogFile

      public void setLogFile(Path logFile)
    • getOutputFile

      public Path getOutputFile()
    • setOutputFile

      public void setOutputFile(Path outputFile)
    • getTimeout

      public Duration getTimeout()
    • setTimeout

      public void setTimeout(Duration timeout)
    • getProgram

      public String getProgram()
    • getArgs

      public String[] getArgs()
    • getProcessOutput

      public String getProcessOutput()
      Returns:
      The stdout of the invoked program.
      Throws:
      IllegalStateException - If the program hasn't been run yet.