camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: String replacement via Spring
Date Wed, 19 Sep 2012 13:49:51 GMT
The replace method on java.lang.String accepts only char as
parameters, and not another string.
Hence why it wont work.

eg "foo" is not a char.


On Wed, Sep 19, 2012 at 3:30 PM, gramanero <gramanero@gmail.com> wrote:
> Hi Henryk,
>
> I apologize for not providing more information. I guess I thought there was
> enough context within the thread that one could understand what I was
> referring to. Sounds like that was not the case.
>
> The two attempts I made using Spring are as follows:
>
> What Claus suggested:
> <transform>
>   <simple>${body.replaceAll("foo", "bar")}</simple>
> </transform>
>
> Same thing as what Claus suggested with the exception of using .replace
> instead of .replaceAll.
> <transform>
>   <simple>${body.replace("foo", "bar")}</simple>
> </transform>
>
> The replacement strings that I am using in the example above are not really
> what I want in the end, but I wanted to just get anything working at this
> point. The point of my last response is that neither solution appears to be
> behaving as I would expect, but again I am wondering if this just isn't
> something that the Simple language can handle. I would like to know if the
> errors I posted earlier are expected or if there is some other underlying
> problem with the Simple language parser.
>
> The real transform that I am trying to get to is something like this:
> <transform>
>   <simple>${body.replace("\\", "\\\\")}</simple>
> </transform>
>
> I just need to replace all single backslashes in a windows-based fully
> qualified file path with double backslashes such that I can send the JSON
> packet to a restful service. Right now, the request is failing to send to
> the .NET restful service due to the backslashes in the file path. If I
> manually change the single backslashes to double backslashes, the JSON
> packet is accepted and processed by the restful service. I also thought
> about using headers to send the information, but this doesn't seem like a
> "restful"way of doing things.
>
> Another approach would be to URL encode the file path, but I can't seem to
> find a way to do that in Spring either. I am very new to Camel, so I am just
> hoping that I am missing something simple.
>
> Thank you for the response and sorry for not being clear enough in my
> previous post.
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/String-replacement-via-Spring-tp5719498p5719590.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Mime
View raw message