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 number 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   * Say a given number, returning early if any of the given DTMF number are
21   * received on the channel.<br>
22   * Returns 0 if playback completes without a digit being pressed, or the ASCII
23   * numerical value of the digit if one was pressed or -1 on error/hangup.
24   * 
25   * @author srt
26   * @version $Id: SayNumberCommand.java,v 1.3 2005/03/11 19:01:02 srt Exp $
27   */
28  public class SayNumberCommand extends AGICommand
29  {
30      /***
31       * Serial version identifier.
32       */
33      private static final long serialVersionUID = 3833744404153644087L;
34  
35      /***
36       * The number to say.
37       */
38      private String number;
39  
40      /***
41       * When one of these number is pressed while streaming the command returns.
42       */
43      private String escapeDigits;
44  
45      /***
46       * Creates a new SayNumberCommand.
47       * 
48       * @param number the number to say.
49       */
50      public SayNumberCommand(String number)
51      {
52          this.number = number;
53          this.escapeDigits = null;
54      }
55  
56      /***
57       * Creates a new SayNumberCommand.
58       * 
59       * @param number the number to say.
60       * @param escapeDigits contains the number that allow the user to
61       *            interrupt this command.
62       */
63      public SayNumberCommand(String number, String escapeDigits)
64      {
65          this.number = number;
66          this.escapeDigits = escapeDigits;
67      }
68  
69      /***
70       * Returns the number to say.
71       * 
72       * @return the number to say.
73       */
74      public String getNumber()
75      {
76          return number;
77      }
78  
79      /***
80       * Sets the number to say.
81       * 
82       * @param number the number to say.
83       */
84      public void setNumber(String number)
85      {
86          this.number = number;
87      }
88  
89      /***
90       * Returns the number that allow the user to interrupt this command.
91       * 
92       * @return the number that allow the user to interrupt this command.
93       */
94      public String getEscapeDigits()
95      {
96          return escapeDigits;
97      }
98  
99      /***
100      * Sets the number that allow the user to interrupt this command.
101      * 
102      * @param escapeDigits the number that allow the user to interrupt this
103      *            command or <code>null</code> for none.
104      */
105     public void setEscapeDigits(String escapeDigits)
106     {
107         this.escapeDigits = escapeDigits;
108     }
109 
110     public String buildCommand()
111     {
112         return "SAY NUMBER " + escapeAndQuote(number) + " "
113                 + escapeAndQuote(escapeDigits);
114     }
115 }