1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. 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,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 *
19 */
20 package org.apache.mina.core.session;
21
22 /**
23 * Represents the type of idleness of {@link IoSession} or
24 * {@link IoSession}. There are three types of idleness:
25 * <ul>
26 * <li>{@link #READER_IDLE} - No data is coming from the remote peer.</li>
27 * <li>{@link #WRITER_IDLE} - Session is not writing any data.</li>
28 * <li>{@link #BOTH_IDLE} - Both {@link #READER_IDLE} and {@link #WRITER_IDLE}.</li>
29 * </ul>
30 * <p>
31 * Idle time settings are all disabled by default. You can enable them
32 * using {@link IoSessionConfig#setIdleTime(IdleStatus,int)}.
33 *
34 * @author <a href="http://mina.apache.org">Apache MINA Project</a>
35 */
36 public class IdleStatus {
37 /**
38 * Represents the session status that no data is coming from the remote
39 * peer.
40 */
41 public static final IdleStatus READER_IDLE = new IdleStatus("reader idle");
42
43 /**
44 * Represents the session status that the session is not writing any data.
45 */
46 public static final IdleStatus WRITER_IDLE = new IdleStatus("writer idle");
47
48 /**
49 * Represents both {@link #READER_IDLE} and {@link #WRITER_IDLE}.
50 */
51 public static final IdleStatus BOTH_IDLE = new IdleStatus("both idle");
52
53 private final String strValue;
54
55 /**
56 * Creates a new instance.
57 */
58 private IdleStatus(String strValue) {
59 this.strValue = strValue;
60 }
61
62 /**
63 * @return the string representation of this status.
64 * <ul>
65 * <li>{@link #READER_IDLE} - <tt>"reader idle"</tt></li>
66 * <li>{@link #WRITER_IDLE} - <tt>"writer idle"</tt></li>
67 * <li>{@link #BOTH_IDLE} - <tt>"both idle"</tt></li>
68 * </ul>
69 */
70 @Override
71 public String toString() {
72 return strValue;
73 }
74 }