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.manager;
18  
19  import java.io.Serializable;
20  import java.util.HashMap;
21  import java.util.Map;
22  
23  /***
24   * Enumeration that represents the state of a channel.
25   * 
26   * @author srt
27   * @version $Id: ChannelStateEnum.java,v 1.3 2005/03/13 11:26:48 srt Exp $
28   */
29  public class ChannelStateEnum implements Serializable
30  {
31      /***
32       * Serializable version identifier
33       */
34      private static final long serialVersionUID = 6436381500165485011L;
35  
36      private static Map literals = new HashMap();
37  
38      private String state;
39  
40      public static final ChannelStateEnum DOWN = new ChannelStateEnum("Down");
41      public static final ChannelStateEnum OFF_HOOK = new ChannelStateEnum("OffHook");
42      public static final ChannelStateEnum DIALING = new ChannelStateEnum("Dialing");
43      public static final ChannelStateEnum RING = new ChannelStateEnum("Ring");
44      public static final ChannelStateEnum RINGING = new ChannelStateEnum("Ringing");
45      public static final ChannelStateEnum UP = new ChannelStateEnum("Up");
46      public static final ChannelStateEnum BUSY = new ChannelStateEnum("Busy");
47      public static final ChannelStateEnum RSRVD = new ChannelStateEnum("Rsrvd");
48      public static final ChannelStateEnum HUNGUP = new ChannelStateEnum("Hungup");
49  
50      private ChannelStateEnum(String state)
51      {
52          this.state = state;
53          literals.put(state, this);
54      }
55  
56      public static ChannelStateEnum getEnum(String state)
57      {
58          return (ChannelStateEnum) literals.get(state);
59      }
60  
61      public String toString()
62      {
63          return state;
64      }
65  }