You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2006/10/18 09:41:48 UTC

svn commit: r465168 - /myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/jsfext/EnumConverter.java

Author: imario
Date: Wed Oct 18 00:41:45 2006
New Revision: 465168

URL: http://svn.apache.org/viewvc?view=rev&rev=465168
Log:
removed unused methods, added check for family

Modified:
    myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/jsfext/EnumConverter.java

Modified: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/jsfext/EnumConverter.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/jsfext/EnumConverter.java?view=diff&rev=465168&r1=465167&r2=465168
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/jsfext/EnumConverter.java (original)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/jsfext/EnumConverter.java Wed Oct 18 00:41:45 2006
@@ -38,16 +38,16 @@
 		{
 			return null;
 		}
-		
+
 		int pos = value.indexOf('@');
 		if (pos < 0)
 		{
 			throw new IllegalArgumentException(value + " do not point to an enum");
 		}
-		
+
 		String clazz = value.substring(0, pos);
 		int ordinal = Integer.parseInt(value.substring(pos+1), 10);
-		
+
 		try
 		{
 			Enum e = ordinalToEnum(Class.forName(clazz), ordinal);
@@ -60,7 +60,7 @@
 		{
 			throw new RuntimeException(e1);
 		}
-		
+
 		throw new IllegalArgumentException("ordinal " + ordinal + " not found in enum " + clazz);
 	}
 
@@ -72,31 +72,15 @@
 		}
 
 		Enum e = (Enum) value;
-		
-		if (component instanceof UIInput)
+
+		if (component instanceof UIInput || UIInput.COMPONENT_FAMILY.equals(component.getFamily()))
 		{
 			return e.getClass().getName() + "@" + Integer.toString(e.ordinal(), 10);
 		}
-		
-		return e.name();
-	}
 
-	@SuppressWarnings("unchecked")
-	protected Enum stringToEnum(Class type, String string)
-	{
-		EnumSet es = EnumSet.allOf(type);
-        for (Object e1 : es)
-        {
-            Enum e = (Enum) e1;
-            if (string.equals(e.name()))
-            {
-                return e;
-            }
-        }
-
-        return null;
+		return e.toString();
 	}
-	
+
 	@SuppressWarnings("unchecked")
 	protected Enum ordinalToEnum(Class type, int ordinal)
 	{
@@ -111,23 +95,5 @@
         }
 
         return null;
-	}
-	
-	public String fixString(Class type, String string)
-	{
-		Enum e = stringToEnum(type, string);
-		if (e == null)
-		{
-			throw new IllegalArgumentException("cant find enum for string '" + string + "' type '" + type.getName() + "'");
-		}
-		
-		String prefix = type.getName() + "@";
-		
-		if (!string.startsWith(prefix))
-		{
-			return prefix + e.ordinal();
-		}
-		
-		return string;
 	}
 }