View Javadoc

1   /*
2    * Copyright 2012 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the 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>
33   * <td>{@code true}</td><td>The channel is open.</td>
34   * </tr>
35   * <tr>
36   * <td>Upstream</td><td>{@link #OPEN}</td>
37   * <td>{@code false}</td><td>The channel is closed.</td>
38   * </tr>
39   * <tr>
40   * <td>Upstream</td><td>{@link #BOUND}</td>
41   * <td>{@link SocketAddress}</td><td>The channel is bound to a local address.</td>
42   * </tr>
43   * <tr>
44   * <td>Upstream</td><td>{@link #BOUND}</td>
45   * <td>{@code null}</td><td>The channel is unbound to a local address.</td>
46   * </tr>
47   * <tr>
48   * <td>Upstream</td><td>{@link #CONNECTED}</td>
49   * <td>{@link SocketAddress}</td><td>The channel is connected to a remote address.</td>
50   * </tr>
51   * <tr>
52   * <td>Upstream</td><td>{@link #CONNECTED}</td>
53   * <td>{@code null}</td><td>The channel is disconnected from a remote address.</td>
54   * </tr>
55   * <tr>
56   * <td>Upstream</td><td>{@link #INTEREST_OPS}</td>
57   * <td>an integer</td><td>The channel interestOps has been changed.</td>
58   * </tr>
59   * <tr>
60   * <td>Downstream</td><td>{@link #OPEN}</td>
61   * <td>{@code true}</td><td>N/A</td>
62   * </tr>
63   * <tr>
64   * <td>Downstream</td><td>{@link #OPEN}</td>
65   * <td>{@code false}</td><td>Close the channel.</td>
66   * </tr>
67   * <tr>
68   * <td>Downstream</td><td>{@link #BOUND}</td>
69   * <td>{@link SocketAddress}</td><td>Bind the channel to the specified local address.</td>
70   * </tr>
71   * <tr>
72   * <td>Downstream</td><td>{@link #BOUND}</td>
73   * <td>{@code null}</td><td>Unbind the channel from the current local address.</td>
74   * </tr>
75   * <tr>
76   * <td>Downstream</td><td>{@link #CONNECTED}</td>
77   * <td>{@link SocketAddress}</td><td>Connect the channel to the specified remote address.</td>
78   * </tr>
79   * <tr>
80   * <td>Downstream</td><td>{@link #CONNECTED}</td>
81   * <td>{@code null}</td><td>Disconnect the channel from the current remote address.</td>
82   * </tr>
83   * <tr>
84   * <td>Downstream</td><td>{@link #INTEREST_OPS}</td>
85   * <td>an integer</td><td>Change the interestOps of the channel.</td>
86   * </tr>
87   * </table>
88   * <p>
89   * To see how an event is interpreted further, please refer to {@link ChannelEvent}.
90   */
91  public enum ChannelState {
92      /**
93       * Represents a {@link Channel}'s {@link Channel#isOpen() open} property
94       */
95      OPEN,
96  
97      /**
98       * Represents a {@link Channel}'s {@link Channel#isBound() bound} property
99       */
100     BOUND,
101 
102     /**
103      * Represents a {@link Channel}'s {@link Channel#isConnected() connected}
104      * property
105      */
106     CONNECTED,
107 
108     /**
109      * Represents a {@link Channel}'s {@link Channel#getInterestOps() interestOps}
110      * property
111      */
112     INTEREST_OPS
113 }