/** * Creates an input stream of text as UTF-8 bytes. * @param text The text which will be treated as UTF-8 bytes * @return The new input */ static public StreamableInput input(String text) { return input(text, StandardCharsets.UTF_8); }
/** * Creates an input stream of text as UTF-8 bytes. * @param text The text which will be treated as UTF-8 bytes * @return The new input */ static public StreamableInput input(String text) { return input(text, StandardCharsets.UTF_8); }
static public StreamableInput input(InputStream stream) { return input(stream, null); }
static public StreamableInput input(InputStream stream) { return input(stream, null); }
static public StreamableInput input(File file) { Objects.requireNonNull(file, "file cannot be null"); return input(file.toPath()); }
static public StreamableInput input(File file) { Objects.requireNonNull(file, "file cannot be null"); return input(file.toPath()); }
default public T pipeInput(String text) { return pipeInput(Streamables.input(text)); }
default public T pipeInput(String text) { return pipeInput(Streamables.input(text)); }
default public T pipeInput(String text, Charset charset) { return pipeInput(Streamables.input(text, charset)); }
default public T pipeInput(InputStream stream) { return pipeInput(Streamables.input(stream)); }
default public T pipeInput(Path path) { return pipeInput(Streamables.input(path)); }
default public T pipeInput(InputStream stream) { return pipeInput(Streamables.input(stream)); }
default public T pipeInput(Path path) { return pipeInput(Streamables.input(path)); }
default public T pipeInput(File file) { return pipeInput(Streamables.input(file)); }
default public T pipeInput(File file) { return pipeInput(Streamables.input(file)); }
public SshSftpPut source(Path sourceFile) { return source(Streamables.input(sourceFile)); }
public SshSftpPut source(File sourceFile) { return source(Streamables.input(sourceFile)); }
public SshSftpPut source(InputStream source) { return source(Streamables.input(source)); }
default public T pipeInput(String text, Charset charset) { return pipeInput(Streamables.input(text, charset)); }
public Pipeline add(PipeMixin pipable) { if (!(pipable instanceof Action)) { throw new IllegalArgumentException("pipable must be an instance of " + Action.class.getCanonicalName()); } if (this.pipables.size() > 0) { PipeMixin lastPipable = this.pipables.get(this.pipables.size() - 1); // connect output to input log.debug("Connecting {} output -> {} input", lastPipable.getClass(), pipable.getClass()); BytePipe pipe = new BytePipe(); lastPipable.pipeOutput(Streamables.output(pipe.getOutputStream(), "<pipe>")); pipable.pipeInput(Streamables.input(pipe.getInputStream(), "<pipe>")); } this.pipables.add(pipable); return this; }