1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 }