public final class SortArguments extends Object implements Arguments<SortArguments>
sort
command.Constructor and Description |
---|
SortArguments()
Constructor to use if no options are specified.
|
SortArguments(SortOptions options)
Constructor with option set containing the selected command options.
|
SortArguments(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. |
Comparator<? super Line> |
getComparator()
Returns the
<comparator> operand value: The comparator to use for the line comparisons. |
File[] |
getFiles()
Returns the
<files> operand value: The files to be sorted or merged; relative paths are not resolved
(use the string paths argument to enable relative path resolving
based on the current working directory). |
SortArguments |
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 sorted or merged. |
SortOptions |
getOptions()
Returns the options set containing the selected command options.
|
String[] |
getPaths()
Returns the
<paths> operand value: Path names of the files to be sorted, merged, or checked; 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 |
isCheck()
Returns true if the
-- check option
is set. |
boolean |
isComparatorSet()
Returns true if the
<comparator> operand has been set. |
boolean |
isDictionaryOrder()
Returns true if the
-- dictionaryOrder option
is set. |
boolean |
isFilesSet()
Returns true if the
<files> operand has been set. |
boolean |
isGeneralNumericSort()
Returns true if the
-- generalNumericSort option
is set. |
boolean |
isHumanNumericSort()
Returns true if the
-- humanNumericSort option
is set. |
boolean |
isIgnoreCase()
Returns true if the
-- ignoreCase option
is set. |
boolean |
isIgnoreLeadingBlanks()
Returns true if the
-- ignoreLeadingBlanks option
is set. |
boolean |
isInputsSet()
Returns true if the
<inputs> operand has been set. |
boolean |
isMerge()
Returns true if the
-- merge option
is set. |
boolean |
isMonthSort()
Returns true if the
-- monthSort option
is set. |
boolean |
isNumericSort()
Returns true if the
-- numericSort option
is set. |
boolean |
isPathsSet()
Returns true if the
<paths> operand has been set. |
boolean |
isReverse()
Returns true if the
-- reverse option
is set. |
boolean |
isUnique()
Returns true if the
-- unique option
is set. |
boolean |
isVersionSort()
Returns true if the
-- versionSort option
is set. |
void |
setComparator(Comparator<? super Line> comparator)
Sets
<comparator> : The comparator to use for the line comparisons. |
void |
setFiles(File... files)
Sets
<files> : The files to be sorted or merged; 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 sorted or merged. |
void |
setPaths(String... paths)
Sets
<paths> : Path names of the files to be sorted, merged, or checked; 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 SortArguments()
public SortArguments(SortOptions options)
options
- the selected optionsNullPointerException
- if the argument is nullpublic SortArguments(String... args)
args
- string arguments for the commandNullPointerException
- if args is nullpublic SortOptions getOptions()
public SortArguments 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<SortArguments>
context
- the execution context providing access to variables and
converterspublic String[] getPaths()
<paths>
operand value: Path names of the files to be sorted, merged, or checked; 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 files to be sorted, merged, or checked; 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 files to be sorted or merged; 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 files to be sorted or merged; 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 sorted or merged.<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 sorted or merged.inputs
- the value for the <inputs>
operandpublic Comparator<? super Line> getComparator()
<comparator>
operand value: The comparator to use for the line comparisons.<comparator>
operand value (variables are not resolved)IllegalStateException
- if this operand has never been setpublic boolean isComparatorSet()
<comparator>
operand has been set.
Note that this method returns true even if null
was passed to the
setComparator(java.util.Comparator)
method.
<comparator>
operand has
been called at least oncepublic void setComparator(Comparator<? super Line> comparator)
<comparator>
: The comparator to use for the line comparisons.comparator
- the value for the <comparator>
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. "--comparator" for a subsequent comparator 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 isCheck()
--
check
option
is set. The option is also known as -
c option.
Description: Checks that the single input file is ordered as specified by the arguments and the collating sequence of the current locale. No output is produced; only the exit code is affected.
--check
or -c
option is setpublic boolean isMerge()
--
merge
option
is set. The option is also known as -
m option.
Description: Merge only; the input file are assumed to be already sorted.
--merge
or -m
option is setpublic boolean isUnique()
--
unique
option
is set. The option is also known as -
u option.
Description: Unique: suppress all but one in each set of lines having equal keys.
If used with the -c
option, checks that there are no lines
with duplicate keys, in addition to checking that the input file is
sorted.
--unique
or -u
option is setpublic boolean isIgnoreLeadingBlanks()
--
ignoreLeadingBlanks
option
is set. The option is also known as -
b option.
Description: Ignore leading blanks. (This option is ignored if a comparator operand is present).
--ignoreLeadingBlanks
or -b
option is setpublic boolean isDictionaryOrder()
--
dictionaryOrder
option
is set. The option is also known as -
d option.
Description: Consider only blanks and alphanumeric characters. (This option is ignored if a comparator operand is present).
--dictionaryOrder
or -d
option is setpublic boolean isIgnoreCase()
--
ignoreCase
option
is set. The option is also known as -
f option.
Description: Consider all lowercase characters that have uppercase equivalents to be the uppercase equivalent for the purposes of comparison. (This option is ignored if a comparator operand is present).
--ignoreCase
or -f
option is setpublic boolean isNumericSort()
--
numericSort
option
is set. The option is also known as -
n option.
Description: Sort numerically; the number begins each line and consists of optional blanks, an optional minus sign, and zero or more digits possibly separated by thousands separators, optionally followed by a decimal-point character and zero or more digits. An empty number is treated as '0'. The current local specifies the decimal-point character and thousands separator.
Comparison is exact; there is no rounding error.
Neither a leading '+' nor exponential notation is recognized. To
compare such strings numerically, use the
-genericNumericSort (-g)
option.
(This option is ignored if a comparator operand is present).
--numericSort
or -n
option is setpublic boolean isGeneralNumericSort()
--
generalNumericSort
option
is set. The option is also known as -
g option.
Description: Sort numerically, using the standard Double.parseDouble(String)
function to convert a trimmed line to a double-precision floating
point number. This allows floating point numbers to be specified in
scientific notation, like 1.0e-34 and 10e100.
Uses the following collating sequence: Lines that cannot be parsed because they do not represent valid double values (in alpha-numeric order); "-Infinity"; finite numbers in ascending numeric order (with -0 < +0); "Infinity"; "NaN".
This option is usually slower than -numeric-sort (-n)
and it
can lose information when converting to floating point.
(This option is ignored if a comparator operand is present).
--generalNumericSort
or -g
option is setpublic boolean isHumanNumericSort()
--
humanNumericSort
option
is set. The option is also known as -
h option.
Description: Sort numerically, first by numeric sign (negative, zero, or positive); then by SI suffix (either empty, or 'k' or 'K', or one of 'MGTPEZY', in that order); and finally by numeric value. For example, '1023M' sorts before '1G' because 'M' (mega) precedes 'G' (giga) as an SI suffix.
This option sorts values that are consistently scaled to the nearest
suffix, regardless of whether suffixes denote powers of 1000 or
1024, and it therefore sorts the output of any single invocation of
the ls
command that are invoked with the --human-readable
option.
The syntax for numbers is the same as for the
--numericSort (-n)
option; the SI suffix must immediately
follow the number.
(This option is ignored if a comparator operand is present).
--humanNumericSort
or -h
option is setpublic boolean isMonthSort()
--
monthSort
option
is set. The option is also known as -
M option.
Description: An initial string, consisting of any amount of blanks, followed by a month name abbreviation, is folded to UPPER case and compared in the order: (unknown) < 'JAN' < ... < 'DEC'. The current locale determines the month spellings.
--monthSort
or -M
option is setpublic boolean isVersionSort()
--
versionSort
option
is set. The option is also known as -
V option.
Description: Sort by version name and number. It behaves like a standard sort, except that each sequence of decimal digits is treated numerically as an index/version number.
(This option is ignored if a comparator operand is present).
--versionSort
or -V
option is setpublic boolean isReverse()
--
reverse
option
is set. The option is also known as -
r option.
Description: Reverse the sense of comparisons.
--reverse
or -r
option is setpublic String toString()
Arguments
toString
in interface Arguments<SortArguments>
toString
in class Object
Copyright © 2024. All rights reserved.