Package com.swiftmq.mgmt
Class CommandRegistry
- java.lang.Object
-
- com.swiftmq.mgmt.CommandRegistry
-
- All Implemented Interfaces:
Dumpable
public class CommandRegistry extends java.lang.Object implements Dumpable
A CommandRegistry object will be attached to Entities/EntityLists. It contains all commands for that Entity.- Author:
- IIT GmbH, Bremen/Germany, Copyright (c) 2000-2002, All Rights Reserved
- See Also:
Entity
,EntityList
-
-
Constructor Summary
Constructors Constructor Description CommandRegistry(java.lang.String name, Entity myEntity)
Creates a new CommandRegistry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCommand(Command command)
Add a command.java.lang.String[]
executeCommand(java.lang.String[] context, java.lang.String[] commandString)
Execute a command.Command
findCommand(java.lang.String[] cmd)
Find a command.java.util.ArrayList
getCommands()
Returns a list of all registered commands.int
getDumpId()
Returns a unique dump id for this object.void
readContent(java.io.DataInput in)
Read the content of this object from the stream.void
removeCommand(Command command)
Remove a command.void
setDefaultCommand(CommandExecutor defaultCommand)
Set a default command executor.void
setName(java.lang.String name)
Set the context name.void
writeContent(java.io.DataOutput out)
Write the content of this object to the stream.
-
-
-
Constructor Detail
-
CommandRegistry
public CommandRegistry(java.lang.String name, Entity myEntity)
Creates a new CommandRegistry.- Parameters:
name
- the name of the context; will be used to display help content.myEntity
- attached Entity.
-
-
Method Detail
-
getDumpId
public int getDumpId()
Description copied from interface:Dumpable
Returns a unique dump id for this object.
-
writeContent
public void writeContent(java.io.DataOutput out) throws java.io.IOException
Description copied from interface:Dumpable
Write the content of this object to the stream.- Specified by:
writeContent
in interfaceDumpable
- Parameters:
out
- output stream- Throws:
java.io.IOException
- if an error occurs
-
readContent
public void readContent(java.io.DataInput in) throws java.io.IOException
Description copied from interface:Dumpable
Read the content of this object from the stream.- Specified by:
readContent
in interfaceDumpable
- Parameters:
in
- input stream- Throws:
java.io.IOException
- if an error occurs
-
setName
public void setName(java.lang.String name)
Set the context name.- Parameters:
name
- name.
-
setDefaultCommand
public void setDefaultCommand(CommandExecutor defaultCommand)
Set a default command executor. It will executed if no other registered command matches inexecuteCommand()
.- Parameters:
defaultCommand
- default command executor.
-
getCommands
public java.util.ArrayList getCommands()
Returns a list of all registered commands.- Returns:
- command list.
-
addCommand
public void addCommand(Command command)
Add a command.- Parameters:
command
- command.
-
removeCommand
public void removeCommand(Command command)
Remove a command.- Parameters:
command
- command.
-
findCommand
public Command findCommand(java.lang.String[] cmd)
Find a command.- Parameters:
cmd
- tokenized command name.- Returns:
- command or null.
-
executeCommand
public java.lang.String[] executeCommand(java.lang.String[] context, java.lang.String[] commandString)
Execute a command. If no command is found, the default command is executes. If no default command has been registered, a error structure is returned ("Unknown command").- Parameters:
context
- the command context.commandString
- the tokenized command string.- Returns:
- state structure.
-
-