public enum GrepOption extends Enum<GrepOption> implements Option, GrepOptions
grep
command.
For most applications, it may be more convenient to use Grep.Options
instead of the option constants defined here.
-i | --ignoreCase | Match lines ignoring the case when comparing the strings, also known from Unix with its acronym 'i'. | |||
-v | --invertMatch | Invert the match result, that is, a non-matching line is written to the output and a matching line is not. This option is also known from Unix with its acronym 'v'. | |||
-F | --fixedStrings | Use fixed-strings matching instead of regular expressions. This is
usually faster than the standard regexp version.
(This option is ignored if a | |||
-n | --lineNumber | Prefix each line of output with the line number within its input file. | |||
-c | --count | Suppress normal output; instead print a count of matching lines for
each input file. With the -v , --invertMatch option,
count non-matching lines. | |||
-l | --matchingFiles | Suppress normal output; instead print the name of each input file from which output would normally have been printed. The scanning will stop on the first match. | |||
-x | --wholeLine | Select only those matches that exactly match the whole line
excluding the terminating line ending.
(This option is ignored if a |
GrepOptions.Default
Enum Constant and Description |
---|
count
Option
--count , -c :
Suppress normal output; instead print a count of matching lines for
each input file. |
fixedStrings
Option
--fixedStrings , -F :
Use fixed-strings matching instead of regular expressions. |
ignoreCase
Option
--ignoreCase , -i :
Match lines ignoring the case when comparing the strings, also known
from Unix with its acronym 'i'. |
invertMatch
Option
--invertMatch , -v :
Invert the match result, that is, a non-matching line is written to
the output and a matching line is not. |
lineNumber
Option
--lineNumber , -n :
Prefix each line of output with the line number within its input
file. |
matchingFiles
Option
--matchingFiles , -l :
Suppress normal output; instead print the name of each input file
from which output would normally have been printed. |
wholeLine
Option
--wholeLine , -x :
Select only those matches that exactly match the whole line
excluding the terminating line ending. |
CONVERTER, EMPTY
Modifier and Type | Method and Description |
---|---|
char |
acronym()
Returns a one letter acronym for this option.
|
EnumSet<GrepOption> |
asSet()
Returns a new set with
this active option. |
static GrepOption |
findByAcronym(char acronym)
Returns the option with the given
acronym , or null if no
such option is found. |
boolean |
isSet(GrepOption option)
Returns true if the specified
option is set and false otherwise |
Iterator<GrepOption> |
iterator()
Returns an immutable iterator returning o single element:
this
option. |
Class<GrepOption> |
optionType()
Returns the option type class, usually an enum.
|
int |
size()
Returns 1 as this is a set with a single element:
this option |
boolean |
useAcronymFor(GrepOption option)
Returns true if the
acronym should be used for
the specified option in string representations. |
static GrepOption |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static GrepOption[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
forEach, spliterator
public static final GrepOption ignoreCase
--ignoreCase
, -i
:
Match lines ignoring the case when comparing the strings, also known
from Unix with its acronym 'i'.public static final GrepOption invertMatch
--invertMatch
, -v
:
Invert the match result, that is, a non-matching line is written to
the output and a matching line is not. This option is also known
from Unix with its acronym 'v'.public static final GrepOption fixedStrings
--fixedStrings
, -F
:
Use fixed-strings matching instead of regular expressions. This is
usually faster than the standard regexp version.
(This option is ignored if a pattern
operand is specified
instead of the regexp
string).
public static final GrepOption lineNumber
--lineNumber
, -n
:
Prefix each line of output with the line number within its input
file.public static final GrepOption count
--count
, -c
:
Suppress normal output; instead print a count of matching lines for
each input file. With the -v
, --invertMatch
option,
count non-matching lines.public static final GrepOption matchingFiles
--matchingFiles
, -l
:
Suppress normal output; instead print the name of each input file
from which output would normally have been printed. The scanning
will stop on the first match.public static final GrepOption wholeLine
--wholeLine
, -x
:
Select only those matches that exactly match the whole line
excluding the terminating line ending.
(This option is ignored if a pattern
operand is specified
instead of the regexp
string).
public static GrepOption[] values()
for (GrepOption c : GrepOption.values()) System.out.println(c);
public static GrepOption valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic Class<GrepOption> optionType()
OptionSet
optionType
in interface OptionSet<GrepOption>
public static GrepOption findByAcronym(char acronym)
acronym
, or null
if no
such option is found.acronym
- the option acronym
acronym
or null
if it
is not foundpublic char acronym()
Option
public boolean isSet(GrepOption option)
OptionSet
option
is set and false otherwiseisSet
in interface OptionSet<GrepOption>
option
- the option to testoption
is set in this OptionSet
public EnumSet<GrepOption> asSet()
this
active option.asSet
in interface OptionSet<GrepOption>
public Iterator<GrepOption> iterator()
this
option.iterator
in interface Iterable<GrepOption>
iterator
in interface OptionSet<GrepOption>
this
active option.public int size()
this
optionsize
in interface OptionSet<GrepOption>
public boolean useAcronymFor(GrepOption option)
acronym
should be used for
the specified option
in string representations.
This method returns always true for all options.
useAcronymFor
in interface OptionSet<GrepOption>
option
- the option of interestCopyright © 2024. All rights reserved.