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  import net.sf.asterisk.manager.event.DBGetResponseEvent;
20  
21  /***
22   * Retrieves an entry in the Asterisk database for a given family and key.<br>
23   * If an entry is found a DBGetResponseEvent is sent by Asterisk containing the
24   * value, otherwise a ManagerError indicates that no entry matches.<br>
25   * Available since Asterisk 1.2
26   * 
27   * @see net.sf.asterisk.manager.event.DBGetResponseEvent
28   * @author srt
29   * @version $Id: DBGetAction.java,v 1.4 2005/08/07 00:09:42 srt Exp $
30   * @since 0.2
31   */
32  public class DBGetAction extends AbstractManagerAction
33          implements
34              EventGeneratingAction
35  {
36      /***
37       * Serial version identifier
38       */
39      private static final long serialVersionUID = 921037572305993779L;
40      private String family;
41      private String key;
42  
43      /***
44       * Creates a new empty DBGetAction.
45       */
46      public DBGetAction()
47      {
48  
49      }
50  
51      /***
52       * Creates a new DBGetAction that retrieves the value of the database entry
53       * with the given key in the given family.
54       * 
55       * @param family the family of the key
56       * @param key the key of the entry to retrieve
57       * @since 0.2
58       */
59      public DBGetAction(String family, String key)
60      {
61          this.family = family;
62          this.key = key;
63      }
64  
65      public String getAction()
66      {
67          return "DBGet";
68      }
69  
70      /***
71       * Returns the family of the key.
72       * 
73       * @return the family of the key.
74       */
75      public String getFamily()
76      {
77          return family;
78      }
79  
80      /***
81       * Sets the family of the key.
82       * 
83       * @param family the family of the key.
84       */
85      public void setFamily(String family)
86      {
87          this.family = family;
88      }
89  
90      /***
91       * Returns the the key of the entry to retrieve.
92       * 
93       * @return the key of the entry to retrieve.
94       */
95      public String getKey()
96      {
97          return key;
98      }
99  
100     /***
101      * Sets the key of the entry to retrieve.
102      * 
103      * @param key the key of the entry to retrieve.
104      */
105     public void setKey(String key)
106     {
107         this.key = key;
108     }
109 
110     public Class getActionCompleteEventClass()
111     {
112         return DBGetResponseEvent.class;
113     }
114 }