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   * Deletes a family or specific keytree within a family in the Asterisk
21   * database.<br>
22   * Returns 1 if successful, 0 otherwise.
23   * 
24   * @author srt
25   * @version $Id: DatabaseDelCommand.java,v 1.2 2005/03/08 16:48:34 srt Exp $
26   */
27  public class DatabaseDelCommand extends AGICommand
28  {
29      /***
30       * Serial version identifier.
31       */
32      private static final long serialVersionUID = 3256719598056387384L;
33  
34      /***
35       * The family (or family of the keytree) to delete.
36       */
37      private String family;
38  
39      /***
40       * The keyTree to delete.
41       */
42      private String keyTree;
43  
44      /***
45       * Creates a new DatabaseDelCommand to delete a family.
46       * 
47       * @param family the family to delete.
48       */
49      public DatabaseDelCommand(String family)
50      {
51          this.family = family;
52          this.keyTree = null;
53      }
54  
55      /***
56       * Creates a new DatabaseDelCommand to delete a keytree.
57       * 
58       * @param family the family of the keytree to delete.
59       * @param keyTree the keytree to delete.
60       */
61      public DatabaseDelCommand(String family, String keyTree)
62      {
63          this.family = family;
64          this.keyTree = keyTree;
65      }
66  
67      /***
68       * Returns the family (or family of the keytree) to delete.
69       * 
70       * @return the family (or family of the keytree) to delete.
71       */
72      public String getFamily()
73      {
74          return family;
75      }
76  
77      /***
78       * Sets the family (or family of the keytree) to delete.
79       * 
80       * @param family the family (or family of the keytree) to delete.
81       */
82      public void setFamily(String family)
83      {
84          this.family = family;
85      }
86  
87      /***
88       * Returns the the keytree to delete.
89       * 
90       * @return the keytree to delete.
91       */
92      public String getKeyTree()
93      {
94          return keyTree;
95      }
96  
97      /***
98       * Sets the keytree to delete.
99       * 
100      * @param keyTree the keytree to delete.
101      */
102     public void setKeyTree(String keyTree)
103     {
104         this.keyTree = keyTree;
105     }
106 
107     public String buildCommand()
108     {
109         return "DATABASE DELTREE " + escapeAndQuote(family)
110                 + (keyTree == null ? "" : " " + escapeAndQuote(keyTree));
111     }
112 }