camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dale King <dalewk...@gmail.com>
Subject Re: Scala DSL lacks a way to specify return type of language expressions
Date Wed, 02 Oct 2013 12:19:05 GMT
A conversion after the fact does not help in this case as evaluating the
expression itself fails with an exception unless you tell the xpath what
the correct result type will be. If you don't specify, it assumes node set.
In the case of a count expression the result is a number which cannot be
converted to node set.

For the record I am dealing with something like this in Java DSL:

   setHeader("fooCount", xpath("count(/bar/foo)", Integer.class))

Without the Integer.class parameter this throws an exception. The Scala DSL
does not support adding the return type and no conversion after the fact
will fix it.
On Oct 2, 2013 1:46 AM, "kraythe ." <kraythe@gmail.com> wrote:

> Write an implicit conversion.
>
> Scala doesnt manage return types much. Its unnecessary baggage. I rather
> like that and wish I could use it in my work.
>
> *Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
> *Author of: Hardcore Java (2003) and Maintainable Java (2012)*
> *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39*
>
>
> On Tue, Oct 1, 2013 at 8:55 PM, Dale King <dalewking@gmail.com> wrote:
>
> > The language support in the Scala DSL is too simplistic in that it does
> not
> > support all the options of Java DSL.
> >
> > In particular it does not allow setting the return type of the
> expression.
> > In my case I am trying to  set a header to the result of an xpath count
> > expression. In the Java DSL this fails unless you explicitly set the
> return
> > type of the xpath expression because the default return type for xpath
> is a
> > node set and it cannot convert a number to a node set.
> >
> > It also lacks all the other overloads for things like Namespaces on
> xpath,
> > etc.
> >
> > --
> > Dale King
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message