public enum SedOption extends Enum<SedOption> implements Option, SedOptions
sed
command.
For most applications, it may be more convenient to use Sed.Options
instead of the option constants defined here.
-n | --quiet | Suppress the default output (in which each line, after it is examined for editing, is written to standard output). Only lines explicitly selected for output are written. | |||
-g | --global | Globally substitute for all non-overlapping instances of the regexp
rather than just the first one.
(This option is ignored if the occurrence operand is specified). | |||
-p | --print | Write the matched line to standard output. | |||
-l | --lineNumber | Writes the current line number on a separate line to the standard output. | |||
-I | --ignoreCase | Use case insensitive pattern matching. | |||
-s | --substitute | Substitutes the replacement string for instances of the regexp in
the matched line.
The characters "$0" appearing in the replacement are replaced by the line matching the regexp. The characters "$n", where n is a digit other than zero, are replaced by the text matched by the corresponding backreference expression (aka group). The special meaning of "$n" in this context can be suppressed by preceding it by a backslash. A line can be split by substituting a newline ('\n') into it. A substitution is considered to have been performed even if the replacement string is identical to the string that it replaces. | |||
-a | --append | Append string2 as a separate line after the matched line. | |||
-i | --insert | Insert string2 as a separate line before the matched line. | |||
-c | --change | Write string2 as a separate line instead of the matched line. | |||
-d | --delete | Delete the matched line. | |||
-y | --translate | Replace all occurrences of characters in string1 with the corresponding characters in string2. If the number of characters in the two strings are not equal, or if any of the characters in string1 appear more than once, the results are undefined. |
SedOptions.Default
Enum Constant and Description |
---|
append
Option
--append , -a :
Append string2 as a separate line after the matched line. |
change
Option
--change , -c :
Write string2 as a separate line instead of the matched line. |
delete
Option
--delete , -d :
Delete the matched line. |
global
Option
--global , -g :
Globally substitute for all non-overlapping instances of the regexp
rather than just the first one. |
ignoreCase
Option
--ignoreCase , -I :
Use case insensitive pattern matching. |
insert
Option
--insert , -i :
Insert string2 as a separate line before the matched line. |
lineNumber
Option
--lineNumber , -l :
Writes the current line number on a separate line to the standard
output. |
print
Option
--print , -p :
Write the matched line to standard output. |
quiet
Option
--quiet , -n :
Suppress the default output (in which each line, after it is
examined for editing, is written to standard output). |
substitute
Option
--substitute , -s :
Substitutes the replacement string for instances of the regexp in
the matched line. |
translate
Option
--translate , -y :
Replace all occurrences of characters in string1 with the
corresponding characters in string2. |
CONVERTER, EMPTY
Modifier and Type | Method and Description |
---|---|
char |
acronym()
Returns a one letter acronym for this option.
|
EnumSet<SedOption> |
asSet()
Returns a new set with
this active option. |
static SedOption |
findByAcronym(char acronym)
Returns the option with the given
acronym , or null if no
such option is found. |
boolean |
isSet(SedOption option)
Returns true if the specified
option is set and false otherwise |
Iterator<SedOption> |
iterator()
Returns an immutable iterator returning o single element:
this
option. |
Class<SedOption> |
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(SedOption option)
Returns true if the
acronym should be used for
the specified option in string representations. |
static SedOption |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static SedOption[] |
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 SedOption quiet
--quiet
, -n
:
Suppress the default output (in which each line, after it is
examined for editing, is written to standard output). Only lines
explicitly selected for output are written.public static final SedOption global
--global
, -g
:
Globally substitute for all non-overlapping instances of the regexp
rather than just the first one.
(This option is ignored if the occurrence operand is specified).
public static final SedOption print
--print
, -p
:
Write the matched line to standard output.public static final SedOption lineNumber
--lineNumber
, -l
:
Writes the current line number on a separate line to the standard
output.public static final SedOption ignoreCase
--ignoreCase
, -I
:
Use case insensitive pattern matching.public static final SedOption substitute
--substitute
, -s
:
Substitutes the replacement string for instances of the regexp in
the matched line.
The characters "$0" appearing in the replacement are replaced by the line matching the regexp. The characters "$n", where n is a digit other than zero, are replaced by the text matched by the corresponding backreference expression (aka group). The special meaning of "$n" in this context can be suppressed by preceding it by a backslash.
A line can be split by substituting a newline ('\n') into it.
A substitution is considered to have been performed even if the replacement string is identical to the string that it replaces.
public static final SedOption append
--append
, -a
:
Append string2 as a separate line after the matched line.public static final SedOption insert
--insert
, -i
:
Insert string2 as a separate line before the matched line.public static final SedOption change
--change
, -c
:
Write string2 as a separate line instead of the matched line.public static final SedOption translate
--translate
, -y
:
Replace all occurrences of characters in string1 with the
corresponding characters in string2. If the number of characters in
the two strings are not equal, or if any of the characters in
string1 appear more than once, the results are undefined.public static SedOption[] values()
for (SedOption c : SedOption.values()) System.out.println(c);
public static SedOption 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<SedOption> optionType()
OptionSet
optionType
in interface OptionSet<SedOption>
public static SedOption 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(SedOption option)
OptionSet
option
is set and false otherwisepublic Iterator<SedOption> iterator()
this
option.public int size()
this
optionpublic boolean useAcronymFor(SedOption option)
acronym
should be used for
the specified option
in string representations.
This method returns always true for all options.
useAcronymFor
in interface OptionSet<SedOption>
option
- the option of interestCopyright © 2024. All rights reserved.