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   * Adds or updates an entry in the Asterisk database for a given family, key,
21   * and value.<br>
22   * Returns 1 if successful, 0 otherwise.
23   * 
24   * @author srt
25   * @version $Id: DatabasePutCommand.java,v 1.2 2005/03/08 16:48:34 srt Exp $
26   */
27  public class DatabasePutCommand extends AGICommand
28  {
29      /***
30       * Serial version identifier.
31       */
32      private static final long serialVersionUID = 3256719598056387384L;
33  
34      /***
35       * The family of the key to set.
36       */
37      private String family;
38  
39      /***
40       * The key to set.
41       */
42      private String key;
43  
44      /***
45       * The value to set.
46       */
47      private String value;
48  
49      /***
50       * Creates a new DatabasePutCommand.
51       * 
52       * @param family the family of the key to set.
53       * @param key the key to set.
54       * @param value the value to set.
55       */
56      public DatabasePutCommand(String family, String key, String value)
57      {
58          this.family = family;
59          this.key = key;
60          this.value = value;
61      }
62  
63      /***
64       * Returns the family of the key to set.
65       * 
66       * @return the family of the key to set.
67       */
68      public String getFamily()
69      {
70          return family;
71      }
72  
73      /***
74       * Sets the family of the key to set.
75       * 
76       * @param family the family of the key to set.
77       */
78      public void setFamily(String family)
79      {
80          this.family = family;
81      }
82  
83      /***
84       * Returns the the key to set.
85       * 
86       * @return the key to set.
87       */
88      public String getKey()
89      {
90          return key;
91      }
92  
93      /***
94       * Sets the key to set.
95       * 
96       * @param key the key to set.
97       */
98      public void setKey(String key)
99      {
100         this.key = key;
101     }
102 
103     /***
104      * Returns the value to set.
105      * 
106      * @return the value to set.
107      */
108     public String getValue()
109     {
110         return value;
111     }
112 
113     /***
114      * Sets the value to set.
115      * 
116      * @param value the value to set.
117      */
118     public void setValue(String value)
119     {
120         this.value = value;
121     }
122 
123     public String buildCommand()
124     {
125         return "DATABASE PUT " + escapeAndQuote(family) + " "
126                 + escapeAndQuote(key) + " " + escapeAndQuote(value);
127     }
128 }