View Javadoc

1   /*
2    * Copyright  2004-2005 Stefan Reuter
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *
16   */
17  package net.sf.asterisk.manager.action;
18  
19  /***
20   * The GetVarAction queries for a global or local channel variable.<br>
21   * Reading global variables is supported since Asterisk 1.2.
22   * 
23   * @author srt
24   * @version $Id: GetVarAction.java,v 1.4 2005/11/02 20:02:37 srt Exp $
25   */
26  public class GetVarAction extends AbstractManagerAction
27  {
28      /***
29       * Serializable version identifier
30       */
31      private static final long serialVersionUID = 5239805071977668779L;
32      private String channel;
33      private String variable;
34  
35      /***
36       * Creates a new empty GetVarAction.
37       */
38      public GetVarAction()
39      {
40  
41      }
42  
43      /***
44       * Creates a new GetVarAction that queries for the given global variable.
45       * 
46       * @param variable the name of the global variable to query.
47       * @since 0.2
48       */
49      public GetVarAction(String variable)
50      {
51          this.variable = variable;
52      }
53  
54      /***
55       * Creates a new GetVarAction that queries for the given local channel
56       * variable.
57       * 
58       * @param channel the name of the channel, for example "SIP/1234-9cd".
59       * @param variable the name of the variable to query.
60       * @since 0.2
61       */
62      public GetVarAction(String channel, String variable)
63      {
64          this.channel = channel;
65          this.variable = variable;
66      }
67  
68      /***
69       * Returns the name of this action, i.e. "GetVar".
70       */
71      public String getAction()
72      {
73          return "GetVar";
74      }
75  
76      /***
77       * Returns the name of the channel if you query for a local channel variable
78       * or <code>null</code> if it is a global variable.
79       */
80      public String getChannel()
81      {
82          return channel;
83      }
84  
85      /***
86       * Sets the name of the channel if you query for a local channel variable.
87       * Leave empty to query for a global variable.
88       * 
89       * @param channel the channel if you query for a local channel variable or
90       *            <code>null</code> to query for a gloabl variable.
91       */
92      public void setChannel(String channel)
93      {
94          this.channel = channel;
95      }
96  
97      /***
98       * Retruns the name of the variable to query.
99       */
100     public String getVariable()
101     {
102         return variable;
103     }
104 
105     /***
106      * Sets the name of the variable to query.
107      */
108     public void setVariable(String variable)
109     {
110         this.variable = variable;
111     }
112 }