Constructor and Description |
---|
CommandRegistry() |
Modifier and Type | Method and Description |
---|---|
CommandRegistry |
copy(Console console)
Returns a deep copy of this registry.
|
Command[] |
getAllCommands(String namespace)
Returns a array containing all the registered commands
having specified namespace.
|
String[] |
getAllLocalNames(String namespace)
Returns a sorted array containing the local names of
all the registered commands having specified namespace.
|
String[] |
getAllNames()
Returns a sorted array containing the names of all
the registered commands having a
null namespace. |
Command |
getCommand(String name)
Returns command with specified name.
|
String[] |
getDescription(Binding binding)
Returns a 3-field description of specified binding.
|
String[][] |
getDescriptions(Binding[] bindings)
Returns descriptions for specified bindings.
|
String |
getLabel(Command command)
Returns a label (guaranteed to be non-null) for specified command.
|
String |
getName(Command command)
Returns name of specified command.
|
static CommandRegistry |
getSharedInstance()
Returns the shared instance of CommandRegistry.
|
boolean |
isRegistered(String name)
Returns
true is command with specified name has been
registered. |
static String |
joinName(String namespace,
String localName)
Joins specified namespace and specified local name in order to
return a qualified name.
|
void |
register(String name,
Command command)
Eagerly registers specified command under specified name.
|
void |
register(String name,
String className)
Lazily registers specified command under specified name.
|
void |
register(String name,
String className,
Command command)
Registers specified command under specified name.
|
static void |
setSharedInstance(CommandRegistry registry)
Installs the shared instance of CommandRegistry.
|
static String[] |
splitName(String name)
Returns a 2-string array containing specified name split into
a namespace and a local name.
|
String |
toString() |
boolean |
unregister(String name)
Unregisters command having specified name.
|
public CommandRegistry copy(Console console)
console
- used to print copy errors; may be null
public void register(String name, String className)
Equivalent to register(name, className, null)
.
public void register(String name, Command command)
Equivalent to register(name, null, command)
.
public void register(String name, String className, Command command)
name
- name of command to be registered.
May not be null
or empty.className
- class of command to be registered.
May be null
is command is to be eagerly registered;
otherwise may not be null
or empty.command
- instance of command to be registered.
May be null
is command is to be lazily registered.
className and command may not both be
null
.public static String[] splitName(String name)
splitName("{foo}bar")
returns
["foo", "bar"]
.
splitName("bar")
returns [null, "bar"]
.
splitName("{}bar")
returns [null, "bar"]
.
public static String joinName(String namespace, String localName)
joinName("foo", "bar")
returns "{foo}bar".
joinName(null, "bar")
returns "bar".
joinName("", "bar")
returns "bar".
splitName(java.lang.String)
public boolean unregister(String name)
name
- name of command to be unregistered.true
if command has been unregistered;
false
if specified command is unknownpublic Command getCommand(String name)
null
if such
command has not been registered or if specified command has been
lazily registered and instantiating the class does not work.public boolean isRegistered(String name)
true
is command with specified name has been
registered. Returns false
otherwise.public String getName(Command command)
null
if
specified command has not been registered or if
specified command has been lazily registered and getCommand(java.lang.String)
has not yet been used for it.public String getLabel(Command command)
public String[] getAllNames()
null
namespace.
This command is equivalent to
getAllLocalNames(null)
.
public String[] getAllLocalNames(String namespace)
namespace
- the namespace of the commands.
May be null
.getAllNames()
public Command[] getAllCommands(String namespace)
namespace
- the namespace of the commands.
May be null
.public String[][] getDescriptions(Binding[] bindings)
public String[] getDescription(Binding binding)
public static final void setSharedInstance(CommandRegistry registry)
getSharedInstance()
public static final CommandRegistry getSharedInstance()
Creates and installs one if setSharedInstance(com.xmlmind.xmledit.control.CommandRegistry)
has never
been invoked or has been set to null
.