You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2013/05/17 19:02:35 UTC

svn commit: r1483915 - in /commons/proper/io/trunk/src: changes/changes.xml main/java/org/apache/commons/io/IOCase.java

Author: sebb
Date: Fri May 17 17:02:35 2013
New Revision: 1483915

URL: http://svn.apache.org/r1483915
Log:
IO-239 Convert IOCase to a Java 1.5+ Enumeration

Modified:
    commons/proper/io/trunk/src/changes/changes.xml
    commons/proper/io/trunk/src/main/java/org/apache/commons/io/IOCase.java

Modified: commons/proper/io/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/changes/changes.xml?rev=1483915&r1=1483914&r2=1483915&view=diff
==============================================================================
--- commons/proper/io/trunk/src/changes/changes.xml (original)
+++ commons/proper/io/trunk/src/changes/changes.xml Fri May 17 17:02:35 2013
@@ -47,6 +47,10 @@ The <action> type attribute can be add,u
   <body>
     <!-- The release date is the date RC is cut -->
     <release version="2.5" date="2013-??-??" description="New features and bug fixes.">    
+      <action issue="IO-239" dev="sebb" type="update">
+         Convert IOCase to a Java 1.5+ Enumeration
+         [N.B. this is binary compatible]
+      </action>
       <action issue="IO-233" dev="sebb" type="add">
          Add Methods for Buffering Streams/Writers To IOUtils
          Added overloaded buffer() methods - see also IO-330

Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/IOCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/IOCase.java?rev=1483915&r1=1483914&r2=1483915&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/IOCase.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/IOCase.java Fri May 17 17:02:35 2013
@@ -34,17 +34,17 @@ import java.io.Serializable;
  * @version $Id$
  * @since 1.3
  */
-public final class IOCase implements Serializable {
+public enum IOCase implements Serializable {
 
     /**
      * The constant for case sensitive regardless of operating system.
      */
-    public static final IOCase SENSITIVE = new IOCase("Sensitive", true);
+    SENSITIVE ("Sensitive", true),
 
     /**
      * The constant for case insensitive regardless of operating system.
      */
-    public static final IOCase INSENSITIVE = new IOCase("Insensitive", false);
+    INSENSITIVE ("Insensitive", false),
 
     /**
      * The constant for case sensitivity determined by the current operating system.
@@ -58,7 +58,7 @@ public final class IOCase implements Ser
      * If you derialize this constant of Windows, and deserialize on Unix, or vice
      * versa, then the value of the case-sensitivity flag will change.
      */
-    public static final IOCase SYSTEM = new IOCase("System", !FilenameUtils.isSystemWindows());
+    SYSTEM ("System", !FilenameUtils.isSystemWindows());
 
     /** Serialization version. */
     private static final long serialVersionUID = -6343169151696340687L;
@@ -78,14 +78,12 @@ public final class IOCase implements Ser
      * @throws IllegalArgumentException if the name is invalid
      */
     public static IOCase forName(final String name) {
-        if (IOCase.SENSITIVE.name.equals(name)){
-            return IOCase.SENSITIVE;
-        }
-        if (IOCase.INSENSITIVE.name.equals(name)){
-            return IOCase.INSENSITIVE;
-        }
-        if (IOCase.SYSTEM.name.equals(name)){
-            return IOCase.SYSTEM;
+        for (IOCase ioCase : IOCase.values())
+        {
+            if (ioCase.getName().equals(name))
+            {
+                return ioCase;
+            }
         }
         throw new IllegalArgumentException("Invalid IOCase name: " + name);
     }