public interface CommandBuilder extends To
toXXX(..)
methods inherited from the
pseudo To
command.Modifier and Type | Method and Description |
---|---|
CommandBuilder |
apply(LineOperation operation)
Adds a new command based on the specified operation and adds it to the
chain of commands held by this builder.
|
Command<?> |
build()
Builds the composite command and returns it.
|
CommandBuilder |
join(Command<?> command)
Adds the specified command to the chain of commands held by this builder.
|
CommandBuilder |
reset()
Resets this command builder to its initial state.
|
String |
toString()
Returns a string representation of the composite command that would be
returned by
build() . |
toDevNull, toExitValue, toFile, toFile, toLineList, toLineStream, toOutput, toOutputStream, toStdOut, toStringList, toStringResult, toStringStream, toWriter
CommandBuilder join(Command<?> command)
grep(..)
methods to join a grep
command.
If this is the fist joined command, the builder builds this
command and returns or executes it if build()
or
toXXX(..)
is called, respectively. If the command argument joins
already existing commands, the last command in the chain redirects its
output to the standard input of the specified command.
command
- the command to join the last previously joined commandNullPointerException
- if the command argument is nullCommandBuilder apply(LineOperation operation)
If this is the fist joined command, the builder builds the command
created from the operation and returns or executes it if build()
or toXXX(..)
is called, respectively. If the command argument joins
already existing commands, the last command in the chain redirects its
output to the standard input of the specified command.
operation
- the operation on which the added command is basedNullPointerException
- if the operation argument is nullCommandBuilder reset()
NoOp
command. New commands can be joined
subsequently to create a new command chain.Command<?> build()
This method is rarely used by application code. Usually one of the toXXX(..) methods is invoked to execute the command and return the output directly. To get a string representation of the built command, the command's toString() method can be used.
String toString()
build()
. A composite command string looks for
instance like this:
"echo -messages [Hello WORLD] | grep -matchString world -ignoreCase"
Use To.toStringResult()
instead to execute the command and return
the output as a string.
Copyright © 2024. All rights reserved.