Package org.jboss.as.cli.impl
Class ArgumentWithValue
- java.lang.Object
-
- org.jboss.as.cli.impl.ArgumentWithoutValue
-
- org.jboss.as.cli.impl.ArgumentWithValue
-
- All Implemented Interfaces:
CommandArgument
- Direct Known Subclasses:
ArgumentWithListValue,ConditionArgument,FileSystemPathArgument,RequestParamArgWithValue
public class ArgumentWithValue extends ArgumentWithoutValue
- Author:
- Alexey Loubyansky
-
-
Field Summary
Fields Modifier and Type Field Description protected ParsingStateinitialStateinitial state for value parsing-
Fields inherited from class org.jboss.as.cli.impl.ArgumentWithoutValue
access, cantAppearAfter, exclusive, fullName, index, requiredPreceding, shortName
-
-
Constructor Summary
Constructors Constructor Description ArgumentWithValue(CommandHandlerWithArguments handler, int index, String fullName)ArgumentWithValue(CommandHandlerWithArguments handler, String fullName)ArgumentWithValue(CommandHandlerWithArguments handler, CommandLineCompleter valueCompleter, int index, String fullName)ArgumentWithValue(CommandHandlerWithArguments handler, CommandLineCompleter valueCompleter, String fullName)ArgumentWithValue(CommandHandlerWithArguments handler, CommandLineCompleter valueCompleter, ArgumentValueConverter valueConverter, String fullName)ArgumentWithValue(CommandHandlerWithArguments handler, CommandLineCompleter valueCompleter, ArgumentValueConverter valueConverter, String fullName, String shortName)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetOriginalValue(ParsedCommandLine parsedLine, boolean required)Returns value as it appeared on the command line with escape sequences and system properties not resolved.StringgetResolvedValue(ParsedCommandLine parsedLine, boolean required)Calls getOriginalValue(ParsedCommandLine parsedLine, boolean required) and correctly handles escape sequences and resolves system properties.StringgetValue(ParsedCommandLine args, boolean required)Returns the value of the argument specified on the command line.CommandLineCompletergetValueCompleter()Returns the tab-completer for the value.ArgumentValueConvertergetValueConverter()protected ParsingStateinitParsingState()booleanisValueComplete(ParsedCommandLine args)Checks whether the value is specified and complete.booleanisValueRequired()Argument can only appear if not already present in the parsed command BUT this is not all the time true, for example, an argument cannot appear AFTER some other arguments.static StringresolveValue(String value)static StringresolveValue(String value, ParsingState initialState)org.jboss.dmr.ModelNodetoModelNode(CommandContext ctx)-
Methods inherited from class org.jboss.as.cli.impl.ArgumentWithoutValue
addCantAppearAfter, addRequiredPreceding, canAppearNext, getFullName, getIndex, getShortName, getValue, isExclusive, isPresent, setAccessRequirement, setExclusive
-
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
-
initialState
protected final ParsingState initialState
initial state for value parsing
-
-
Constructor Detail
-
ArgumentWithValue
public ArgumentWithValue(CommandHandlerWithArguments handler, String fullName)
-
ArgumentWithValue
public ArgumentWithValue(CommandHandlerWithArguments handler, CommandLineCompleter valueCompleter, String fullName)
-
ArgumentWithValue
public ArgumentWithValue(CommandHandlerWithArguments handler, CommandLineCompleter valueCompleter, ArgumentValueConverter valueConverter, String fullName)
-
ArgumentWithValue
public ArgumentWithValue(CommandHandlerWithArguments handler, int index, String fullName)
-
ArgumentWithValue
public ArgumentWithValue(CommandHandlerWithArguments handler, CommandLineCompleter valueCompleter, int index, String fullName)
-
ArgumentWithValue
public ArgumentWithValue(CommandHandlerWithArguments handler, CommandLineCompleter valueCompleter, ArgumentValueConverter valueConverter, String fullName, String shortName)
-
-
Method Detail
-
initParsingState
protected ParsingState initParsingState()
-
getValueCompleter
public CommandLineCompleter getValueCompleter()
Description copied from interface:CommandArgumentReturns the tab-completer for the value.- Specified by:
getValueCompleterin interfaceCommandArgument- Overrides:
getValueCompleterin classArgumentWithoutValue- Returns:
- tab-completer for the value or null of none available.
-
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- Overrides:
getValuein classArgumentWithoutValue- 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
-
getResolvedValue
public String getResolvedValue(ParsedCommandLine parsedLine, boolean required) throws CommandFormatException
Calls getOriginalValue(ParsedCommandLine parsedLine, boolean required) and correctly handles escape sequences and resolves system properties.- Parameters:
parsedLine- parsed command linerequired- whether the argument is required- Returns:
- resolved argument value
- Throws:
CommandFormatException- in case the required argument is missing
-
resolveValue
public static String resolveValue(String value) throws CommandFormatException
- Throws:
CommandFormatException
-
resolveValue
public static String resolveValue(String value, ParsingState initialState) throws CommandFormatException
- Throws:
CommandFormatException
-
getOriginalValue
public String getOriginalValue(ParsedCommandLine parsedLine, boolean required) throws CommandFormatException
Returns value as it appeared on the command line with escape sequences and system properties not resolved. The variables, though, are resolved during the initial parsing of the command line.- Parameters:
parsedLine- parsed command linerequired- whether the argument is required- Returns:
- argument value as it appears on the command line
- Throws:
CommandFormatException- in case the required argument is missing
-
toModelNode
public org.jboss.dmr.ModelNode toModelNode(CommandContext ctx) throws CommandFormatException
- Throws:
CommandFormatException
-
isValueRequired
public boolean isValueRequired()
Argument can only appear if not already present in the parsed command BUT this is not all the time true, for example, an argument cannot appear AFTER some other arguments. This logic is in the parent implementation. That is why, although we would like to redefine the method at this point we can't.- Specified by:
isValueRequiredin interfaceCommandArgument- Overrides:
isValueRequiredin classArgumentWithoutValue- Returns:
- true if this argument accepts a value, otherwise false.
-
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- Overrides:
isValueCompletein classArgumentWithoutValue- Parameters:
args- the parsed arguments- Returns:
- true if the value of the argument is complete, false otherwise.
- Throws:
CommandFormatException
-
getValueConverter
public ArgumentValueConverter getValueConverter()
-
-