camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bvah...@apache.org
Subject svn commit: r1431644 - in /camel/branches/camel-2.10.x: ./ camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
Date Thu, 10 Jan 2013 21:12:13 GMT
Author: bvahdat
Date: Thu Jan 10 21:12:13 2013
New Revision: 1431644

URL: http://svn.apache.org/viewvc?rev=1431644&view=rev
Log:
Merged revisions 1431642 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk

........
  r1431642 | bvahdat | 2013-01-10 22:09:55 +0100 (Do, 10 Jan 2013) | 1 line
  
  CAMEL-5948: Better make use of java.lang.reflect.Array utility, thanks to Daniel for the
hint.
........

Modified:
    camel/branches/camel-2.10.x/   (props changed)
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1431642

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java?rev=1431644&r1=1431643&r2=1431644&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
Thu Jan 10 21:12:13 2013
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Array;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
@@ -544,53 +545,11 @@ public final class ObjectHelper {
                     }
 
                     private int length() {
-                        int answer = 0;
-                        if (array instanceof byte[]) {
-                            answer = ((byte[]) array).length;
-                        } else if (array instanceof short[]) {
-                            answer = ((short[]) array).length;
-                        } else if (array instanceof int[]) {
-                            answer = ((int[]) array).length;
-                        } else if (array instanceof long[]) {
-                            answer = ((long[]) array).length;
-                        } else if (array instanceof float[]) {
-                            answer = ((float[]) array).length;
-                        } else if (array instanceof double[]) {
-                            answer = ((double[]) array).length;
-                        } else if (array instanceof char[]) {
-                            answer = ((char[]) array).length;
-                        } else if (array instanceof boolean[]) {
-                            answer = ((boolean[]) array).length;
-                        } else {
-                            throw new IllegalStateException("Unexpected type for " + array);
-                        }
-
-                        return answer;
+                        return Array.getLength(array);
                     }
 
                     private Object current(int index) {
-                        Object answer = 0;
-                        if (array instanceof byte[]) {
-                            answer = Byte.valueOf(((byte[]) array)[index]);
-                        } else if (array instanceof short[]) {
-                            answer = Short.valueOf(((short[]) array)[index]);
-                        } else if (array instanceof int[]) {
-                            answer = Integer.valueOf(((int[]) array)[index]);
-                        } else if (array instanceof long[]) {
-                            answer = Long.valueOf(((long[]) array)[index]);
-                        } else if (array instanceof float[]) {
-                            answer = Float.valueOf(((float[]) array)[index]);
-                        } else if (array instanceof double[]) {
-                            answer = Double.valueOf(((double[]) array)[index]);
-                        } else if (array instanceof char[]) {
-                            answer = Character.valueOf(((char[]) array)[index]);
-                        } else if (array instanceof boolean[]) {
-                            answer = Boolean.valueOf(((boolean[]) array)[index]);
-                        } else {
-                            throw new IllegalStateException("Unexpected type for " + array);
-                        }
-
-                        return answer;
+                        return Array.get(array, index);
                     }
 
                 };



Mime
View raw message