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   * Retrieves an entry in the Asterisk database for a given family and key.<br>
21   * Returns 0 if is not set. Returns 1 if the variable is set and returns the
22   * value in parenthesis.<br>
23   * Example return code: 200 result=1 (testvariable)
24   * 
25   * @author srt
26   * @version $Id: DatabaseGetCommand.java,v 1.2 2005/03/08 16:48:34 srt Exp $
27   */
28  public class DatabaseGetCommand extends AGICommand
29  {
30      /***
31       * Serial version identifier.
32       */
33      private static final long serialVersionUID = 3256719598056387384L;
34  
35      /***
36       * The family of the key to retrieve.
37       */
38      private String family;
39  
40      /***
41       * The key to retrieve.
42       */
43      private String key;
44  
45      /***
46       * Creates a new DatabaseGetCommand.
47       * 
48       * @param family the family of the key to retrieve.
49       * @param key the key to retrieve.
50       */
51      public DatabaseGetCommand(String family, String key)
52      {
53          this.family = family;
54          this.key = key;
55      }
56  
57      /***
58       * Returns the family of the key to retrieve.
59       * 
60       * @return the family of the key to retrieve.
61       */
62      public String getFamily()
63      {
64          return family;
65      }
66  
67      /***
68       * Sets the family of the key to retrieve.
69       * 
70       * @param family the family of the key to retrieve.
71       */
72      public void setFamily(String family)
73      {
74          this.family = family;
75      }
76  
77      /***
78       * Returns the the key to retrieve.
79       * 
80       * @return the key to retrieve.
81       */
82      public String getKey()
83      {
84          return key;
85      }
86  
87      /***
88       * Sets the key to retrieve.
89       * 
90       * @param key the key to retrieve.
91       */
92      public void setKey(String key)
93      {
94          this.key = key;
95      }
96  
97      public String buildCommand()
98      {
99          return "DATABASE GET " + escapeAndQuote(family) + " "
100                 + escapeAndQuote(key);
101     }
102 }