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 public class DefaultIdleStateEvent implements IdleStateEvent {
31
32 private final Channel channel;
33 private final IdleState state;
34 private final long lastActivityTimeMillis;
35
36
37
38
39 public DefaultIdleStateEvent(
40 Channel channel, IdleState state, long lastActivityTimeMillis) {
41 if (channel == null) {
42 throw new NullPointerException("channel");
43 }
44 if (state == null) {
45 throw new NullPointerException("state");
46 }
47 this.channel = channel;
48 this.state = state;
49 this.lastActivityTimeMillis = lastActivityTimeMillis;
50 }
51
52 public Channel getChannel() {
53 return channel;
54 }
55
56 public ChannelFuture getFuture() {
57 return succeededFuture(getChannel());
58 }
59
60 public IdleState getState() {
61 return state;
62 }
63
64 public long getLastActivityTimeMillis() {
65 return lastActivityTimeMillis;
66 }
67
68 @Override
69 public String toString() {
70 return getChannel().toString() + ' ' + getState() + " since " +
71 DateFormat.getDateTimeInstance(
72 DateFormat.SHORT, DateFormat.SHORT, Locale.US).format(
73 new Date(getLastActivityTimeMillis()));
74 }
75 }