public final class CutArguments extends Object implements Arguments<CutArguments>
cut
command.Constructor and Description |
---|
CutArguments()
Constructor to use if no options are specified.
|
CutArguments(CutOptions options)
Constructor with option set containing the selected command options.
|
CutArguments(String... args)
Constructor string arguments encoding options and arguments, possibly
also containing variable expressions.
|
Modifier and Type | Method and Description |
---|---|
String[] |
getArgs()
Returns the
<args> operand value: String arguments defining the options and operands for the command. |
String |
getDelimiter()
Returns the
<delimiter> operand value (variables are NOT resolved): use as the output delimiter the default is to use the input delimiter |
String |
getDelimiter(ExecutionContext context)
Returns the
<delimiter> (variables are resolved): use as the output delimiter the default is to use the input delimiter |
CutArguments |
getForContext(ExecutionContext context)
Returns an arguments object for the given execution context with resolved
variables if necessary and possible.
|
int[] |
getIndexes()
Returns the
<indexes> operand value: select these chars/field based on the given indexes. |
CutOptions |
getOptions()
Returns the options set containing the selected command options.
|
char |
getOutputDelimiter()
Returns the
<outputDelimiter> operand value: use as the output delimiter the default is to use the input delimiter |
Range |
getRange()
Returns the
<range> operand value: select only these fields |
boolean |
isArgsSet()
Returns true if the
<args> operand has been set. |
boolean |
isChars()
Returns true if the
-- chars option
is set. |
boolean |
isDelimiterSet()
Returns true if the
<delimiter> operand has been set. |
boolean |
isFields()
Returns true if the
-- fields option
is set. |
boolean |
isIndexesSet()
Returns true if the
<indexes> operand has been set. |
boolean |
isOutputDelimiterSet()
Returns true if the
<outputDelimiter> operand has been set. |
boolean |
isRangeSet()
Returns true if the
<range> operand has been set. |
void |
setDelimiter(String delimiter)
Sets
<delimiter> : use as the output delimiter the default is to use the input delimiter |
void |
setIndexes(int... indexes)
Sets
<indexes> : select these chars/field based on the given indexes. |
void |
setOutputDelimiter(char outputDelimiter)
Sets
<outputDelimiter> : use as the output delimiter the default is to use the input delimiter |
void |
setRange(Range range)
Sets
<range> : select only these fields |
String |
toString()
Returns a string representation of the command arguments and options.
|
public CutArguments()
public CutArguments(CutOptions options)
options
- the selected optionsNullPointerException
- if the argument is nullpublic CutArguments(String... args)
args
- string arguments for the commandNullPointerException
- if args is nullpublic CutOptions getOptions()
public CutArguments 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<CutArguments>
context
- the execution context providing access to variables and
converterspublic String getDelimiter()
<delimiter>
operand value (variables are NOT resolved): use as the output delimiter the default is to use the input delimiter<delimiter>
operand value (variables are not resolved)IllegalStateException
- if this operand has never been setgetDelimiter(ExecutionContext)
public String getDelimiter(ExecutionContext context)
<delimiter>
(variables are resolved): use as the output delimiter the default is to use the input delimitercontext
- the execution context used to resolve variables<delimiter>
operand value after resolving variablesIllegalStateException
- if this operand has never been setgetDelimiter()
public boolean isDelimiterSet()
<delimiter>
operand has been set.
Note that this method returns true even if null
was passed to the
setDelimiter(String)
method.
<delimiter>
operand has
been called at least oncepublic void setDelimiter(String delimiter)
<delimiter>
: use as the output delimiter the default is to use the input delimiterdelimiter
- the value for the <delimiter>
operandpublic char getOutputDelimiter()
<outputDelimiter>
operand value: use as the output delimiter the default is to use the input delimiter<outputDelimiter>
operand value (variables are not resolved)IllegalStateException
- if this operand has never been setpublic boolean isOutputDelimiterSet()
<outputDelimiter>
operand has been set.
Note that this method returns true even if null
was passed to the
setOutputDelimiter(char)
method.
<outputDelimiter>
operand has
been called at least oncepublic void setOutputDelimiter(char outputDelimiter)
<outputDelimiter>
: use as the output delimiter the default is to use the input delimiteroutputDelimiter
- the value for the <outputDelimiter>
operandpublic int[] getIndexes()
<indexes>
operand value: select these chars/field based on the given indexes. Indexes are 1 based. i.e. the first character/field on a line has an index of 1.<indexes>
operand value (variables are not resolved)IllegalStateException
- if this operand has never been setpublic boolean isIndexesSet()
<indexes>
operand has been set.
Note that this method returns true even if null
was passed to the
setIndexes(int[])
method.
<indexes>
operand has
been called at least oncepublic void setIndexes(int... indexes)
<indexes>
: select these chars/field based on the given indexes. Indexes are 1 based. i.e. the first character/field on a line has an index of 1.indexes
- the value for the <indexes>
operandpublic Range getRange()
<range>
operand value: select only these fields<range>
operand value (variables are not resolved)IllegalStateException
- if this operand has never been setpublic boolean isRangeSet()
<range>
operand has been set.
Note that this method returns true even if null
was passed to the
setRange(org.unix4j.util.Range)
method.
<range>
operand has
been called at least oncepublic void setRange(Range range)
<range>
: select only these fieldsrange
- the value for the <range>
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 "--range" operand have to be prefixed with the operand name
(e.g. "--indexes" for subsequent index operand values).<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 isChars()
--
chars
option
is set. The option is also known as -
c option.
Description: The list specifies character positions.
--chars
or -c
option is setpublic boolean isFields()
--
fields
option
is set. The option is also known as -
f option.
Description: The list specifies fields, separated in the input by the field delimiter character (see the -d option.) Output fields are separated by a single occurrence of the field delimiter character.
--fields
or -f
option is setpublic String toString()
Arguments
toString
in interface Arguments<CutArguments>
toString
in class Object
Copyright © 2024. All rights reserved.