public final class HeadArguments extends Object implements Arguments<HeadArguments>
head
command.Constructor and Description |
---|
HeadArguments()
Constructor to use if no options are specified.
|
HeadArguments(HeadOptions options)
Constructor with option set containing the selected command options.
|
HeadArguments(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. |
long |
getCount()
Returns the
<count> operand value: The first count lines of each input file are
copied to standard output, starting from 1 (characters instead of
lines if the -c option is specified). |
File[] |
getFiles()
Returns the
<files> operand value: The input files to be filtered; relative paths are not resolved (use
the string paths argument to enable relative path resolving based on
the current working directory). |
HeadArguments |
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 to be filtered. |
HeadOptions |
getOptions()
Returns the options set containing the selected command options.
|
String[] |
getPaths()
Returns the
<paths> operand value: Path names of the input files to be filtered; 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 |
isCountSet()
Returns true if the
<count> operand has been set. |
boolean |
isFilesSet()
Returns true if the
<files> operand has been set. |
boolean |
isInputsSet()
Returns true if the
<inputs> operand has been set. |
boolean |
isPathsSet()
Returns true if the
<paths> operand has been set. |
boolean |
isSuppressHeaders()
Returns true if the
-- suppressHeaders option
is set. |
void |
setCount(long count)
Sets
<count> : The first count lines of each input file are
copied to standard output, starting from 1 (characters instead of
lines if the -c option is specified). |
void |
setFiles(File... files)
Sets
<files> : The input files to be filtered; 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 to be filtered. |
void |
setPaths(String... paths)
Sets
<paths> : Path names of the input files to be filtered; 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 HeadArguments()
public HeadArguments(HeadOptions options)
options
- the selected optionsNullPointerException
- if the argument is nullpublic HeadArguments(String... args)
args
- string arguments for the commandNullPointerException
- if args is nullpublic HeadOptions getOptions()
public HeadArguments 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<HeadArguments>
context
- the execution context providing access to variables and
converterspublic long getCount()
<count>
operand value: The first count
lines of each input file are
copied to standard output, starting from 1 (characters instead of
lines if the -c
option is specified). Must be a non-negative
integer or an exception is thrown. If count
is greater than
the number number of lines (characters) in the input, the
application will not error and send the whole file to the output.<count>
operand value (variables are not resolved)IllegalStateException
- if this operand has never been setpublic boolean isCountSet()
<count>
operand has been set.
Note that this method returns true even if null
was passed to the
setCount(long)
method.
<count>
operand has
been called at least oncepublic void setCount(long count)
<count>
: The first count
lines of each input file are
copied to standard output, starting from 1 (characters instead of
lines if the -c
option is specified). Must be a non-negative
integer or an exception is thrown. If count
is greater than
the number number of lines (characters) in the input, the
application will not error and send the whole file to the output.count
- the value for the <count>
operandpublic String[] getPaths()
<paths>
operand value: Path names of the input files to be filtered; 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 to be filtered; 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 to be filtered; 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 to be filtered; 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 to be filtered.<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 to be filtered.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 (e.g. "--count" for a subsequent count operand value).<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 count
argument is in units of characters instead of
lines. Starts from 1 and includes line ending characters.
--chars
or -c
option is setpublic boolean isSuppressHeaders()
--
suppressHeaders
option
is set. The option is also known as -
q option.
Description: Suppresses printing of headers when multiple files are being examined.
--suppressHeaders
or -q
option is setpublic String toString()
Arguments
toString
in interface Arguments<HeadArguments>
toString
in class Object
Copyright © 2024. All rights reserved.