Package net.sf.jguiraffe.gui.cmd
Class CommandWrapper
- java.lang.Object
-
- net.sf.jguiraffe.gui.cmd.CommandWrapper
-
- All Implemented Interfaces:
Command
public class CommandWrapper extends Object implements Command
A wrapper implementation of the
Command
interface.An instance of this class is initialized with another
Command
object. It implements all methods defined by theCommand
interface by delegating to the wrappedCommand
object. Thus this class can serve as a base class for command implementations that need to alter certain behavior of other command objects.- Version:
- $Id: CommandWrapper.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description CommandWrapper(Command wrappedCmd)
Creates a new instance ofCommandWrapper
and initializes it with the wrapped command.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute()
Executes this command.Runnable
getGUIUpdater()
Returns the object for the updating the UI after execution of the command.Command
getWrappedCommand()
Returns theCommand
object that is wrapped by this object.void
onException(Throwable t)
Notifies this command about an exception that occurred during execution.void
onFinally()
This method is called after the execution of the command.
-
-
-
Constructor Detail
-
CommandWrapper
public CommandWrapper(Command wrappedCmd)
Creates a new instance ofCommandWrapper
and initializes it with the wrapped command.- Parameters:
wrappedCmd
- the wrapped command (must not be null)- Throws:
IllegalArgumentException
- if the wrapped command is null
-
-
Method Detail
-
getWrappedCommand
public final Command getWrappedCommand()
Returns theCommand
object that is wrapped by this object.- Returns:
- the wrapped
Command
-
execute
public void execute() throws Exception
Executes this command. This implementation delegates to the wrapped command.
-
getGUIUpdater
public Runnable getGUIUpdater()
Returns the object for the updating the UI after execution of the command. This implementation delegates to the wrapped command.- Specified by:
getGUIUpdater
in interfaceCommand
- Returns:
- the object for updating the UI
-
onException
public void onException(Throwable t)
Notifies this command about an exception that occurred during execution. This implementation delegates to the wrapped command.- Specified by:
onException
in interfaceCommand
- Parameters:
t
- the exception
-
-