1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.asteriskjava.manager.action;
18
19 /***
20 * The CommandAction sends a command line interface (CLI) command to the
21 * asterisk server.<p>
22 * For a list of supported commands type <code>help</code> on Asterisk's
23 * command line.<p>
24 * In response to a CommandAction you will receive a CommandResponse that
25 * contains the CLI output.<p>
26 * Example:
27 * <pre>
28 * CommandAction commandAction = new CommandAction("iax2 show peers");
29 * CommandResponse response = (CommandResponse) c.sendAction(commandAction);
30 * for (String line : response.getResult())
31 * {
32 * System.out.println(line);
33 * }
34 * </pre>
35 * Where <code>c</code> is an instance of
36 * {@link org.asteriskjava.manager.ManagerConnection}.
37 *
38 * @see org.asteriskjava.manager.response.CommandResponse
39 * @author srt
40 * @version $Id: CommandAction.java 729 2007-05-26 05:16:57Z sprior $
41 */
42 public class CommandAction extends AbstractManagerAction
43 {
44 /***
45 * Serializable version identifier
46 */
47 static final long serialVersionUID = 4753117770471622025L;
48
49 protected String command;
50
51 /***
52 * Creates a new CommandAction.
53 */
54 public CommandAction()
55 {
56
57 }
58
59 /***
60 * Creates a new CommandAction with the given command.
61 *
62 * @param command the CLI command to execute.
63 * @since 0.2
64 */
65 public CommandAction(String command)
66 {
67 this.command = command;
68 }
69
70 /***
71 * Returns the name of this action, i.e. "Command".
72 */
73 @Override
74 public String getAction()
75 {
76 return "Command";
77 }
78
79 /***
80 * Returns the command.
81 */
82 public String getCommand()
83 {
84 return command;
85 }
86
87 /***
88 * Sets the CLI command to send to the Asterisk server.
89 */
90 public void setCommand(String command)
91 {
92 this.command = command;
93 }
94 }