Class ExternalContentTransformation
- java.lang.Object
-
- org.eclipse.epsilon.picto.transformers.ExternalContentTransformation
-
- All Implemented Interfaces:
java.lang.Runnable
,java.util.concurrent.Callable<byte[]>
public class ExternalContentTransformation extends java.lang.Object implements java.lang.Runnable, java.util.concurrent.Callable<byte[]>
Utility class for using external programs in transforming content.- Since:
- 2.2
- Author:
- Sina Madani
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String[]
args
protected boolean
hasRun
protected java.nio.file.Path
logFile
protected java.nio.file.Path
outputFile
protected java.lang.String
processOutput
protected java.lang.String
program
protected byte[]
result
protected int
resultCode
protected java.time.Duration
timeout
-
Constructor Summary
Constructors Modifier Constructor Description protected
ExternalContentTransformation(java.lang.String program, java.lang.Object... arguments)
ExternalContentTransformation(java.nio.file.Path outputFile, java.lang.String program, java.lang.Object... arguments)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
call()
static java.nio.file.Path
createTempFile(java.lang.String extension, byte... contents)
Convenience method for temporary files used in intermediate transformations.java.lang.String[]
getArgs()
java.io.IOException
getException()
java.nio.file.Path
getLogFile()
java.nio.file.Path
getOutputFile()
java.lang.String
getProcessOutput()
java.lang.String
getProgram()
byte[]
getResult()
int
getResultCode()
java.time.Duration
getTimeout()
static java.lang.String
resolveNodeProgram(java.lang.String program)
void
run()
protected void
screenRun()
void
setLogFile(java.nio.file.Path logFile)
void
setOutputFile(java.nio.file.Path outputFile)
void
setTimeout(java.time.Duration timeout)
-
-
-
Field Detail
-
program
protected final java.lang.String program
-
args
protected final java.lang.String[] args
-
timeout
protected java.time.Duration timeout
-
logFile
protected java.nio.file.Path logFile
-
outputFile
protected java.nio.file.Path outputFile
-
resultCode
protected int resultCode
-
hasRun
protected boolean hasRun
-
result
protected byte[] result
-
processOutput
protected java.lang.String processOutput
-
-
Constructor Detail
-
ExternalContentTransformation
protected ExternalContentTransformation(java.lang.String program, java.lang.Object... arguments)
-
ExternalContentTransformation
public ExternalContentTransformation(java.nio.file.Path outputFile, java.lang.String program, java.lang.Object... arguments)
-
-
Method Detail
-
createTempFile
public static java.nio.file.Path createTempFile(java.lang.String extension, byte... contents) throws java.io.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:
java.io.IOException
- If the temp file couldn't be created.
-
resolveNodeProgram
public static java.lang.String resolveNodeProgram(java.lang.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 java.lang.IllegalStateException
- Throws:
java.lang.IllegalStateException
-
getResult
public byte[] getResult() throws java.io.IOException
- Throws:
java.io.IOException
-
run
public final void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
call
public byte[] call() throws java.io.IOException
- Specified by:
call
in interfacejava.util.concurrent.Callable<byte[]>
- Throws:
java.io.IOException
-
getException
public java.io.IOException getException()
-
getLogFile
public java.nio.file.Path getLogFile()
-
setLogFile
public void setLogFile(java.nio.file.Path logFile)
-
getOutputFile
public java.nio.file.Path getOutputFile()
-
setOutputFile
public void setOutputFile(java.nio.file.Path outputFile)
-
getTimeout
public java.time.Duration getTimeout()
-
setTimeout
public void setTimeout(java.time.Duration timeout)
-
getProgram
public java.lang.String getProgram()
-
getArgs
public java.lang.String[] getArgs()
-
getProcessOutput
public java.lang.String getProcessOutput()
- Returns:
- The stdout of the invoked program.
- Throws:
java.lang.IllegalStateException
- If the program hasn't been run yet.
-
-