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.fastagi.command;
18  
19  /***
20   * Returns the value of the given channel varible.<br>
21   * Since Asterisk 1.2 you can also use this command to use custom Asterisk
22   * functions. Syntax is "func(args)".<br>
23   * Returns 0 if the variable is not set. Returns 1 if the variable is set and
24   * returns the variable in parenthesis.<br>
25   * Example return code: 200 result=1 (testvariable)
26   * 
27   * @author srt
28   * @version $Id: GetVariableCommand.java,v 1.6 2005/11/08 21:11:31 srt Exp $
29   */
30  public class GetVariableCommand extends AGICommand
31  {
32      /***
33       * Serial version identifier.
34       */
35      private static final long serialVersionUID = 3256719598056387384L;
36  
37      /***
38       * The name of the variable to retrieve.
39       */
40      private String variable;
41  
42      /***
43       * Creates a new GetVariableCommand.
44       * 
45       * @param variable the name of the variable to retrieve.
46       */
47      public GetVariableCommand(String variable)
48      {
49          this.variable = variable;
50      }
51  
52      /***
53       * Returns the name of the variable to retrieve.
54       * 
55       * @return the the name of the variable to retrieve.
56       */
57      public String getVariable()
58      {
59          return variable;
60      }
61  
62      /***
63       * Sets the name of the variable to retrieve.<br>
64       * Since Asterisk 1.2 you can also use custom dialplan functions (like
65       * "func(args)") as variable.
66       * 
67       * @param variable the name of the variable to retrieve.
68       */
69      public void setVariable(String variable)
70      {
71          this.variable = variable;
72      }
73  
74      public String buildCommand()
75      {
76          return "GET VARIABLE " + escapeAndQuote(variable);
77      }
78  }