1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.netty.handler.timeout;
17
18 import static org.jboss.netty.channel.Channels.*;
19
20 import java.text.DateFormat;
21 import java.util.Date;
22 import java.util.Locale;
23
24 import org.jboss.netty.channel.Channel;
25 import org.jboss.netty.channel.ChannelFuture;
26
27
28
29
30
31
32
33
34 public class DefaultIdleStateEvent implements IdleStateEvent {
35
36 private final Channel channel;
37 private final IdleState state;
38 private final long lastActivityTimeMillis;
39
40
41
42
43 public DefaultIdleStateEvent(
44 Channel channel, IdleState state, long lastActivityTimeMillis) {
45 if (channel == null) {
46 throw new NullPointerException("channel");
47 }
48 if (state == null) {
49 throw new NullPointerException("state");
50 }
51 this.channel = channel;
52 this.state = state;
53 this.lastActivityTimeMillis = lastActivityTimeMillis;
54 }
55
56 public Channel getChannel() {
57 return channel;
58 }
59
60 public ChannelFuture getFuture() {
61 return succeededFuture(getChannel());
62 }
63
64 public IdleState getState() {
65 return state;
66 }
67
68 public long getLastActivityTimeMillis() {
69 return lastActivityTimeMillis;
70 }
71
72 @Override
73 public String toString() {
74 return getChannel().toString() + ' ' + getState() + " since " +
75 DateFormat.getDateTimeInstance(
76 DateFormat.SHORT, DateFormat.SHORT, Locale.US).format(
77 new Date(getLastActivityTimeMillis()));
78 }
79 }