Package tv.hd3g.fflauncher
Class ConversionTool
- java.lang.Object
-
- tv.hd3g.fflauncher.ConversionTool
-
-
Field Summary
Fields Modifier and Type Field Description static BiConsumer<tv.hd3g.processlauncher.cmdline.Parameters,String>APPEND_PARAM_AT_ENDprotected StringexecNameprotected List<tv.hd3g.fflauncher.ConversionToolParameterReference>inputSourcesprotected List<tv.hd3g.fflauncher.ConversionToolParameterReference>outputExpectedDestinationsprotected tv.hd3g.processlauncher.cmdline.Parametersparametersstatic BiConsumer<tv.hd3g.processlauncher.cmdline.Parameters,String>PREPEND_PARAM_AT_START
-
Constructor Summary
Constructors Modifier Constructor Description ConversionTool(String execName)protectedConversionTool(String execName, tv.hd3g.processlauncher.cmdline.Parameters parameters)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConversionTooladdInputSource(File source, String varNameInParameters, String... parametersBeforeInputSource)Add a parameters via an input reference, like: [parametersBeforeInputSource] {varNameInParameters replaced by source} For example, set source = "/myfile", varNameInParameters = "IN", parametersBeforeInputSource = [-i], For an parameters = "exec -VERBOSE <%IN%> -send <%OUT%>", you will get an updated parameters: "exec -VERBOSE -i /myfile -send <%OUT%>"ConversionTooladdInputSource(File source, String varNameInParameters, Collection<String> parametersBeforeInputSource)Add a parameters via an input reference, like: [parametersBeforeInputSource] {varNameInParameters replaced by source} [parametersAfterInputSource] For example, set source = "/myfile", varNameInParameters = "IN", parametersBeforeInputSource = [-i], parametersAfterInputSource = [-w], For an parameters = "exec -VERBOSE <%IN%> -send <%OUT%>", you will get an updated parameters: "exec -VERBOSE -i /myfile -w -send <%OUT%>"ConversionTooladdInputSource(String source, String varNameInParameters, String... parametersBeforeInputSource)Add a parameters via an input reference, like: [parametersBeforeInputSource] {varNameInParameters replaced by source} For example, set source = "myfile", varNameInParameters = "IN", parametersBeforeInputSource = [-i], For an parameters = "exec -VERBOSE <%IN%> -send <%OUT%>", you will get an updated parameters: "exec -VERBOSE -i myfile -send <%OUT%>"ConversionTooladdInputSource(String source, String varNameInParameters, Collection<String> parametersBeforeInputSource)Add a parameters via an input reference, like: [parametersBeforeInputSource] {varNameInParameters replaced by source} [parametersAfterInputSource] For example, set source = "myfile", varNameInParameters = "IN", parametersBeforeInputSource = [-i], parametersAfterInputSource = [-w], For an parameters = "exec -VERBOSE <%IN%> -send <%OUT%>", you will get an updated parameters: "exec -VERBOSE -i myfile -w -send <%OUT%>"ConversionTooladdOutputDestination(File destination, String varNameInParameters, String... parametersBeforeOutputDestination)Add a parameters via an output reference, like: [parametersBeforeOutputDestination] {varNameInParameters replaced by destination} For example, set destination = "myfile", varNameInParameters = "OUT", parametersBeforeOutputDestination = [-o], For an parameters = "exec -VERBOSE <%IN%> -send <%OUT%>", you will get an updated parameters: "exec -VERBOSE <%IN%> -send -o myfile"ConversionTooladdOutputDestination(File destination, String varNameInParameters, Collection<String> parametersBeforeOutputDestination)Add a parameters via an output reference, like: [parametersBeforeOutputDestination] {varNameInParameters replaced by destination} [parametersAfterOutputDestination] For example, set destination = "myfile", varNameInParameters = "OUT", parametersBeforeOutputDestination = [-o], parametersAfterOutputDestination = [-w], For an parameters = "exec -VERBOSE <%IN%> -send <%OUT%>", you will get an updated parameters: "exec -VERBOSE <%IN%> -send -o myfile -w"ConversionTooladdOutputDestination(String destination, String varNameInParameters, String... parametersBeforeOutputDestination)Add a parameters via an output reference, like: [parametersBeforeOutputDestination] {varNameInParameters replaced by destination} For example, set destination = "myfile", varNameInParameters = "OUT", parametersBeforeOutputDestination = [-o], For an parameters = "exec -VERBOSE <%IN%> -send <%OUT%>", you will get an updated parameters: "exec -VERBOSE <%IN%> -send -o myfile"ConversionTooladdOutputDestination(String destination, String varNameInParameters, Collection<String> parametersBeforeOutputDestination)Add a parameters via an output reference, like: [parametersBeforeOutputDestination] {varNameInParameters replaced by destination} [parametersAfterOutputDestination] For example, set destination = "myfile", varNameInParameters = "OUT", parametersBeforeOutputDestination = [-o], parametersAfterOutputDestination = [-w], For an parameters = "exec -VERBOSE <%IN%> -send <%OUT%>", you will get an updated parameters: "exec -VERBOSE <%IN%> -send -o myfile -w"ConversionTooladdSimpleOutputDestination(File destinationFile)Define cmd var name like <%OUT_AUTOMATIC_n%> with "n" the # of setted destination.ConversionTooladdSimpleOutputDestination(String destinationName)Define cmd var name like <%OUT_AUTOMATIC_n%> with "n" the # of setted destination.voidbeforeRun(tv.hd3g.processlauncher.ProcesslauncherBuilder processBuilder)ConversionToolcheckDestinations()Check read access for every files set in output.ConversionToolcheckSources()Check read access for every files set in input.ConversionToolcleanUpOutputFiles(boolean remove_all, boolean clean_output_directories)Don't need to be executed before.voidfixIOParametredVars(BiConsumer<tv.hd3g.processlauncher.cmdline.Parameters,String> onMissingInputVar, BiConsumer<tv.hd3g.processlauncher.cmdline.Parameters,String> onMissingOutputVar)Search and patch missing I/O parameter vars, and manageCollisionsParameters for each I/O entries.Optional<String>getDeclaredDestinationByVarName(String var_name)List<String>getDeclaredDestinations()Optional<String>getDeclaredSourceByVarName(String var_name)List<String>getDeclaredSources()StringgetExecutableName()Optional<Predicate<tv.hd3g.processlauncher.LineEntry>>getFilterForLinesEventsToDisplay()tv.hd3g.processlauncher.cmdline.ParametersgetInternalParameters()longgetMaxExecTime(TimeUnit unit)ScheduledExecutorServicegetMaxExecTimeScheduler()List<File>getOutputFiles(OutputFilePresencePolicy filterPolicy)Don't need to be executed before, only checks.Map<String,String>getParametersVariables()Set values for variables like <%myvar%> in the command line, do NOT set input/output references if they was set with addInputSource/addOutputDestination.tv.hd3g.processlauncher.cmdline.ParametersgetReadyToRunParameters()protected PrintStreamgetStdErrPrintStreamToDisplayLinesEvents()protected PrintStreamgetStdOutPrintStreamToDisplayLinesEvents()FilegetWorkingDirectory()booleanisCheckSourcesBeforeReady()booleanisOnErrorDeleteOutFiles()booleanisRemoveParamsIfNoVarToInject()protected voidonMissingInputOutputVar(String var_name, String ressource)protected StringpatchVarName(String rawVarName)ConversionToolsetCheckSourcesBeforeReady(boolean checkSourcesBeforeReady)True by default.ConversionToolsetFilterForLinesEventsToDisplay(Predicate<tv.hd3g.processlauncher.LineEntry> filterForLinesEventsToDisplay)ConversionToolsetMaxExecTimeScheduler(ScheduledExecutorService maxExecTimeScheduler)Enable the execution time limitationConversionToolsetMaxExecutionTimeForShortCommands(long max_exec_time, TimeUnit unit)You needs to provide a maxExecTimeSchedulerConversionToolsetOnErrorDeleteOutFiles(boolean onErrorDeleteOutFiles)ConversionToolsetRemoveParamsIfNoVarToInject(boolean remove_params_if_no_var_to_inject)ConversionToolsetWorkingDirectory(File workingDirectory)
-
-
-
Field Detail
-
execName
protected final String execName
-
inputSources
protected final List<tv.hd3g.fflauncher.ConversionToolParameterReference> inputSources
-
outputExpectedDestinations
protected final List<tv.hd3g.fflauncher.ConversionToolParameterReference> outputExpectedDestinations
-
parameters
protected final tv.hd3g.processlauncher.cmdline.Parameters parameters
-
APPEND_PARAM_AT_END
public static final BiConsumer<tv.hd3g.processlauncher.cmdline.Parameters,String> APPEND_PARAM_AT_END
-
PREPEND_PARAM_AT_START
public static final BiConsumer<tv.hd3g.processlauncher.cmdline.Parameters,String> PREPEND_PARAM_AT_START
-
-
Method Detail
-
isRemoveParamsIfNoVarToInject
public boolean isRemoveParamsIfNoVarToInject()
-
setRemoveParamsIfNoVarToInject
public ConversionTool setRemoveParamsIfNoVarToInject(boolean remove_params_if_no_var_to_inject)
-
setMaxExecutionTimeForShortCommands
public ConversionTool setMaxExecutionTimeForShortCommands(long max_exec_time, TimeUnit unit)
You needs to provide a maxExecTimeScheduler
-
setMaxExecTimeScheduler
public ConversionTool setMaxExecTimeScheduler(ScheduledExecutorService maxExecTimeScheduler)
Enable the execution time limitation
-
getMaxExecTime
public long getMaxExecTime(TimeUnit unit)
-
getMaxExecTimeScheduler
public ScheduledExecutorService getMaxExecTimeScheduler()
-
setFilterForLinesEventsToDisplay
public ConversionTool setFilterForLinesEventsToDisplay(Predicate<tv.hd3g.processlauncher.LineEntry> filterForLinesEventsToDisplay)
-
getFilterForLinesEventsToDisplay
public Optional<Predicate<tv.hd3g.processlauncher.LineEntry>> getFilterForLinesEventsToDisplay()
-
getParametersVariables
public Map<String,String> getParametersVariables()
Set values for variables like <%myvar%> in the command line, do NOT set input/output references if they was set with addInputSource/addOutputDestination.
-
addInputSource
public ConversionTool addInputSource(String source, String varNameInParameters, String... parametersBeforeInputSource)
Add a parameters via an input reference, like: [parametersBeforeInputSource] {varNameInParameters replaced by source} For example, set source = "myfile", varNameInParameters = "IN", parametersBeforeInputSource = [-i], For an parameters = "exec -VERBOSE <%IN%> -send <%OUT%>", you will get an updated parameters: "exec -VERBOSE -i myfile -send <%OUT%>"- Parameters:
source- can be another var name (mindfuck)
-
addInputSource
public ConversionTool addInputSource(File source, String varNameInParameters, String... parametersBeforeInputSource)
Add a parameters via an input reference, like: [parametersBeforeInputSource] {varNameInParameters replaced by source} For example, set source = "/myfile", varNameInParameters = "IN", parametersBeforeInputSource = [-i], For an parameters = "exec -VERBOSE <%IN%> -send <%OUT%>", you will get an updated parameters: "exec -VERBOSE -i /myfile -send <%OUT%>"
-
addInputSource
public ConversionTool addInputSource(String source, String varNameInParameters, Collection<String> parametersBeforeInputSource)
Add a parameters via an input reference, like: [parametersBeforeInputSource] {varNameInParameters replaced by source} [parametersAfterInputSource] For example, set source = "myfile", varNameInParameters = "IN", parametersBeforeInputSource = [-i], parametersAfterInputSource = [-w], For an parameters = "exec -VERBOSE <%IN%> -send <%OUT%>", you will get an updated parameters: "exec -VERBOSE -i myfile -w -send <%OUT%>"- Parameters:
source- can be another var name (mindfuck)parametersBeforeInputSource- can be null, and can be another var name (mindfuck)parametersAfterInputSource- can be null, and can be another var name (mindfuck)
-
addInputSource
public ConversionTool addInputSource(File source, String varNameInParameters, Collection<String> parametersBeforeInputSource)
Add a parameters via an input reference, like: [parametersBeforeInputSource] {varNameInParameters replaced by source} [parametersAfterInputSource] For example, set source = "/myfile", varNameInParameters = "IN", parametersBeforeInputSource = [-i], parametersAfterInputSource = [-w], For an parameters = "exec -VERBOSE <%IN%> -send <%OUT%>", you will get an updated parameters: "exec -VERBOSE -i /myfile -w -send <%OUT%>"- Parameters:
parametersBeforeInputSource- can be null, and can be another var name (mindfuck)parametersAfterInputSource- can be null, and can be another var name (mindfuck)
-
addOutputDestination
public ConversionTool addOutputDestination(String destination, String varNameInParameters, String... parametersBeforeOutputDestination)
Add a parameters via an output reference, like: [parametersBeforeOutputDestination] {varNameInParameters replaced by destination} For example, set destination = "myfile", varNameInParameters = "OUT", parametersBeforeOutputDestination = [-o], For an parameters = "exec -VERBOSE <%IN%> -send <%OUT%>", you will get an updated parameters: "exec -VERBOSE <%IN%> -send -o myfile"- Parameters:
destination- can be another var name (mindfuck)
-
addOutputDestination
public ConversionTool addOutputDestination(File destination, String varNameInParameters, String... parametersBeforeOutputDestination)
Add a parameters via an output reference, like: [parametersBeforeOutputDestination] {varNameInParameters replaced by destination} For example, set destination = "myfile", varNameInParameters = "OUT", parametersBeforeOutputDestination = [-o], For an parameters = "exec -VERBOSE <%IN%> -send <%OUT%>", you will get an updated parameters: "exec -VERBOSE <%IN%> -send -o myfile"
-
addOutputDestination
public ConversionTool addOutputDestination(String destination, String varNameInParameters, Collection<String> parametersBeforeOutputDestination)
Add a parameters via an output reference, like: [parametersBeforeOutputDestination] {varNameInParameters replaced by destination} [parametersAfterOutputDestination] For example, set destination = "myfile", varNameInParameters = "OUT", parametersBeforeOutputDestination = [-o], parametersAfterOutputDestination = [-w], For an parameters = "exec -VERBOSE <%IN%> -send <%OUT%>", you will get an updated parameters: "exec -VERBOSE <%IN%> -send -o myfile -w"- Parameters:
destination- can be another var name (mindfuck)parametersBeforeOutputDestination- can be null, and can be another var name (mindfuck)parametersAfterOutputDestination- can be null, and can be another var name (mindfuck)
-
addOutputDestination
public ConversionTool addOutputDestination(File destination, String varNameInParameters, Collection<String> parametersBeforeOutputDestination)
Add a parameters via an output reference, like: [parametersBeforeOutputDestination] {varNameInParameters replaced by destination} [parametersAfterOutputDestination] For example, set destination = "myfile", varNameInParameters = "OUT", parametersBeforeOutputDestination = [-o], parametersAfterOutputDestination = [-w], For an parameters = "exec -VERBOSE <%IN%> -send <%OUT%>", you will get an updated parameters: "exec -VERBOSE <%IN%> -send -o myfile -w"- Parameters:
parametersBeforeOutputDestination- can be null, and can be another var name (mindfuck)parametersAfterOutputDestination- can be null, and can be another var name (mindfuck)
-
getWorkingDirectory
public File getWorkingDirectory()
- Returns:
- Can be null.
-
setWorkingDirectory
public ConversionTool setWorkingDirectory(File workingDirectory) throws IOException
- Throws:
IOException
-
isOnErrorDeleteOutFiles
public boolean isOnErrorDeleteOutFiles()
-
setOnErrorDeleteOutFiles
public ConversionTool setOnErrorDeleteOutFiles(boolean onErrorDeleteOutFiles)
-
beforeRun
public void beforeRun(tv.hd3g.processlauncher.ProcesslauncherBuilder processBuilder)
- Specified by:
beforeRunin interfacetv.hd3g.processlauncher.tool.ExecutableTool
-
getStdOutPrintStreamToDisplayLinesEvents
protected PrintStream getStdOutPrintStreamToDisplayLinesEvents()
-
getStdErrPrintStreamToDisplayLinesEvents
protected PrintStream getStdErrPrintStreamToDisplayLinesEvents()
-
getDeclaredSourceByVarName
public Optional<String> getDeclaredSourceByVarName(String var_name)
- Parameters:
varName- with tags- Returns:
- never null
-
getDeclaredDestinationByVarName
public Optional<String> getDeclaredDestinationByVarName(String var_name)
- Parameters:
varName- with tags- Returns:
- never null
-
getDeclaredDestinations
public List<String> getDeclaredDestinations()
- Returns:
- never null, can be empty
-
addSimpleOutputDestination
public ConversionTool addSimpleOutputDestination(String destinationName)
Define cmd var name like <%OUT_AUTOMATIC_n%> with "n" the # of setted destination. Don't forget to call fixIOParametredVars() for add the new created var in current Parameters.
-
addSimpleOutputDestination
public ConversionTool addSimpleOutputDestination(File destinationFile)
Define cmd var name like <%OUT_AUTOMATIC_n%> with "n" the # of setted destination. Don't forget to call fixIOParametredVars() for add the new created var in current Parameters.
-
getOutputFiles
public List<File> getOutputFiles(OutputFilePresencePolicy filterPolicy)
Don't need to be executed before, only checks.
-
cleanUpOutputFiles
public ConversionTool cleanUpOutputFiles(boolean remove_all, boolean clean_output_directories)
Don't need to be executed before.- Parameters:
remove_all- if false, remove only empty files.
-
getInternalParameters
public tv.hd3g.processlauncher.cmdline.Parameters getInternalParameters()
- Returns:
- without variable injection
-
setCheckSourcesBeforeReady
public ConversionTool setCheckSourcesBeforeReady(boolean checkSourcesBeforeReady)
True by default. Force to check read access for every files set in input.- Returns:
- this
-
isCheckSourcesBeforeReady
public boolean isCheckSourcesBeforeReady()
- Returns:
- true by default. Force to check read access for every files set in input.
-
checkSources
public ConversionTool checkSources()
Check read access for every files set in input.- Throws:
RuntimeException
-
checkDestinations
public ConversionTool checkDestinations()
Check read access for every files set in output.- Throws:
RuntimeException
-
fixIOParametredVars
public void fixIOParametredVars(BiConsumer<tv.hd3g.processlauncher.cmdline.Parameters,String> onMissingInputVar, BiConsumer<tv.hd3g.processlauncher.cmdline.Parameters,String> onMissingOutputVar)
Search and patch missing I/O parameter vars, and manageCollisionsParameters for each I/O entries.- Parameters:
onMissingInputVar- you can manually add the var (the String value provided) in the provided ParametersonMissingOutputVar- you can manually add the var (the String value provided) in the provided Parameters
-
getReadyToRunParameters
public tv.hd3g.processlauncher.cmdline.Parameters getReadyToRunParameters()
- Specified by:
getReadyToRunParametersin interfacetv.hd3g.processlauncher.tool.ExecutableTool- Returns:
- a copy form internal parameters, with variable injection
-
getExecutableName
public String getExecutableName()
- Specified by:
getExecutableNamein interfacetv.hd3g.processlauncher.tool.ExecutableTool
-
-