View Javadoc

1   /*
2    * Copyright 2009 Red Hat, Inc.
3    *
4    * Red Hat licenses this file to you under the Apache License, version 2.0
5    * (the "License"); you may not use this file except in compliance with the
6    * License.  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, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package org.jboss.netty.channel;
17  
18  import java.net.SocketAddress;
19  
20  /**
21   * The current or future state of a {@link Channel}.
22   * <p>
23   * The state of a {@link Channel} is interpreted differently depending on the
24   * {@linkplain ChannelStateEvent#getValue() value} of a {@link ChannelStateEvent}
25   * and the direction of the event in a {@link ChannelPipeline}:
26   *
27   * <table border="1" cellspacing="0" cellpadding="6">
28   * <tr>
29   * <th>Direction</th><th>State</th><th>Value</th><th>Meaning</th>
30   * </tr>
31   * <tr>
32   * <td>Upstream</td><td>{@link #OPEN}</td><td>{@code true}</td><td>The channel is open.</td>
33   * </tr>
34   * <tr>
35   * <td>Upstream</td><td>{@link #OPEN}</td><td>{@code false}</td><td>The channel is closed.</td>
36   * </tr>
37   * <tr>
38   * <td>Upstream</td><td>{@link #BOUND}</td><td>{@link SocketAddress}</td><td>The channel is bound to a local address.</td>
39   * </tr>
40   * <tr>
41   * <td>Upstream</td><td>{@link #BOUND}</td><td>{@code null}</td><td>The channel is unbound to a local address.</td>
42   * </tr>
43   * <tr>
44   * <td>Upstream</td><td>{@link #CONNECTED}</td><td>{@link SocketAddress}</td><td>The channel is connected to a remote address.</td>
45   * </tr>
46   * <tr>
47   * <td>Upstream</td><td>{@link #CONNECTED}</td><td>{@code null}</td><td>The channel is disconnected from a remote address.</td>
48   * </tr>
49   * <tr>
50   * <td>Upstream</td><td>{@link #INTEREST_OPS}</td><td>an integer</td><td>The channel interestOps has been changed.</td>
51   * </tr>
52   * <tr>
53   * <td>Downstream</td><td>{@link #OPEN}</td><td>{@code true}</td><td>N/A</td>
54   * </tr>
55   * <tr>
56   * <td>Downstream</td><td>{@link #OPEN}</td><td>{@code false}</td><td>Close the channel.</td>
57   * </tr>
58   * <tr>
59   * <td>Downstream</td><td>{@link #BOUND}</td><td>{@link SocketAddress}</td><td>Bind the channel to the specified local address.</td>
60   * </tr>
61   * <tr>
62   * <td>Downstream</td><td>{@link #BOUND}</td><td>{@code null}</td><td>Unbind the channel from the current local address.</td>
63   * </tr>
64   * <tr>
65   * <td>Downstream</td><td>{@link #CONNECTED}</td><td>{@link SocketAddress}</td><td>Connect the channel to the specified remote address.</td>
66   * </tr>
67   * <tr>
68   * <td>Downstream</td><td>{@link #CONNECTED}</td><td>{@code null}</td><td>Disconnect the channel from the current remote address.</td>
69   * </tr>
70   * <tr>
71   * <td>Downstream</td><td>{@link #INTEREST_OPS}</td><td>an integer</td><td>Change the interestOps of the channel.</td>
72   * </tr>
73   * </table>
74   * <p>
75   * To see how an event is interpreted further, please refer to {@link ChannelEvent}.
76   *
77   * @author <a href="http://www.jboss.org/netty/">The Netty Project</a>
78   * @author <a href="http://gleamynode.net/">Trustin Lee</a>
79   *
80   * @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
81   */
82  public enum ChannelState {
83      /**
84       * Represents a {@link Channel}'s {@link Channel#isOpen() open} property
85       */
86      OPEN,
87  
88      /**
89       * Represents a {@link Channel}'s {@link Channel#isBound() bound} property
90       */
91      BOUND,
92  
93      /**
94       * Represents a {@link Channel}'s {@link Channel#isConnected() connected}
95       * property
96       */
97      CONNECTED,
98  
99      /**
100      * Represents a {@link Channel}'s {@link Channel#getInterestOps() interestOps}
101      * property
102      */
103     INTEREST_OPS;
104 }