You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by jv...@apache.org on 2009/10/20 15:22:24 UTC

svn commit: r827432 - /mina/branches/3.0/core/src/main/java/org/apache/mina/IdleStatus.java

Author: jvermillard
Date: Tue Oct 20 13:22:24 2009
New Revision: 827432

URL: http://svn.apache.org/viewvc?rev=827432&view=rev
Log:
transformed IdleStatus to enum (thanks Kiran Ayyagari)

Modified:
    mina/branches/3.0/core/src/main/java/org/apache/mina/IdleStatus.java

Modified: mina/branches/3.0/core/src/main/java/org/apache/mina/IdleStatus.java
URL: http://svn.apache.org/viewvc/mina/branches/3.0/core/src/main/java/org/apache/mina/IdleStatus.java?rev=827432&r1=827431&r2=827432&view=diff
==============================================================================
--- mina/branches/3.0/core/src/main/java/org/apache/mina/IdleStatus.java (original)
+++ mina/branches/3.0/core/src/main/java/org/apache/mina/IdleStatus.java Tue Oct 20 13:22:24 2009
@@ -19,57 +19,39 @@
  */
 package org.apache.mina;
 
+import java.security.InvalidParameterException;
+
 
 /**
- * Represents the type of idleness of {@link IoSession} or
- * {@link IoSession}.  There are three types of idleness:
+ * Represents the type of idleness of {@link IoSession}. 
+ *  There are three types of idleness:
  * <ul>
- *   <li>{@link #READER_IDLE} - No data is coming from the remote peer.</li>
- *   <li>{@link #WRITER_IDLE} - Session is not writing any data.</li>
- *   <li>{@link #BOTH_IDLE} - Both {@link #READER_IDLE} and {@link #WRITER_IDLE}.</li>
+ *   <li>{@link #READ_IDLE} - No data is coming from the remote peer.</li>
+ *   <li>{@link #WRITE_IDLE} - Session is not writing any data.</li>
+ *   <li>{@link #READ_WRITE_IDLE} - Both {@link #READ_IDLE} and {@link #WRITE_IDLE}.</li>
  * </ul>
  * <p>
- * Idle time settings are all disabled by default.  You can enable them
- * using {@link IoSessionConfig#setIdleTime(IdleStatus,int)}.
- *
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class IdleStatus {
-    /**
-     * Represents the session status that no data is coming from the remote
-     * peer.
-     */
-    public static final IdleStatus READER_IDLE = new IdleStatus("reader idle");
-
-    /**
-     * Represents the session status that the session is not writing any data.
-     */
-    public static final IdleStatus WRITER_IDLE = new IdleStatus("writer idle");
-
-    /**
-     * Represents both {@link #READER_IDLE} and {@link #WRITER_IDLE}.
-     */
-    public static final IdleStatus BOTH_IDLE = new IdleStatus("both idle");
-
-    private final String strValue;
-
-    /**
-     * Creates a new instance.
-     */
-    private IdleStatus(String strValue) {
-        this.strValue = strValue;
-    }
+public enum IdleStatus {
+    READ_IDLE,
+    WRITE_IDLE,
+    READ_WRITE_IDLE;
 
     /**
      * Returns the string representation of this status.
-     * <ul>
-     *   <li>{@link #READER_IDLE} - <tt>"reader idle"</tt></li>
-     *   <li>{@link #WRITER_IDLE} - <tt>"writer idle"</tt></li>
-     *   <li>{@link #BOTH_IDLE} - <tt>"both idle"</tt></li>
-     * </ul>
      */
     @Override
     public String toString() {
-        return strValue;
+        switch (this) {
+        case READ_IDLE:
+            return "read idle";
+        case WRITE_IDLE:
+            return "write idle";
+        case READ_WRITE_IDLE:
+            return "both idle";
+        default:
+            throw new InvalidParameterException("unknown IdleStatus");
+        }
     }
 }
\ No newline at end of file