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   * Returns the status of the specified channel. If no channel name is given the
21   * returns the status of the current channel.<br>
22   * Return values:
23   * <ul>
24   * <li>0 Channel is down and available
25   * <li>1 Channel is down, but reserved
26   * <li>2 Channel is off hook
27   * <li>3 Digits (or equivalent) have been dialed
28   * <li>4 Line is ringing
29   * <li>5 Remote end is ringing
30   * <li>6 Line is up
31   * <li>7 Line is busy
32   * </ul>
33   * 
34   * @author srt
35   * @version $Id: ChannelStatusCommand.java,v 1.2 2005/03/08 16:48:34 srt Exp $
36   */
37  public class ChannelStatusCommand extends AGICommand
38  {
39      /***
40       * Serial version identifier.
41       */
42      private static final long serialVersionUID = 3904959746380281145L;
43  
44      /***
45       * The name of the channel to query or <code>null</code> for the current
46       * channel.
47       */
48      private String channel;
49  
50      /***
51       * Creates a new ChannelStatusCommand that queries the current channel.
52       */
53      public ChannelStatusCommand()
54      {
55          this.channel = null;
56      }
57  
58      /***
59       * Creates a new ChannelStatusCommand that queries the given channel.
60       * 
61       * @param channel the name of the channel to query.
62       */
63      public ChannelStatusCommand(String channel)
64      {
65          this.channel = channel;
66      }
67  
68      /***
69       * Returns the name of the channel to query.
70       * 
71       * @return the name of the channel to query or <code>null</code> for the
72       *         current channel.
73       */
74      public String getChannel()
75      {
76          return channel;
77      }
78  
79      /***
80       * Sets the name of the channel to query.
81       * 
82       * @param channel the name of the channel to query or <code>null</code>
83       *            for the current channel.
84       */
85      public void setChannel(String channel)
86      {
87          this.channel = channel;
88      }
89  
90      public String buildCommand()
91      {
92          return "CHANNEL STATUS"
93                  + (channel == null ? "" : " " + escapeAndQuote(channel));
94      }
95  }