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 voidaddCommand(Command command)Add a command.java.lang.String[]executeCommand(java.lang.String[] context, java.lang.String[] commandString)Execute a command.CommandfindCommand(java.lang.String[] cmd)Find a command.java.util.ListgetCommands()Returns a list of all registered commands.intgetDumpId()Returns a unique dump id for this object.voidreadContent(java.io.DataInput in)Read the content of this object from the stream.voidremoveCommand(Command command)Remove a command.voidsetDefaultCommand(CommandExecutor defaultCommand)Set a default command executor.voidsetName(java.lang.String name)Set the context name.voidwriteContent(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:DumpableReturns a unique dump id for this object.
-
writeContent
public void writeContent(java.io.DataOutput out) throws java.io.IOExceptionDescription copied from interface:DumpableWrite the content of this object to the stream.- Specified by:
writeContentin interfaceDumpable- Parameters:
out- output stream- Throws:
java.io.IOException- if an error occurs
-
readContent
public void readContent(java.io.DataInput in) throws java.io.IOExceptionDescription copied from interface:DumpableRead the content of this object from the stream.- Specified by:
readContentin 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.List 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.
-
-