1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.netty.channel;
17
18
19
20
21
22
23
24
25
26
27 public class DownstreamChannelStateEvent implements ChannelStateEvent {
28
29 private final Channel channel;
30 private final ChannelFuture future;
31 private final ChannelState state;
32 private final Object value;
33
34
35
36
37 public DownstreamChannelStateEvent(
38 Channel channel, ChannelFuture future,
39 ChannelState state, Object value) {
40
41 if (channel == null) {
42 throw new NullPointerException("channel");
43 }
44 if (future == null) {
45 throw new NullPointerException("future");
46 }
47 if (state == null) {
48 throw new NullPointerException("state");
49 }
50 this.channel = channel;
51 this.future = future;
52 this.state = state;
53 this.value = value;
54 }
55
56 public Channel getChannel() {
57 return channel;
58 }
59
60 public ChannelFuture getFuture() {
61 return future;
62 }
63
64 public ChannelState getState() {
65 return state;
66 }
67
68 public Object getValue() {
69 return value;
70 }
71
72 @Override
73 public String toString() {
74 String channelString = getChannel().toString();
75 StringBuilder buf = new StringBuilder(channelString.length() + 64);
76 buf.append(channelString);
77 switch (getState()) {
78 case OPEN:
79 if (Boolean.TRUE.equals(getValue())) {
80 buf.append(" OPEN");
81 } else {
82 buf.append(" CLOSE");
83 }
84 break;
85 case BOUND:
86 if (getValue() != null) {
87 buf.append(" BIND: ");
88 buf.append(getValue());
89 } else {
90 buf.append(" UNBIND");
91 }
92 break;
93 case CONNECTED:
94 if (getValue() != null) {
95 buf.append(" CONNECT: ");
96 buf.append(getValue());
97 } else {
98 buf.append(" DISCONNECT");
99 }
100 break;
101 case INTEREST_OPS:
102 buf.append(" CHANGE_INTEREST: ");
103 buf.append(getValue());
104 break;
105 default:
106 buf.append(' ');
107 buf.append(getState().name());
108 buf.append(": ");
109 buf.append(getValue());
110 }
111 return buf.toString();
112 }
113 }