1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package nl.toolforge.karma.core.cmd.event;
20
21 import nl.toolforge.karma.core.cmd.Command;
22
23 /***
24 * Generated before a command is executed. This event has the default priority {@link CommandResponseEvent#LEVEL_DEBUG}.
25 *
26 * @author D.A. Smedes
27 * @version $Id: CommandStartedEvent.java,v 1.2 2004/10/26 22:47:58 hippe Exp $
28 */
29 public final class CommandStartedEvent extends CommandResponseEvent {
30
31 private long start = 0L;
32
33 /***
34 * Creates the event for <code>command</code>.
35 *
36 * @param command The command that has started.
37 */
38 public CommandStartedEvent(Command command) {
39 super(command, LEVEL_DEBUG);
40 start = System.currentTimeMillis();;
41 }
42
43 /***
44 * Returns the time this event was generated, effectively, the time the command was started.
45 *
46 * @return Start time of the command.
47 */
48 public long getTime() {
49 return start;
50 }
51
52 /***
53 * Returns a SimpleMessage formatted as <code>[ <command-name> ] Started.</code>.
54 */
55 public Message getEventMessage() {
56 return new SimpleMessage(MessageHelper.format(getCommand().getName(), "Started."));
57 }
58 }