Package org.aksw.commons.io.process.pipe
Class ProcessPipeUtils
- java.lang.Object
-
- org.aksw.commons.io.process.pipe.ProcessPipeUtils
-
public class ProcessPipeUtils extends Object
Utility functions to create file and input stream transform based on system calls InputStreams passed as arguments to the various processors are considered to be owned by the processors. Hence, the processors are in charge of closing them. The client code is in charge of closing InputStreams returned by the processors. TODO Enhance the FileCreation objects such that they expose a future for when the process started modifying the file.- Author:
- raven
-
-
Constructor Summary
Constructors Constructor Description ProcessPipeUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FileCreationcreateFileCreation(Process process, Path path)static java.util.function.Function<InputStream,InputStream>createPipedTransformer(java.util.function.BiConsumer<InputStream,OutputStream> action)TODO Move this method elsewhere as it does not make use of a process Transformation using a piped input/outputstream createPipedTransform((in, out) -> { for(item : () -> readItems(in)) { write(item); } )static java.util.function.BiFunction<Path,Path,FileCreation>mapPathToPath(java.util.function.BiFunction<Path,Path,String[]> cmdBuilder)static PathToStreammapPathToStream(java.util.function.Function<Path,String[]> cmdBuilder)static java.util.function.BiFunction<InputStreamOrPath,Path,FileCreation>mapStreamToPath(java.util.function.Function<Path,String[]> cmdBuilder)static StreamToStreammapStreamToStream(String[] cmd)static ProcessstartProcess(ProcessBuilder processBuilder)static ThreadstartThreadedCopy(InputStream from, OutputStream to, java.util.function.Consumer<Exception> failureCallback)Create a new thread to copy from source to target TODO Closing the target silently terminate the thread and associated resources (such as a system process) Closing the input stream should not happen though as it is considered to be owned by the copy process
-
-
-
Method Detail
-
createPipedTransformer
public static java.util.function.Function<InputStream,InputStream> createPipedTransformer(java.util.function.BiConsumer<InputStream,OutputStream> action)
TODO Move this method elsewhere as it does not make use of a process Transformation using a piped input/outputstream createPipedTransform((in, out) -> { for(item : () -> readItems(in)) { write(item); } )- Parameters:
action-- Returns:
-
startThreadedCopy
public static Thread startThreadedCopy(InputStream from, OutputStream to, java.util.function.Consumer<Exception> failureCallback)
Create a new thread to copy from source to target TODO Closing the target silently terminate the thread and associated resources (such as a system process) Closing the input stream should not happen though as it is considered to be owned by the copy process- Parameters:
from-to-- Returns:
-
startProcess
public static Process startProcess(ProcessBuilder processBuilder)
-
mapPathToStream
public static PathToStream mapPathToStream(java.util.function.Function<Path,String[]> cmdBuilder)
-
createFileCreation
public static FileCreation createFileCreation(Process process, Path path)
-
mapStreamToPath
public static java.util.function.BiFunction<InputStreamOrPath,Path,FileCreation> mapStreamToPath(java.util.function.Function<Path,String[]> cmdBuilder)
-
mapPathToPath
public static java.util.function.BiFunction<Path,Path,FileCreation> mapPathToPath(java.util.function.BiFunction<Path,Path,String[]> cmdBuilder)
-
mapStreamToStream
public static StreamToStream mapStreamToStream(String[] cmd)
-
-