View Javadoc

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  /**
24   * Represents the type of idleness of {@link IoSession} or
25   * {@link IoSession}.  There are three types of idleness:
26   * <ul>
27   *   <li>{@link #READER_IDLE} - No data is coming from the remote peer.</li>
28   *   <li>{@link #WRITER_IDLE} - Session is not writing any data.</li>
29   *   <li>{@link #BOTH_IDLE} - Both {@link #READER_IDLE} and {@link #WRITER_IDLE}.</li>
30   * </ul>
31   * <p>
32   * Idle time settings are all disabled by default.  You can enable them
33   * using {@link IoSessionConfig#setIdleTime(IdleStatus,int)}.
34   *
35   * @author The Apache MINA Project (dev@mina.apache.org)
36   */
37  public class IdleStatus {
38      /**
39       * Represents the session status that no data is coming from the remote
40       * peer.
41       */
42      public static final IdleStatus READER_IDLE = new IdleStatus("reader idle");
43  
44      /**
45       * Represents the session status that the session is not writing any data.
46       */
47      public static final IdleStatus WRITER_IDLE = new IdleStatus("writer idle");
48  
49      /**
50       * Represents both {@link #READER_IDLE} and {@link #WRITER_IDLE}.
51       */
52      public static final IdleStatus BOTH_IDLE = new IdleStatus("both idle");
53  
54      private final String strValue;
55  
56      /**
57       * Creates a new instance.
58       */
59      private IdleStatus(String strValue) {
60          this.strValue = strValue;
61      }
62  
63      /**
64       * Returns the string representation of this status.
65       * <ul>
66       *   <li>{@link #READER_IDLE} - <tt>"reader idle"</tt></li>
67       *   <li>{@link #WRITER_IDLE} - <tt>"writer idle"</tt></li>
68       *   <li>{@link #BOTH_IDLE} - <tt>"both idle"</tt></li>
69       * </ul>
70       */
71      @Override
72      public String toString() {
73          return strValue;
74      }
75  }