Package com.sshtools.client.tasks
Class CommandTask.CommandTaskBuilder
java.lang.Object
com.sshtools.client.tasks.AbstractConnectionTask.AbstractConnectionTaskBuilder<B,TT>
com.sshtools.client.tasks.AbstractSessionTask.AbstractSessionTaskBuilder<CommandTask.CommandTaskBuilder,SessionChannelNG,CommandTask>
com.sshtools.client.tasks.CommandTask.CommandTaskBuilder
- Enclosing class:
- CommandTask
public static final class CommandTask.CommandTaskBuilder
extends AbstractSessionTask.AbstractSessionTaskBuilder<CommandTask.CommandTaskBuilder,SessionChannelNG,CommandTask>
Builder for
CommandTask
.-
Field Summary
Fields inherited from class com.sshtools.client.tasks.AbstractConnectionTask.AbstractConnectionTaskBuilder
clientSupplier, connection
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
create()
Create a newCommandTask.CommandTaskBuilder
.onBeforeExecute
(CommandTask.CommandTaskEvent onBeforeExecute) Set a callback to run before the command is executed.Set a callback to run when the command has been executed.onClose
(CommandTask.CommandTaskEvent onClose) Set a callback to run when the command is closed.onTask
(CommandTask.CommandTaskEvent onExecute) Set a callback to run when the command has been executed.Set to auto-consume input.withAutoConsume
(boolean autoConsume) Set the whether to auto-consume input.withCommand
(String command) Set the command to run.withEncoding
(String encoding) Set the character encoding to use for transferring string content.withEncoding
(Charset encoding) Set the character encoding to use for transferring string content.Methods inherited from class com.sshtools.client.tasks.AbstractSessionTask.AbstractSessionTaskBuilder
withFuture, withSession
Methods inherited from class com.sshtools.client.tasks.AbstractConnectionTask.AbstractConnectionTaskBuilder
withClient, withClients, withConnection
-
Method Details
-
withAutoConsume
Set to auto-consume input. Will be ignored ifAbstractSessionTask.AbstractSessionTaskBuilder.withSession(java.util.function.Function)
has been used.- Returns:
- this for chaining
-
withAutoConsume
Set the whether to auto-consume input. Will be ignored ifAbstractSessionTask.AbstractSessionTaskBuilder.withSession(java.util.function.Function)
has been used.- Parameters:
autoConsume
- auto consume- Returns:
- this for chaining
-
withCommand
Set the command to run. This is mandatory.- Parameters:
command
- command- Returns:
- this for chaining
-
withEncoding
Set the character encoding to use for transferring string content.- Parameters:
encoding
- encoding- Returns:
- builder for chaining
-
withEncoding
Set the character encoding to use for transferring string content.- Parameters:
encoding
- encoding- Returns:
- builder for chaining
-
create
Create a newCommandTask.CommandTaskBuilder
.- Returns:
- builder
-
onBeforeExecute
public final CommandTask.CommandTaskBuilder onBeforeExecute(CommandTask.CommandTaskEvent onBeforeExecute) Set a callback to run before the command is executed.- Parameters:
onBeforeExecute
- on before execute callback- Returns:
- builder for chaining
-
onClose
Set a callback to run when the command is closed.- Parameters:
onClose
- on close callback- Returns:
- builder for chaining
-
onBeforeTask
Set a callback to run when the command has been executed. This should NOT block until the task is done.- Parameters:
onOpen
- on session channel open- Returns:
- builder for chaining
-
onTask
Set a callback to run when the command has been executed. Here you can obtain I/O streams if required, and then block until the task is done. The channel backing this task will be closed when the callback exits. If you do not set this,AbstractSessionTask.close()
should be called when the task is finished with.- Parameters:
onExecute
- execute task- Returns:
- builder for chaining
-
build
- Specified by:
build
in classAbstractConnectionTask.AbstractConnectionTaskBuilder<CommandTask.CommandTaskBuilder,
CommandTask>
-