public final class UniqArguments extends Object implements Arguments<UniqArguments>
uniq
command.Constructor and Description |
---|
UniqArguments()
Constructor to use if no options are specified.
|
UniqArguments(String... args)
Constructor string arguments encoding options and arguments, possibly
also containing variable expressions.
|
UniqArguments(UniqOptions 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 |
getFile()
Returns the
<file> operand value: The files or directories used as starting point for the listing;
relative paths are not resolved (use the string path argument to
enable relative path resolving based on the current working
directory). |
UniqArguments |
getForContext(ExecutionContext context)
Returns an arguments object for the given execution context with resolved
variables if necessary and possible.
|
UniqOptions |
getOptions()
Returns the options set containing the selected command options.
|
String |
getPath()
Returns the
<path> operand value (variables are NOT resolved): The files or directories used as starting point for the listing;
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 files or directories used as starting point for the listing;
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 |
isCount()
Returns true if the
-- count option
is set. |
boolean |
isDuplicatedOnly()
Returns true if the
-- duplicatedOnly option
is set. |
boolean |
isFileSet()
Returns true if the
<file> operand has been set. |
boolean |
isGlobal()
Returns true if the
-- global option
is set. |
boolean |
isPathSet()
Returns true if the
<path> operand has been set. |
boolean |
isUniqueOnly()
Returns true if the
-- uniqueOnly option
is set. |
void |
setFile(File file)
Sets
<file> : The files or directories used as starting point for the listing;
relative paths are not resolved (use the string path argument to
enable relative path resolving based on the current working
directory). |
void |
setPath(String path)
Sets
<path> : The files or directories used as starting point for the listing;
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 UniqArguments()
public UniqArguments(UniqOptions options)
options
- the selected optionsNullPointerException
- if the argument is nullpublic UniqArguments(String... args)
args
- string arguments for the commandNullPointerException
- if args is nullpublic UniqOptions getOptions()
public UniqArguments 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<UniqArguments>
context
- the execution context providing access to variables and
converterspublic File getFile()
<file>
operand value: The files or directories used as starting point for the listing;
relative paths are not resolved (use the string path argument to
enable relative path resolving based on the current working
directory).<file>
operand value (variables are not resolved)IllegalStateException
- if this operand has never been setpublic boolean isFileSet()
<file>
operand has been set.
Note that this method returns true even if null
was passed to the
setFile(java.io.File)
method.
<file>
operand has
been called at least oncepublic void setFile(File file)
<file>
: The files or directories used as starting point for the listing;
relative paths are not resolved (use the string path argument to
enable relative path resolving based on the current working
directory).file
- the value for the <file>
operandpublic String getPath()
<path>
operand value (variables are NOT resolved): The files or directories used as starting point for the listing;
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 files or directories used as starting point for the listing;
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 files or directories used as starting point for the listing;
wildcards * and ? are supported; relative paths are resolved on the
basis of the current working directory.path
- the value for the <path>
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 "--path" 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 isCount()
--
count
option
is set. The option is also known as -
c option.
Description: Precedes each output line with a count of the number of times the line occurred in the input.
--count
or -c
option is setpublic boolean isDuplicatedOnly()
--
duplicatedOnly
option
is set. The option is also known as -
d option.
Description: Suppresses the writing of lines that are not repeated in the input.
--duplicatedOnly
or -d
option is setpublic boolean isUniqueOnly()
--
uniqueOnly
option
is set. The option is also known as -
u option.
Description: Suppresses the writing of lines that are repeated in the input.
--uniqueOnly
or -u
option is setpublic boolean isGlobal()
--
global
option
is set. The option is also known as -
g option.
Description: Suppresses repeated lines globally, that is, if lines are non-adjacent. This option guarantees unique output lines even if the input lines are not sorted.
--global
or -g
option is setpublic String toString()
Arguments
toString
in interface Arguments<UniqArguments>
toString
in class Object
Copyright © 2024. All rights reserved.