Package org.pipecraft.pipes.sync.inter
Class IntermediateTxtFileWriterPipe<T>
- java.lang.Object
-
- org.pipecraft.pipes.sync.inter.DelegatePipe<T>
-
- org.pipecraft.pipes.sync.inter.IntermediateTxtFileWriterPipe<T>
-
- All Implemented Interfaces:
Closeable,AutoCloseable,BasePipe,Pipe<T>
public class IntermediateTxtFileWriterPipe<T> extends DelegatePipe<T>
A pipe write to a text file any item passed through it. The write callback is never invoked on null values which indicate end of input pipe. Pipe output is same as pipe input. In order to write the object as a string, a string mapper must be provided.- Author:
- Shai Barad
-
-
Constructor Summary
Constructors Constructor Description IntermediateTxtFileWriterPipe(Pipe<T> input, File output, Charset charset, FailableFunction<T,String,PipeException> stringMapper)Constructor Uses default file write options.IntermediateTxtFileWriterPipe(Pipe<T> input, File output, Charset charset, FileWriteOptions options)Constructor Uses the toString as the mapper from the object to StringIntermediateTxtFileWriterPipe(Pipe<T> input, File output, Charset charset, FileWriteOptions options, FailableFunction<T,String,PipeException> stringMapper)ConstructorIntermediateTxtFileWriterPipe(Pipe<T> input, File output, FailableFunction<T,String,PipeException> stringMapper)Constructor Uses default file write options and UTF8.IntermediateTxtFileWriterPipe(Pipe<T> input, File output, FileWriteOptions options)Constructor Uses default toString() as the string mapper, and UTF8IntermediateTxtFileWriterPipe(Pipe<T> input, File output, FileWriteOptions options, FailableFunction<T,String,PipeException> stringMapper)Constructor Uses UTF8
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Tnext()voidstart()Performs pre-processing prior to item flow throw the pipe.-
Methods inherited from class org.pipecraft.pipes.sync.inter.DelegatePipe
getOriginPipe, getProgress, peek
-
-
-
-
Constructor Detail
-
IntermediateTxtFileWriterPipe
public IntermediateTxtFileWriterPipe(Pipe<T> input, File output, Charset charset, FileWriteOptions options, FailableFunction<T,String,PipeException> stringMapper)
Constructor- Parameters:
input- The input pipeoutput- The text file to write to. If exists, the file is being overwritten.charset- the file charsetoptions- the file optionsstringMapper- in order to write the object as a string, a string mapper must be provided
-
IntermediateTxtFileWriterPipe
public IntermediateTxtFileWriterPipe(Pipe<T> input, File output, Charset charset, FileWriteOptions options)
Constructor Uses the toString as the mapper from the object to String- Parameters:
input- The input pipeoutput- The text file to write to. If exists, the file is being overwritten.charset- the file charsetoptions- the file options
-
IntermediateTxtFileWriterPipe
public IntermediateTxtFileWriterPipe(Pipe<T> input, File output, Charset charset, FailableFunction<T,String,PipeException> stringMapper)
Constructor Uses default file write options.- Parameters:
input- The input pipeoutput- The text file to write to. If exists, the file is being overwritten.charset- the file charsetstringMapper- in order to write the object as a string, a string mapper must be provided. It should never return null values
-
IntermediateTxtFileWriterPipe
public IntermediateTxtFileWriterPipe(Pipe<T> input, File output, FailableFunction<T,String,PipeException> stringMapper)
Constructor Uses default file write options and UTF8.- Parameters:
input- The input pipeoutput- The text file to write to. If exists, the file is being overwritten.stringMapper- in order to write the object as a string, a string mapper must be provided. It should never return null values
-
IntermediateTxtFileWriterPipe
public IntermediateTxtFileWriterPipe(Pipe<T> input, File output, FileWriteOptions options)
Constructor Uses default toString() as the string mapper, and UTF8- Parameters:
input- The input pipeoutput- The text file to write to. If exists, the file is being overwritten.options- the file options
-
IntermediateTxtFileWriterPipe
public IntermediateTxtFileWriterPipe(Pipe<T> input, File output, FileWriteOptions options, FailableFunction<T,String,PipeException> stringMapper)
Constructor Uses UTF8- Parameters:
input- The input pipeoutput- The text file to write to. If exists, the file is being overwritten.options- The file writing optionsstringMapper- in order to write the object as a string, a string mapper must be provided. It should never return null values
-
-
Method Detail
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classDelegatePipe<T>- Throws:
IOException
-
next
public T next() throws PipeException, InterruptedException
- Specified by:
nextin interfacePipe<T>- Overrides:
nextin classDelegatePipe<T>- Returns:
- The next item in this pipe output, or null if the output end has been reached. May be a blocking operation.
- Throws:
PipeException- In case of pipe errors in this pipe or somewhere up-stream while trying to prepare next item to return.InterruptedException- In case that the operation has been interrupted by another thread.
-
start
public void start() throws PipeException, InterruptedExceptionDescription copied from interface:BasePipePerforms pre-processing prior to item flow throw the pipe. Implementations must call the same method for all their input pipes before accessing their items. This is typically done here.- Specified by:
startin interfaceBasePipe- Overrides:
startin classDelegatePipe<T>- Throws:
PipeException- In case of pipe errors in this pipe or somewhere up-stream.InterruptedException- In case that the operation has been interrupted by another thread.
-
-