Return-Path:
X-Original-To: apmail-camel-dev-archive@www.apache.org
Delivered-To: apmail-camel-dev-archive@www.apache.org
Received: from mail.apache.org (hermes.apache.org [140.211.11.3])
by minotaur.apache.org (Postfix) with SMTP id CC134EF9B
for ;
Thu, 10 Jan 2013 20:55:19 +0000 (UTC)
Received: (qmail 18821 invoked by uid 500); 10 Jan 2013 20:55:19 -0000
Delivered-To: apmail-camel-dev-archive@camel.apache.org
Received: (qmail 18775 invoked by uid 500); 10 Jan 2013 20:55:19 -0000
Mailing-List: contact dev-help@camel.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: dev@camel.apache.org
Delivered-To: mailing list dev@camel.apache.org
Received: (qmail 18764 invoked by uid 99); 10 Jan 2013 20:55:19 -0000
Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230)
by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jan 2013 20:55:19 +0000
X-ASF-Spam-Status: No, hits=0.7 required=5.0
tests=SPF_NEUTRAL
X-Spam-Check-By: apache.org
Received-SPF: neutral (nike.apache.org: local policy)
Received: from [64.85.173.253] (HELO server.dankulp.com) (64.85.173.253)
by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jan 2013 20:55:11 +0000
Received: by server.dankulp.com (Postfix, from userid 5000)
id 73B21180A4B; Thu, 10 Jan 2013 15:54:50 -0500 (EST)
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on server.dankulp.com
X-Spam-Level:
X-Msg-File: /tmp/mailfilter-dev@camel.apache.org.K4yN5nhgW1
Received: from macbook.house.dankulp.com (c-24-91-72-253.hsd1.ma.comcast.net
[24.91.72.253])
(using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits))
(No client certificate requested)
by server.dankulp.com (Postfix) with ESMTPSA id 130331809D6;
Thu, 10 Jan 2013 15:54:44 -0500 (EST)
Content-Type: text/plain; charset=windows-1252
Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\))
Subject: Re: svn commit: r1431626 - in /camel/trunk/camel-core/src:
main/java/org/apache/camel/util/ObjectHelper.java
test/java/org/apache/camel/util/ObjectHelperTest.java
From: Daniel Kulp
In-Reply-To: <20130110204401.62E7D23889D7@eris.apache.org>
Date: Thu, 10 Jan 2013 15:54:43 -0500
Content-Transfer-Encoding: quoted-printable
Message-Id:
References: <20130110204401.62E7D23889D7@eris.apache.org>
To: dev@camel.apache.org,
bvahdat@apache.org
X-Mailer: Apple Mail (2.1499)
X-Virus-Checked: Checked by ClamAV on apache.org
X-Old-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00
shortcircuit=no autolearn=ham version=3.3.2
Any particular reason for not just doing:
java.lang.reflect.Array.getLength(array)
to get the length and:
java.lang.reflect.Array.get(array, index);
to avoid all the casting, instanceofs, etc=85.? The "get" method will =
automatically handle the boxing as well.
Dan
On Jan 10, 2013, at 3:44 PM, bvahdat@apache.org wrote:
> Author: bvahdat
> Date: Thu Jan 10 20:44:00 2013
> New Revision: 1431626
>=20
> URL: http://svn.apache.org/viewvc?rev=3D1431626&view=3Drev
> Log:
> CAMEL-5948: ObjectHelper.createIterator() should properly handle the =
array of primitive types e.g. int[].
>=20
> Modified:
> =
camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.ja=
va
> =
camel/trunk/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTes=
t.java
>=20
> Modified: =
camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.ja=
va
> URL: =
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apac=
he/camel/util/ObjectHelper.java?rev=3D1431626&r1=3D1431625&r2=3D1431626&vi=
ew=3Ddiff
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
> --- =
camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.ja=
va (original)
> +++ =
camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.ja=
va Thu Jan 10 20:44:00 2013
> @@ -64,6 +64,12 @@ import org.slf4j.LoggerFactory;
> public final class ObjectHelper {
> private static final transient Logger LOG =3D =
LoggerFactory.getLogger(ObjectHelper.class);
> private static final String DEFAULT_DELIMITER =3D ",";
> + @SuppressWarnings("unchecked")
> + private static final List> PRIMITIVE_TYPES =3D =
Arrays.asList(byte.class, short.class, int.class, long.class,
> + =
float.class, double.class, char.class, boolean.class, void.class);
> + @SuppressWarnings("unchecked")
> + private static final List> PRIMITIVE_ARRAY_TYPES =3D =
Arrays.asList(byte[].class, short[].class, int[].class, long[].class,
> + =
float[].class, double[].class, char[].class, boolean[].class);
>=20
> /**
> * Utility classes should not have a public constructor.
> @@ -493,7 +499,12 @@ public final class ObjectHelper {
> * Object[], a String with values separated by the given =
delimiter,
> * or a primitive type array; otherwise to simplify the caller's
> * code, we just create a singleton collection iterator over a =
single value
> - *
> + *=20
> + *
In case of primitive type arrays the returned {@code =
Iterator} iterates
> + * over the corresponding Java primitive wrapper objects of the =
given elements
> + * inside the {@code value} array. That's we get an autoboxing of =
the primitive
> + * types here for free as it's also the case in Java language =
itself.
> + *=20
> * @param value the value
> * @param delimiter delimiter for separating String values
> * @param allowEmptyValues whether to allow empty values
> @@ -514,9 +525,79 @@ public final class ObjectHelper {
> } else if (value instanceof Iterable) {
> return ((Iterable