Package org.jboss.as.cli.impl
Class ArgumentWithoutValue
- java.lang.Object
-
- org.jboss.as.cli.impl.ArgumentWithoutValue
-
- All Implemented Interfaces:
CommandArgument
- Direct Known Subclasses:
ArgumentWithValue,RequestParamArgWithoutValue
public class ArgumentWithoutValue extends Object implements CommandArgument
- Author:
- Alexey Loubyansky
-
-
Field Summary
Fields Modifier and Type Field Description protected AccessRequirementaccessprotected List<CommandArgument>cantAppearAfterprotected booleanexclusiveprotected StringfullNameprotected intindexprotected List<CommandArgument>requiredPrecedingprotected StringshortName
-
Constructor Summary
Constructors Constructor Description ArgumentWithoutValue(CommandHandlerWithArguments handler, int index, String fullName)ArgumentWithoutValue(CommandHandlerWithArguments handler, String fullName)ArgumentWithoutValue(CommandHandlerWithArguments handler, String fullName, String shortName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCantAppearAfter(CommandArgument arg)voidaddRequiredPreceding(CommandArgument arg)booleancanAppearNext(CommandContext ctx)Checks whether the argument can appear on the command given the already present arguments.StringgetFullName()The default name of the argument.intgetIndex()If the argument doesn't have a name its value can be found by index.StringgetShortName()Short name of the argument if exists.StringgetValue(ParsedCommandLine args)Returns the value of the argument specified on the command line.StringgetValue(ParsedCommandLine args, boolean required)Returns the value of the argument specified on the command line.CommandLineCompletergetValueCompleter()Returns the tab-completer for the value.booleanisExclusive()booleanisPresent(ParsedCommandLine args)Checks whether the argument is present on the command line.booleanisValueComplete(ParsedCommandLine args)Checks whether the value is specified and complete.booleanisValueRequired()Checks whether the argument accepts value.voidsetAccessRequirement(AccessRequirement access)voidsetExclusive(boolean exclusive)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jboss.as.cli.CommandArgument
getDecoratedName
-
-
-
-
Field Detail
-
index
protected final int index
-
fullName
protected final String fullName
-
shortName
protected final String shortName
-
requiredPreceding
protected List<CommandArgument> requiredPreceding
-
cantAppearAfter
protected List<CommandArgument> cantAppearAfter
-
exclusive
protected boolean exclusive
-
access
protected AccessRequirement access
-
-
Constructor Detail
-
ArgumentWithoutValue
public ArgumentWithoutValue(CommandHandlerWithArguments handler, String fullName)
-
ArgumentWithoutValue
public ArgumentWithoutValue(CommandHandlerWithArguments handler, String fullName, String shortName)
-
ArgumentWithoutValue
public ArgumentWithoutValue(CommandHandlerWithArguments handler, int index, String fullName)
-
-
Method Detail
-
setExclusive
public void setExclusive(boolean exclusive)
-
isExclusive
public boolean isExclusive()
-
addRequiredPreceding
public void addRequiredPreceding(CommandArgument arg)
-
addCantAppearAfter
public void addCantAppearAfter(CommandArgument arg)
-
getIndex
public int getIndex()
Description copied from interface:CommandArgumentIf the argument doesn't have a name its value can be found by index. Indexes start with 0. A command could have both a name and an index. In that case, the name is optional. If the command doesn't have a fixed index, the method will return -1.- Specified by:
getIndexin interfaceCommandArgument- Returns:
- the index of the argument.
-
getValueCompleter
public CommandLineCompleter getValueCompleter()
Description copied from interface:CommandArgumentReturns the tab-completer for the value.- Specified by:
getValueCompleterin interfaceCommandArgument- Returns:
- tab-completer for the value or null of none available.
-
getValue
public String getValue(ParsedCommandLine args)
Description copied from interface:CommandArgumentReturns the value of the argument specified on the command line. If the argument isn't specified the returned value is null. Although, it might throw IllegalArgumentException in case the argument is a required one.- Specified by:
getValuein interfaceCommandArgument- Parameters:
args- parsed arguments.- Returns:
- the value of the argument or null if the argument isn't present or is missing value.
-
getValue
public String getValue(ParsedCommandLine args, boolean required) throws CommandFormatException
Description copied from interface:CommandArgumentReturns the value of the argument specified on the command line. If the argument isn't specified and the value is not required null is returned. Otherwise an exception is thrown.- Specified by:
getValuein interfaceCommandArgument- Parameters:
args- parsed arguments.required- whether the value for this argument is required.- Returns:
- the value of the argument or null if the argument isn't present and the value is not required.
- Throws:
CommandFormatException
-
isPresent
public boolean isPresent(ParsedCommandLine args) throws CommandFormatException
Description copied from interface:CommandArgumentChecks whether the argument is present on the command line.- Specified by:
isPresentin interfaceCommandArgument- Parameters:
args- parsed arguments- Returns:
- true if the argument is present, false - otherwise.
- Throws:
CommandFormatException
-
isValueComplete
public boolean isValueComplete(ParsedCommandLine args) throws CommandFormatException
Description copied from interface:CommandArgumentChecks whether the value is specified and complete. The value is considered complete only if it is followed by a separator (argument separator, end of argument list but not end-of-content).- Specified by:
isValueCompletein interfaceCommandArgument- Parameters:
args- the parsed arguments- Returns:
- true if the value of the argument is complete, false otherwise.
- Throws:
CommandFormatException
-
getFullName
public String getFullName()
Description copied from interface:CommandArgumentThe default name of the argument. An argument can have more than one name, e.g. --force and -f. Full name can't be null.- Specified by:
getFullNamein interfaceCommandArgument- Returns:
- the default name of the argument.
-
canAppearNext
public boolean canAppearNext(CommandContext ctx) throws CommandFormatException
Description copied from interface:CommandArgumentChecks whether the argument can appear on the command given the already present arguments. (Used for tab-completion. Although, often isValueComplete(ParsedOperationRequest req) would be more appropriate.)- Specified by:
canAppearNextin interfaceCommandArgument- Returns:
- true if the argument can appear on the command line next, false - otherwise.
- Throws:
CommandFormatException
-
isValueRequired
public boolean isValueRequired()
Description copied from interface:CommandArgumentChecks whether the argument accepts value.- Specified by:
isValueRequiredin interfaceCommandArgument- Returns:
- true if this argument accepts a value, otherwise false.
-
getShortName
public String getShortName()
Description copied from interface:CommandArgumentShort name of the argument if exists.- Specified by:
getShortNamein interfaceCommandArgument- Returns:
- short name of the argument or null if the short name doesn't exist.
-
setAccessRequirement
public void setAccessRequirement(AccessRequirement access)
-
-