public final class WcArguments extends Object implements Arguments<WcArguments>
wc
command.Constructor and Description |
---|
WcArguments()
Constructor to use if no options are specified.
|
WcArguments(String... args)
Constructor string arguments encoding options and arguments, possibly
also containing variable expressions.
|
WcArguments(WcOptions options)
Constructor with option set containing the selected command options.
|
Modifier and Type | Method and Description |
---|---|
String[] |
getArgs()
Returns the
<args> operand value: String arguments defining the options and operands for the command. |
File[] |
getFiles()
Returns the
<files> operand value: The input files; relative paths are not resolved (use the string
paths argument to enable relative path resolving based on the
current working directory). |
WcArguments |
getForContext(ExecutionContext context)
Returns an arguments object for the given execution context with resolved
variables if necessary and possible.
|
Input[] |
getInputs()
Returns the
<inputs> operand value: The inputs. |
WcOptions |
getOptions()
Returns the options set containing the selected command options.
|
String[] |
getPaths()
Returns the
<paths> operand value: Path names of the input files; wildcards * and ? are supported;
relative paths are resolved on the basis of the current working
directory. |
boolean |
isArgsSet()
Returns true if the
<args> operand has been set. |
boolean |
isChars()
Returns true if the
-- chars option
is set. |
boolean |
isFilesSet()
Returns true if the
<files> operand has been set. |
boolean |
isInputsSet()
Returns true if the
<inputs> operand has been set. |
boolean |
isLines()
Returns true if the
-- lines option
is set. |
boolean |
isPathsSet()
Returns true if the
<paths> operand has been set. |
boolean |
isWords()
Returns true if the
-- words option
is set. |
void |
setFiles(File... files)
Sets
<files> : The input files; relative paths are not resolved (use the string
paths argument to enable relative path resolving based on the
current working directory). |
void |
setInputs(Input... inputs)
Sets
<inputs> : The inputs. |
void |
setPaths(String[] paths)
Sets
<paths> : Path names of the input files; wildcards * and ? are supported;
relative paths are resolved on the basis of the current working
directory. |
String |
toString()
Returns a string representation of the command arguments and options.
|
public WcArguments()
public WcArguments(WcOptions options)
options
- the selected optionsNullPointerException
- if the argument is nullpublic WcArguments(String... args)
args
- string arguments for the commandNullPointerException
- if args is nullpublic WcOptions getOptions()
public WcArguments 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<WcArguments>
context
- the execution context providing access to variables and
converterspublic String[] getPaths()
<paths>
operand value: Path names of the input files; wildcards * and ? are supported;
relative paths are resolved on the basis of the current working
directory.<paths>
operand value (variables are not resolved)IllegalStateException
- if this operand has never been setpublic boolean isPathsSet()
<paths>
operand has been set.
Note that this method returns true even if null
was passed to the
setPaths(String[])
method.
<paths>
operand has
been called at least oncepublic void setPaths(String[] paths)
<paths>
: Path names of the input files; wildcards * and ? are supported;
relative paths are resolved on the basis of the current working
directory.paths
- the value for the <paths>
operandpublic File[] getFiles()
<files>
operand value: The input files; relative paths are not resolved (use the string
paths argument to enable relative path resolving based on the
current working directory).<files>
operand value (variables are not resolved)IllegalStateException
- if this operand has never been setpublic boolean isFilesSet()
<files>
operand has been set.
Note that this method returns true even if null
was passed to the
setFiles(java.io.File[])
method.
<files>
operand has
been called at least oncepublic void setFiles(File... files)
<files>
: The input files; relative paths are not resolved (use the string
paths argument to enable relative path resolving based on the
current working directory).files
- the value for the <files>
operandpublic Input[] getInputs()
<inputs>
operand value: The inputs.<inputs>
operand value (variables are not resolved)IllegalStateException
- if this operand has never been setpublic boolean isInputsSet()
<inputs>
operand has been set.
Note that this method returns true even if null
was passed to the
setInputs(org.unix4j.io.Input[])
method.
<inputs>
operand has
been called at least oncepublic void setInputs(Input... inputs)
<inputs>
: The inputs.inputs
- the value for the <inputs>
operandpublic String[] getArgs()
<args>
operand value: String arguments defining the options and operands for the command.
Options can be specified by acronym (with a leading dash "-") or by
long name (with two leading dashes "--"). Operands other than the
default "--paths" operand have to be prefixed with the operand
name.<args>
operand value (variables are not resolved)IllegalStateException
- if this operand has never been setpublic boolean isArgsSet()
<args>
operand has been set.<args>
operand has
been called at least oncepublic boolean isLines()
--
lines
option
is set. The option is also known as -
l option.
Description: Executes a count of lines and writes this count to the output.
--lines
or -l
option is setpublic boolean isWords()
--
words
option
is set. The option is also known as -
w option.
Description: Executes a count of words and writes this count to the output. A
word is a non-zero-length string of characters delimited by white
space as defined by Character.isWhitespace(char)
.
--words
or -w
option is setpublic boolean isChars()
--
chars
option
is set. The option is also known as -
m option.
Description: Executes a count of chars and writes this count to the output.
--chars
or -m
option is setpublic String toString()
Arguments
toString
in interface Arguments<WcArguments>
toString
in class Object
Copyright © 2024. All rights reserved.