public final class FromArguments extends Object implements Arguments<FromArguments>
from
command.Constructor and Description |
---|
FromArguments()
Constructor to use if no options are specified.
|
Modifier and Type | Method and Description |
---|---|
Class<?> |
getBase()
Returns the
<base> operand value: base class for subsequent resource operand if relative paths are used. |
FromArguments |
getForContext(ExecutionContext context)
Returns an arguments object for the given execution context with resolved
variables if necessary and possible.
|
Input |
getInput()
Returns the
<input> operand value: the input object to read from |
String |
getPath()
Returns the
<path> operand value (variables are NOT resolved): the file to use as input; wildcards * and ? are supported; relative
paths are resolved on the basis of the current working directory. |
String |
getPath(ExecutionContext context)
Returns the
<path> (variables are resolved): the file to use as input; wildcards * and ? are supported; relative
paths are resolved on the basis of the current working directory. |
String |
getResource()
Returns the
<resource> operand value (variables are NOT resolved): a path to the file to redirect to the next command. |
String |
getResource(ExecutionContext context)
Returns the
<resource> (variables are resolved): a path to the file to redirect to the next command. |
boolean |
isBaseSet()
Returns true if the
<base> operand has been set. |
boolean |
isInputSet()
Returns true if the
<input> operand has been set. |
boolean |
isPathSet()
Returns true if the
<path> operand has been set. |
boolean |
isResourceSet()
Returns true if the
<resource> operand has been set. |
void |
setBase(Class<?> base)
Sets
<base> : base class for subsequent resource operand if relative paths are used. |
void |
setInput(Input input)
Sets
<input> : the input object to read from |
void |
setPath(String path)
Sets
<path> : the file to use as input; wildcards * and ? are supported; relative
paths are resolved on the basis of the current working directory. |
void |
setResource(String resource)
Sets
<resource> : a path to the file to redirect to the next command. |
String |
toString()
Returns a string representation of the command arguments and options.
|
public FromArguments()
public FromArguments getForContext(ExecutionContext context)
Arguments
this
arguments instance is simply returned.
If variables are present, they are resolved if such a variable is defined
in the VariableContext
returned by
context.
getVariableContext()
.
Values are converted if necessary with the ValueConverter
s
returned by
context.
getValueConverterFor(Class)
.
getForContext
in interface Arguments<FromArguments>
context
- the execution context providing access to variables and
converterspublic String getPath()
<path>
operand value (variables are NOT resolved): the file to use as input; wildcards * and ? are supported; relative
paths are resolved on the basis of the current working directory.<path>
operand value (variables are not resolved)IllegalStateException
- if this operand has never been setgetPath(ExecutionContext)
public String getPath(ExecutionContext context)
<path>
(variables are resolved): the file to use as input; wildcards * and ? are supported; relative
paths are resolved on the basis of the current working directory.context
- the execution context used to resolve variables<path>
operand value after resolving variablesIllegalStateException
- if this operand has never been setgetPath()
public boolean isPathSet()
<path>
operand has been set.
Note that this method returns true even if null
was passed to the
setPath(String)
method.
<path>
operand has
been called at least oncepublic void setPath(String path)
<path>
: the file to use as input; wildcards * and ? are supported; relative
paths are resolved on the basis of the current working directory.path
- the value for the <path>
operandpublic Class<?> getBase()
<base>
operand value: base class for subsequent resource
operand if relative paths are used.<base>
operand value (variables are not resolved)IllegalStateException
- if this operand has never been setpublic boolean isBaseSet()
<base>
operand has been set.
Note that this method returns true even if null
was passed to the
setBase(Class)
method.
<base>
operand has
been called at least oncepublic void setBase(Class<?> base)
<base>
: base class for subsequent resource
operand if relative paths are used.base
- the value for the <base>
operandpublic String getResource()
<resource>
operand value (variables are NOT resolved): a path to the file to redirect to the next command. The resource needs
to be on the classpath. If the file is in the root directory, the
filename should be prefixed with a forward slash. e.g.:
"/test-file.txt"
.
If the file is in a package, then the package should be specified
prefixed with a forward slash, and with each dot "." replaced with a
forward slash. e.g.:
"/org/company/mypackage/test-file.txt"
.
A base
class operand can be provided for relative paths; see
Class.getResourceAsStream(String)
for details about
resource loading.
<resource>
operand value (variables are not resolved)IllegalStateException
- if this operand has never been setgetResource(ExecutionContext)
public String getResource(ExecutionContext context)
<resource>
(variables are resolved): a path to the file to redirect to the next command. The resource needs
to be on the classpath. If the file is in the root directory, the
filename should be prefixed with a forward slash. e.g.:
"/test-file.txt"
.
If the file is in a package, then the package should be specified
prefixed with a forward slash, and with each dot "." replaced with a
forward slash. e.g.:
"/org/company/mypackage/test-file.txt"
.
A base
class operand can be provided for relative paths; see
Class.getResourceAsStream(String)
for details about
resource loading.
context
- the execution context used to resolve variables<resource>
operand value after resolving variablesIllegalStateException
- if this operand has never been setgetResource()
public boolean isResourceSet()
<resource>
operand has been set.
Note that this method returns true even if null
was passed to the
setResource(String)
method.
<resource>
operand has
been called at least oncepublic void setResource(String resource)
<resource>
: a path to the file to redirect to the next command. The resource needs
to be on the classpath. If the file is in the root directory, the
filename should be prefixed with a forward slash. e.g.:
"/test-file.txt"
.
If the file is in a package, then the package should be specified
prefixed with a forward slash, and with each dot "." replaced with a
forward slash. e.g.:
"/org/company/mypackage/test-file.txt"
.
A base
class operand can be provided for relative paths; see
Class.getResourceAsStream(String)
for details about
resource loading.
resource
- the value for the <resource>
operandpublic Input getInput()
<input>
operand value: the input object to read from<input>
operand value (variables are not resolved)IllegalStateException
- if this operand has never been setpublic boolean isInputSet()
<input>
operand has been set.
Note that this method returns true even if null
was passed to the
setInput(org.unix4j.io.Input)
method.
<input>
operand has
been called at least oncepublic void setInput(Input input)
<input>
: the input object to read frominput
- the value for the <input>
operandpublic String toString()
Arguments
toString
in interface Arguments<FromArguments>
toString
in class Object
Copyright © 2024. All rights reserved.