001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.mina.core.session; 021 022/** 023 * Represents the type of idleness of {@link IoSession} or 024 * {@link IoSession}. There are three types of idleness: 025 * <ul> 026 * <li>{@link #READER_IDLE} - No data is coming from the remote peer.</li> 027 * <li>{@link #WRITER_IDLE} - Session is not writing any data.</li> 028 * <li>{@link #BOTH_IDLE} - Both {@link #READER_IDLE} and {@link #WRITER_IDLE}.</li> 029 * </ul> 030 * <p> 031 * Idle time settings are all disabled by default. You can enable them 032 * using {@link IoSessionConfig#setIdleTime(IdleStatus,int)}. 033 * 034 * @author <a href="http://mina.apache.org">Apache MINA Project</a> 035 */ 036public class IdleStatus { 037 /** 038 * Represents the session status that no data is coming from the remote 039 * peer. 040 */ 041 public static final IdleStatus READER_IDLE = new IdleStatus("reader idle"); 042 043 /** 044 * Represents the session status that the session is not writing any data. 045 */ 046 public static final IdleStatus WRITER_IDLE = new IdleStatus("writer idle"); 047 048 /** 049 * Represents both {@link #READER_IDLE} and {@link #WRITER_IDLE}. 050 */ 051 public static final IdleStatus BOTH_IDLE = new IdleStatus("both idle"); 052 053 private final String strValue; 054 055 /** 056 * Creates a new instance. 057 */ 058 private IdleStatus(String strValue) { 059 this.strValue = strValue; 060 } 061 062 /** 063 * @return the string representation of this status. 064 * <ul> 065 * <li>{@link #READER_IDLE} - <tt>"reader idle"</tt></li> 066 * <li>{@link #WRITER_IDLE} - <tt>"writer idle"</tt></li> 067 * <li>{@link #BOTH_IDLE} - <tt>"both idle"</tt></li> 068 * </ul> 069 */ 070 @Override 071 public String toString() { 072 return strValue; 073 } 074}