You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ablevine1 <ab...@gmail.com> on 2015/08/13 00:40:41 UTC

Define an array in simple

I have found lots of documentation on how to manipulate an array in simple
but none on how to create one.  Is this possible?  I have a bean with method
whose first parameter is an object second parameter is an array of strings.  

My method signature is like so:

myMethod(MyObjectType o, String ... values)

I was hoping to call it from the spring DSL like so:

<bean ref="myBean" method="myMethod(${body}, ['string literal 1', 'string
literal 2', 'string literal 3']" /> 

OR

<bean ref="myBean" method="myMethod(${body}, 'string literal 1', 'string
literal 2', 'string literal 3'" /> 


Neither seem to work and I get an exception like the following:
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type
converter available to convert from type: java.lang.String to the required
type: java.lang.String[] with value [string literal 1]

Any help would be appreciated.



--
View this message in context: http://camel.465427.n5.nabble.com/Define-an-array-in-simple-tp5770637.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Define an array in simple

Posted by ablevine1 <ab...@gmail.com>.
Thanks again. That made the code a bit cleaner. It took a minute to figure
out the exact syntax but that makes the code now: 

<validate><simple>${body.mypropertytovalidate} in
'STRING1,STRING2,STRING3'</simple></validate>



--
View this message in context: http://camel.465427.n5.nabble.com/Define-an-array-in-simple-tp5770637p5770701.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Define an array in simple

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I think there is an IN function in simple also that ought to support this
check too

Den torsdag den 13. august 2015 skrev ablevine1 <ab...@gmail.com>:

> Thanks for getting back to me about this.  Too bad that array creation is
> not
> supported.   What I was trying to do with my bean method was to provide
> validation to check whether or not one of the properties of my object was
> equal to one of the values in the array.  I just found an alternate
> solution
> by using the validate dsl instead.  I'm not sure how I managed not to find
> the validate DSL first before rolling my own solution.  With the validate
> DSL I was able to do the following instead:
>
> <validate><simple>${body.mypropertytovalidate} regex
> '\b(STRING1|STRING2|STRING3)\b'</simple></validate>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Define-an-array-in-simple-tp5770637p5770691.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition: http://www.manning.com/ibsen2

Re: Define an array in simple

Posted by ablevine1 <ab...@gmail.com>.
Thanks for getting back to me about this.  Too bad that array creation is not
supported.   What I was trying to do with my bean method was to provide
validation to check whether or not one of the properties of my object was
equal to one of the values in the array.  I just found an alternate solution
by using the validate dsl instead.  I'm not sure how I managed not to find
the validate DSL first before rolling my own solution.  With the validate
DSL I was able to do the following instead:

<validate><simple>${body.mypropertytovalidate} regex
'\b(STRING1|STRING2|STRING3)\b'</simple></validate>
            



--
View this message in context: http://camel.465427.n5.nabble.com/Define-an-array-in-simple-tp5770637p5770691.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Define an array in simple

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Arrays is not supported with [] etc.




On Thu, Aug 13, 2015 at 12:40 AM, ablevine1 <ab...@gmail.com> wrote:
> I have found lots of documentation on how to manipulate an array in simple
> but none on how to create one.  Is this possible?  I have a bean with method
> whose first parameter is an object second parameter is an array of strings.
>
> My method signature is like so:
>
> myMethod(MyObjectType o, String ... values)
>
> I was hoping to call it from the spring DSL like so:
>
> <bean ref="myBean" method="myMethod(${body}, ['string literal 1', 'string
> literal 2', 'string literal 3']" />
>
> OR
>
> <bean ref="myBean" method="myMethod(${body}, 'string literal 1', 'string
> literal 2', 'string literal 3'" />
>
>
> Neither seem to work and I get an exception like the following:
> Caused by: org.apache.camel.NoTypeConversionAvailableException: No type
> converter available to convert from type: java.lang.String to the required
> type: java.lang.String[] with value [string literal 1]
>
> Any help would be appreciated.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Define-an-array-in-simple-tp5770637.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition: http://www.manning.com/ibsen2