public class JoinedCommand<A extends Arguments<A>> extends Object implements Command<A>
Constructor and Description |
---|
JoinedCommand(Command<A> first,
Command<?> second)
Constructor with first and second command in the join.
|
Modifier and Type | Method and Description |
---|---|
LineProcessor |
execute(ExecutionContext context,
LineProcessor output)
Executes this joined command redirecting the output of the first command
such that it becomes the input of the second command.
|
A |
getArguments(ExecutionContext context)
Returns the implementation specific command arguments and options for the
given execution context.
|
Command<A> |
getFirst()
Returns the first command of this joined command
|
String |
getName()
Returns the joined command names, a string like "echo | grep"
|
Command<?> |
getSecond()
Returns the second command of this joined command
|
Command<?> |
join(Command<?> next)
Returns a new command representing the combination of
this
command with next . |
static <A extends Arguments<A>> |
join(Command<A> first,
Command<?> second) |
String |
toString()
Returns the string representation of this joined command, consisting of
first and second command including arguments and options.
|
public JoinedCommand(Command<A> first, Command<?> second)
first
- the first command in the join, whose output is joined to the
input of the second commandsecond
- the second command in the join, whose input is joined from the
output of the first commandNullPointerException
- if any of the command arguments is nullpublic static <A extends Arguments<A>> JoinedCommand<A> join(Command<A> first, Command<?> second)
public Command<A> getFirst()
public Command<?> getSecond()
public A getArguments(ExecutionContext context)
Command
VariableContext
returned by the given context
object. No variables are resolved if context
is null.getArguments
in interface Command<A extends Arguments<A>>
context
- the execution context with access to variables and value
converters, or null if no variables should be resolvedArguments.getForContext(ExecutionContext)
public Command<?> join(Command<?> next)
Command
this
command with next
. The returned command executes this
command first and usually joins the output to the next
command's
input.
Note that some commands may use a slightly different interpretation of
"joining a command". The xargs
command for instance uses its
joined command as target command; the values collected by xargs
on its input stream are passed to the target command as arguments instead
of as input.
public LineProcessor execute(ExecutionContext context, LineProcessor output)
The specified output
object is passed to the second command's
execute(..)
method. The LineProcessor
returned by the
second command is passed to the execute(..)
method of the first
command, with the effect that the first command provides its output to
the second command as input.
execute
in interface Command<A extends Arguments<A>>
context
- context object providing access to the current directory,
environment variables and other information useful for the
commands during their executionoutput
- the output for the second commandCopyright © 2024. All rights reserved.