Package com.sun.identity.cli
Class SubCommand
- java.lang.Object
-
- com.sun.identity.cli.SubCommand
-
public class SubCommand extends Object
This class contains definition of sub command.
-
-
Constructor Summary
Constructors Constructor Description SubCommand(IDefinition definition, ResourceBundle rb, String name, List mandatoryOptions, List optionalOptions, List optionAliases, String implClassName, boolean webSupport, String deprecationWarning)
Creates a sub command object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkboxUI(String opt)
Returnstrue
if option is to be displayed as checkbox in web based CLI.void
execute(RequestContext rc)
Services a CLI request.String
getDeprecationWarning()
String
getDescription()
Returns description of the sub command.String
getLongOptionName(String name)
Returns long argument/option name given its short name.List
getMandatoryOptions()
Returns list of mandatory argument/options.String
getName()
Returns name of the sub command.List
getOptionAliases(String name)
Returns option aliases.Set
getOptionAliasesGroup(String fullName)
Returns option aliases group.List
getOptionalOptions()
Returns list of optional argument/options.String
getOptionDescription(String name)
Returns the description of an argument/option.String
getOptionDescription(String name, boolean isWeb)
Returns the description of an argument/option.static String
getReservedLongOptionName(String shortName)
Returns long reserved argument/option name given its short name.static String
getReservedShortOptionName(String longName)
Returns short reserved argument/option name given its long name.ResourceBundle
getResourceBundle()
Returns resource bundle of the sub command.String
getShortOptionName(String name)
Returns short argument/option name given its long name.boolean
isBinaryOption(String cmdName)
Returnstrue
if option is binary.boolean
isOptionAlias(String name)
Returnstrue
if option is an alias.static boolean
isReservedLongOption(String name)
Returnstrue
if an argument/option is reserved.static boolean
isReservedShortOption(String name)
Returnstrue
if an argument/option is reserved.boolean
isSupportedOption(String name)
Returnsif the option is supported. boolean
isUnaryOption(String cmdName)
Returnstrue
if option is unary.boolean
textareaUI(String opt)
Returnstrue
if option is to be displayed as text area in web based CLI.boolean
validateOptions(Map options, SSOToken ssoToken)
Returnstrue
if the given options are valid in the context of this sub command.boolean
webEnabled()
Returnstrue
if this command is supported on web browser.
-
-
-
Constructor Detail
-
SubCommand
public SubCommand(IDefinition definition, ResourceBundle rb, String name, List mandatoryOptions, List optionalOptions, List optionAliases, String implClassName, boolean webSupport, String deprecationWarning) throws CLIException
Creates a sub command object.- Parameters:
definition
- Definition class.rb
- Resource Bundle.name
- Name of the Sub Command.mandatoryOptions
- Formated list of mandatory argument/options.optionalOptions
- Formated list of optional argument/options.optionAliases
- Formated list of argument/options aliases.implClassName
- Implementation class name.webSupport
-true
if this command is supported on the web browser.deprecationWarning
- if set to a non zero length string (default is "") then print this warning.- Throws:
CLIException
- if this object cannot be constructed.
-
-
Method Detail
-
isReservedShortOption
public static boolean isReservedShortOption(String name)
Returnstrue
if an argument/option is reserved.- Parameters:
name
- Short name of argument/option.- Returns:
true
if an argument/option is reserved.
-
isReservedLongOption
public static boolean isReservedLongOption(String name)
Returnstrue
if an argument/option is reserved.- Parameters:
name
- Full name of argument/option.- Returns:
true
if an argument/option is reserved.
-
getReservedShortOptionName
public static String getReservedShortOptionName(String longName)
Returns short reserved argument/option name given its long name.- Parameters:
longName
- Long name of reserved argument/option.- Returns:
- short reserved argument/option name given its long name. Returns null if short name is not found.
-
getReservedLongOptionName
public static String getReservedLongOptionName(String shortName)
Returns long reserved argument/option name given its short name.- Parameters:
shortName
- Short name of reserved argument/option.- Returns:
- long reserved argument/option name given its short name. Returns null if long name is not found.
-
getName
public String getName()
Returns name of the sub command.- Returns:
- name of the sub command.
-
getDescription
public String getDescription()
Returns description of the sub command.- Returns:
- description of the sub command.
-
getOptionalOptions
public List getOptionalOptions()
Returns list of optional argument/options.- Returns:
- list of optional argument/options.
-
getMandatoryOptions
public List getMandatoryOptions()
Returns list of mandatory argument/options.- Returns:
- list of mandatory argument/options.
-
getOptionAliases
public List getOptionAliases(String name)
Returns option aliases.- Parameters:
name
- Full name of argument/option.- Returns:
- get option aliases. Returns null of there are no aliases.
-
getOptionAliasesGroup
public Set getOptionAliasesGroup(String fullName)
Returns option aliases group.- Parameters:
fullName
- Full name of argument/option.- Returns:
- option aliases group.
-
isOptionAlias
public boolean isOptionAlias(String name)
Returnstrue
if option is an alias.- Parameters:
name
- Full name of argument/option.- Returns:
true
if option is an alias.
-
execute
public void execute(RequestContext rc) throws CLIException
Services a CLI request.- Parameters:
rc
- Request Context.- Throws:
CLIException
- if request cannot be serviced.
-
validateOptions
public boolean validateOptions(Map options, SSOToken ssoToken)
Returnstrue
if the given options are valid in the context of this sub command.- Parameters:
options
- Map of argument/option full name to its values (List).ssoToken
- Single Sign On token of the user.- Returns:
true
if the given options are valid.
-
getLongOptionName
public String getLongOptionName(String name)
Returns long argument/option name given its short name.- Parameters:
name
- short name of argument/option.- Returns:
- long argument/option name given its short name. Returns null if short name is not found.
-
getShortOptionName
public String getShortOptionName(String name)
Returns short argument/option name given its long name.- Parameters:
name
- Long name of argument/option.- Returns:
- short argument/option name given its long name. Returns null if short name is not found.
-
isSupportedOption
public boolean isSupportedOption(String name)
Returnsif the option is supported. - Parameters:
name
- Name of the argument/option.- Returns:
if the option is supported.
-
getOptionDescription
public String getOptionDescription(String name)
Returns the description of an argument/option.- Parameters:
name
- Name of the argument/option.- Returns:
- the description of an argument/option.
-
getOptionDescription
public String getOptionDescription(String name, boolean isWeb)
Returns the description of an argument/option.- Parameters:
name
- Name of the argument/option.isWeb
-true
if CLI is accessed via browser.- Returns:
- the description of an argument/option.
-
getResourceBundle
public ResourceBundle getResourceBundle()
Returns resource bundle of the sub command.- Returns:
- resource bundle of the sub command.
-
isUnaryOption
public boolean isUnaryOption(String cmdName)
Returnstrue
if option is unary.- Returns:
true
if option is unary.
-
isBinaryOption
public boolean isBinaryOption(String cmdName)
Returnstrue
if option is binary.- Returns:
true
if option is binary.
-
webEnabled
public boolean webEnabled()
Returnstrue
if this command is supported on web browser.- Returns:
true
if this command is supported on web browser.
-
getDeprecationWarning
public String getDeprecationWarning()
- Returns:
- any deprecation warning (by default this is set to the empty string).
-
textareaUI
public boolean textareaUI(String opt)
Returnstrue
if option is to be displayed as text area in web based CLI.- Parameters:
opt
- Name of option.- Returns:
true
if option is to be displayed as text area.
-
checkboxUI
public boolean checkboxUI(String opt)
Returnstrue
if option is to be displayed as checkbox in web based CLI.- Parameters:
opt
- Name of option.- Returns:
true
if option is to be displayed as checkbox.
-
-