1 | /* |
2 | * @(#) $Id: IdleStatus.java 332218 2005-11-10 03:52:42Z trustin $ |
3 | * |
4 | * Copyright 2004 The Apache Software Foundation |
5 | * |
6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
7 | * you may not use this file except in compliance with the License. |
8 | * You may obtain a copy of the License at |
9 | * |
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
11 | * |
12 | * Unless required by applicable law or agreed to in writing, software |
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | * See the License for the specific language governing permissions and |
16 | * limitations under the License. |
17 | * |
18 | */ |
19 | package org.apache.mina.common; |
20 | |
21 | import org.apache.mina.io.IoSession; |
22 | import org.apache.mina.protocol.ProtocolSession; |
23 | |
24 | /** |
25 | * Represents the type of idleness of {@link IoSession} or |
26 | * {@link ProtocolSession}. There are three types of idleness: |
27 | * <ul> |
28 | * <li>{@link #READER_IDLE} - No data is coming from the remote peer.</li> |
29 | * <li>{@link #WRITER_IDLE} - Session is not writing any data.</li> |
30 | * <li>{@link #BOTH_IDLE} - Both {@link #READER_IDLE} and {@link #WRITER_IDLE}.</li> |
31 | * </ul> |
32 | * <p> |
33 | * Idle time settings are all disabled by default. You can enable them |
34 | * using {@link SessionConfig#setIdleTime(IdleStatus,int)}. |
35 | * |
36 | * @author The Apache Directory Project (dev@directory.apache.org) |
37 | * @version $Rev: 332218 $, $Date: 2005-11-10 12:52:42 +0900 $ |
38 | */ |
39 | public class IdleStatus |
40 | { |
41 | /** |
42 | * Represents the session status that no data is coming from the remote |
43 | * peer. |
44 | */ |
45 | public static final IdleStatus READER_IDLE = new IdleStatus( "reader idle" ); |
46 | |
47 | /** |
48 | * Represents the session status that the session is not writing any data. |
49 | */ |
50 | public static final IdleStatus WRITER_IDLE = new IdleStatus( "writer idle" ); |
51 | |
52 | /** |
53 | * Represents both {@link #READER_IDLE} and {@link #WRITER_IDLE}. |
54 | */ |
55 | public static final IdleStatus BOTH_IDLE = new IdleStatus( "both idle" ); |
56 | |
57 | private final String strValue; |
58 | |
59 | /** |
60 | * Creates a new instance. |
61 | */ |
62 | private IdleStatus( String strValue ) |
63 | { |
64 | this.strValue = strValue; |
65 | } |
66 | |
67 | /** |
68 | * Returns the string representation of this status. |
69 | * <ul> |
70 | * <li>{@link #READER_IDLE} - <tt>"reader idle"</tt></li> |
71 | * <li>{@link #WRITER_IDLE} - <tt>"writer idle"</tt></li> |
72 | * <li>{@link #BOTH_IDLE} - <tt>"both idle"</tt></li> |
73 | * </ul> |
74 | */ |
75 | public String toString() |
76 | { |
77 | return strValue; |
78 | } |
79 | } |