View Javadoc

1   /*
2   Karma core - Core of the Karma application
3   Copyright (C) 2004  Toolforge <www.toolforge.nl>
4   
5   This library is free software; you can redistribute it and/or
6   modify it under the terms of the GNU Lesser General Public
7   License as published by the Free Software Foundation; either
8   version 2.1 of the License, or (at your option) any later version.
9   
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  Lesser General Public License for more details.
14  
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19  package nl.toolforge.karma.core.cmd.event;
20  
21  import nl.toolforge.karma.core.cmd.Command;
22  
23  /***
24   * Event thrown when a {@link nl.toolforge.karma.core.cmd.CommandResponse} changes. Classes interested in this event
25   * implement the {@link CommandResponseListener} interface.
26   *
27   * @author W.H.Schraal
28   * @author D.A. Smedes
29   */
30  public abstract class CommandResponseEvent implements Event {
31  
32    private Command command = null;
33  
34    private int priority = LEVEL_INFO;
35  
36    /***
37     * Constructs a <code>CommandResponseEvent</code> and assumes the default priority to be {@link #LEVEL_INFO}.
38     *
39     * @param command The <code>Command</code> that generated
40     */
41    public CommandResponseEvent(Command command) {
42      this(command, Event.LEVEL_INFO);
43    }
44  
45    /***
46     * Constructs a <code>CommandResponseEvent</code>.
47     *
48     * @param command  The <code>Command</code> that generated
49     * @param priority The priority of the event.
50     */
51    public CommandResponseEvent(Command command, int priority) {
52      this.command = command;
53      this.priority = priority;
54    }
55  
56    /***
57     * Gets the priority level for the event.
58     *
59     * @return The priority level for the event.
60     *
61     * @see    {@link #LEVEL_VERBOSE}
62     * @see    {@link #LEVEL_INFO}
63     * @see    {@link #LEVEL_DEBUG}
64     */
65    public final int getPriority() {
66      return priority;
67    }
68  
69    /***
70     * Implementations should return a specific {@link Message} instance.
71     * @return
72     */
73    public abstract Message getEventMessage();
74  
75    /***
76     * Returns the command that generated this event.
77     *
78     * @return The {@link Command} command that generated this event.
79     */
80    public Command getCommand() {
81      return command;
82    }
83  }