- java.lang.Object
-
- org.jline.console.impl.AbstractCommandRegistry
-
- All Implemented Interfaces:
CommandRegistry
- Direct Known Subclasses:
JlineCommandRegistry
public abstract class AbstractCommandRegistry extends Object implements CommandRegistry
CommandRegistry common methods.- Author:
- Matti Rinta-Nikkola
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jline.console.CommandRegistry
CommandRegistry.CommandSession
-
-
Constructor Summary
Constructors Constructor Description AbstractCommandRegistry()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
alias(String alias, String command)
Map<String,String>
commandAliases()
Returns a map of alias-to-command names known by this registry.Set<String>
commandNames()
Returns the command names known by this registry.SystemCompleter
compileCompleters()
Returns aSystemCompleter
that can provide detailed completion information for all registered commands.CmdDesc
doHelpDesc(String command, List<String> info, CmdDesc cmdDesc)
CommandMethods
getCommandMethods(String command)
boolean
hasCommand(String command)
Returns whether a command with the specified name is known to this registry.Object
invoke(CommandRegistry.CommandSession session, String command, Object... args)
Execute a command.void
registerCommands(Map<String,CommandMethods> commandExecute)
<T extends Enum<T>>
voidregisterCommands(Map<T,String> commandName, Map<T,CommandMethods> commandExecute)
Object
registeredCommand(String command)
<V extends Enum<V>>
voidrename(V command, String newName)
void
saveException(Exception exception)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jline.console.CommandRegistry
commandDescription, commandInfo, name
-
-
-
-
Method Detail
-
registerCommands
public <T extends Enum<T>> void registerCommands(Map<T,String> commandName, Map<T,CommandMethods> commandExecute)
-
registerCommands
public void registerCommands(Map<String,CommandMethods> commandExecute)
-
invoke
public Object invoke(CommandRegistry.CommandSession session, String command, Object... args) throws Exception
Description copied from interface:CommandRegistry
Execute a command.- Specified by:
invoke
in interfaceCommandRegistry
- Parameters:
session
- the data of the current command sessioncommand
- the name of the commandargs
- arguments of the command- Returns:
- result of the command execution
- Throws:
Exception
- in case of error
-
saveException
public void saveException(Exception exception)
-
hasCommand
public boolean hasCommand(String command)
Description copied from interface:CommandRegistry
Returns whether a command with the specified name is known to this registry.- Specified by:
hasCommand
in interfaceCommandRegistry
- Parameters:
command
- the command name to test- Returns:
- true if the specified command is registered
-
commandNames
public Set<String> commandNames()
Description copied from interface:CommandRegistry
Returns the command names known by this registry.- Specified by:
commandNames
in interfaceCommandRegistry
- Returns:
- the set of known command names, excluding aliases
-
commandAliases
public Map<String,String> commandAliases()
Description copied from interface:CommandRegistry
Returns a map of alias-to-command names known by this registry.- Specified by:
commandAliases
in interfaceCommandRegistry
- Returns:
- a map with alias keys and command name values
-
compileCompleters
public SystemCompleter compileCompleters()
Description copied from interface:CommandRegistry
Returns aSystemCompleter
that can provide detailed completion information for all registered commands.- Specified by:
compileCompleters
in interfaceCommandRegistry
- Returns:
- a SystemCompleter that can provide command completion for all registered commands
-
getCommandMethods
public CommandMethods getCommandMethods(String command)
-
-