Class 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 the Command interface by delegating to the wrapped Command 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 Detail

      • CommandWrapper

        public CommandWrapper​(Command wrappedCmd)
        Creates a new instance of CommandWrapper 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 the Command 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.
        Specified by:
        execute in interface Command
        Throws:
        Exception - if an error occurs during execution
      • 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 interface Command
        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 interface Command
        Parameters:
        t - the exception
      • onFinally

        public void onFinally()
        This method is called after the execution of the command. This implementation delegates to the wrapped command.
        Specified by:
        onFinally in interface Command