You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ge...@apache.org on 2009/01/09 22:03:22 UTC

svn commit: r733151 - /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java

Author: gerdogdu
Date: Fri Jan  9 13:03:22 2009
New Revision: 733151

URL: http://svn.apache.org/viewvc?rev=733151&view=rev
Log:
OWB-35 cut back overly exception handling in ClassUtil thanks Mark Struberg

Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java?rev=733151&r1=733150&r2=733151&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java Fri Jan  9 13:03:22 2009
@@ -539,8 +539,10 @@
         }
 
         if (i > 1)
+        {
             return true;
-
+        }
+        
         return false;
 
     }
@@ -914,51 +916,44 @@
      */
     public static Object isValueOkForPrimitiveOrWrapper(Class<?> type, String value)
     {
-        try
+        if (type.equals(Integer.TYPE) || type.equals(Integer.class))
         {
-            if (type.equals(Integer.TYPE) || type.equals(Integer.class))
-            {
-                return Integer.valueOf(value);
-            }
-
-            if (type.equals(Float.TYPE) || type.equals(Float.class))
-            {
-                return Float.valueOf(value);
-            }
+            return Integer.valueOf(value);
+        }
 
-            if (type.equals(Double.TYPE) || type.equals(Double.class))
-            {
-                return Double.valueOf(value);
-            }
+        if (type.equals(Float.TYPE) || type.equals(Float.class))
+        {
+            return Float.valueOf(value);
+        }
 
-            if (type.equals(Character.TYPE) || type.equals(Character.class))
-            {
-                return value.toCharArray()[0];
-            }
+        if (type.equals(Double.TYPE) || type.equals(Double.class))
+        {
+            return Double.valueOf(value);
+        }
 
-            if (type.equals(Long.TYPE) || type.equals(Long.class))
-            {
-                return Long.valueOf(value);
-            }
+        if (type.equals(Character.TYPE) || type.equals(Character.class))
+        {
+            return value.toCharArray()[0];
+        }
 
-            if (type.equals(Byte.TYPE) || type.equals(Byte.class))
-            {
-                return Byte.valueOf(value);
-            }
+        if (type.equals(Long.TYPE) || type.equals(Long.class))
+        {
+            return Long.valueOf(value);
+        }
 
-            if (type.equals(Short.TYPE) || type.equals(Short.class))
-            {
-                return Short.valueOf(value);
-            }
+        if (type.equals(Byte.TYPE) || type.equals(Byte.class))
+        {
+            return Byte.valueOf(value);
+        }
 
-            if (type.equals(Boolean.TYPE) || type.equals(Boolean.class))
-            {
-                return Boolean.valueOf(value);
-            }
+        if (type.equals(Short.TYPE) || type.equals(Short.class))
+        {
+            return Short.valueOf(value);
+        }
 
-        } catch (Throwable e)
+        if (type.equals(Boolean.TYPE) || type.equals(Boolean.class))
         {
-            return null;
+            return Boolean.valueOf(value);
         }
 
         return null;
@@ -969,15 +964,7 @@
         Asserts.nullCheckForClass(clazz);
         Asserts.assertNotNull(value, "value parameter can not be null");
 
-        try
-        {
-            return Enum.valueOf(clazz, value);
-
-        } catch (Throwable e)
-        {
-            return null;
-        }
-
+        return Enum.valueOf(clazz, value);
     }
 
     public static Date isValueOkForDate(String value) throws ParseException
@@ -1020,24 +1007,16 @@
         Asserts.assertNotNull(type);
         Asserts.assertNotNull(value);
 
-        try
+        if (type.equals(BigInteger.class))
         {
-            if (type.equals(BigInteger.class))
-            {
-                return new BigInteger(value);
-            } else if (type.equals(BigDecimal.class))
-            {
-                return new BigDecimal(value);
-            } else
-            {
-                return new WebBeansException(new IllegalArgumentException("Argument is not valid"));
-            }
-
-        } catch (NumberFormatException e)
+            return new BigInteger(value);
+        } else if (type.equals(BigDecimal.class))
         {
-            return null;
+            return new BigDecimal(value);
+        } else
+        {
+            return new WebBeansException(new IllegalArgumentException("Argument is not valid"));
         }
-
     }
 
     public static boolean isParametrized(Class<?> clazz)