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