You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Christian Schneider (JIRA)" <ji...@apache.org> on 2009/04/30 08:41:38 UTC

[jira] Created: (CAMEL-1573) convertBodyTo should have an optional parameter for setting the encoding

convertBodyTo should have an optional parameter for setting the encoding
------------------------------------------------------------------------

                 Key: CAMEL-1573
                 URL: https://issues.apache.org/activemq/browse/CAMEL-1573
             Project: Apache Camel
          Issue Type: Improvement
    Affects Versions: 2.0-M1
            Reporter: Christian Schneider
             Fix For: 2.0-M2


When converting data  from a binary form the convertBodyTo(String.class) function currently does not support changing the encoding. This should be added.  Additionally it would be nice to have automatic encoding settings for xml files that contain a <?xml header with an encoding attribute.

The issue happened for me when I tried to read from a FileEndpoint. I have debugged into the code and found that where the file is read there seems to be no support for encoding at all. But maybe I am wrong. I will search for the place in the code and post a link here.

http://www.nabble.com/Convert-File-to-String-with-encoding-to23291163.html


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CAMEL-1573) convertBodyTo should have an optional parameter for setting the encoding

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-1573?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-1573:
-------------------------------

    Fix Version/s:     (was: 2.0-M2)
                   2.0.0

> convertBodyTo should have an optional parameter for setting the encoding
> ------------------------------------------------------------------------
>
>                 Key: CAMEL-1573
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1573
>             Project: Apache Camel
>          Issue Type: Improvement
>    Affects Versions: 2.0-M1
>            Reporter: Christian Schneider
>             Fix For: 2.0.0
>
>
> When converting data  from a binary form the convertBodyTo(String.class) function currently does not support changing the encoding. This should be added.  Additionally it would be nice to have automatic encoding settings for xml files that contain a <?xml header with an encoding attribute.
> The issue happened for me when I tried to read from a FileEndpoint. I have debugged into the code and found that where the file is read there seems to be no support for encoding at all. But maybe I am wrong. I will search for the place in the code and post a link here.
> http://www.nabble.com/Convert-File-to-String-with-encoding-to23291163.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (CAMEL-1573) convertBodyTo should have an optional parameter for setting the encoding

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-1573?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-1573.
--------------------------------

    Resolution: Fixed

trunk: 771351
1.x: 771353

In 1.x I have fixed the bug in ObjectHelper.loadClass not being able to load byte[] class.



> convertBodyTo should have an optional parameter for setting the encoding
> ------------------------------------------------------------------------
>
>                 Key: CAMEL-1573
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1573
>             Project: Apache Camel
>          Issue Type: Improvement
>    Affects Versions: 2.0-M1
>            Reporter: Christian Schneider
>            Assignee: Claus Ibsen
>             Fix For: 2.0.0
>
>
> When converting data  from a binary form the convertBodyTo(String.class) function currently does not support changing the encoding. This should be added.  Additionally it would be nice to have automatic encoding settings for xml files that contain a <?xml header with an encoding attribute.
> The issue happened for me when I tried to read from a FileEndpoint. I have debugged into the code and found that where the file is read there seems to be no support for encoding at all. But maybe I am wrong. I will search for the place in the code and post a link here.
> http://www.nabble.com/Convert-File-to-String-with-encoding-to23291163.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-1573) convertBodyTo should have an optional parameter for setting the encoding

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1573?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=51458#action_51458 ] 

Claus Ibsen commented on CAMEL-1573:
------------------------------------

That constant is in Camel 2.0. In Camel 1.x its somewhere else.

You should really use org.w3c.Document as the type if you want to read an XML file. It will leverage the Java XML API to read and understand the encoding option in the XML files.
Then afterwards you can get it as a String.

Or the javax.xml.transform.stream.StreamSource should also be doable.

Camel cannot really know its a XML file, unless we add some convention that if the file name extension is xml it should use the XML converters.

> convertBodyTo should have an optional parameter for setting the encoding
> ------------------------------------------------------------------------
>
>                 Key: CAMEL-1573
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1573
>             Project: Apache Camel
>          Issue Type: Improvement
>    Affects Versions: 2.0-M1
>            Reporter: Christian Schneider
>             Fix For: 2.0-M2
>
>
> When converting data  from a binary form the convertBodyTo(String.class) function currently does not support changing the encoding. This should be added.  Additionally it would be nice to have automatic encoding settings for xml files that contain a <?xml header with an encoding attribute.
> The issue happened for me when I tried to read from a FileEndpoint. I have debugged into the code and found that where the file is read there seems to be no support for encoding at all. But maybe I am wrong. I will search for the place in the code and post a link here.
> http://www.nabble.com/Convert-File-to-String-with-encoding-to23291163.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-1573) convertBodyTo should have an optional parameter for setting the encoding

Posted by "Christian Schneider (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1573?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=51464#action_51464 ] 

Christian Schneider commented on CAMEL-1573:
--------------------------------------------

Hi Claus,

I have just tested with org.w3c.dom.Document. This seems to work fine. So we have a solution for my problem. 
But in any case this should be added to documentation. I did not know that I can convert to Document.

Is there any page already for the convertBodyTo ? I did not find one. It would be quite nice to have some examples for conversions. Perhaps there could be one page per dsl method. Are there any plans to build this? 

> convertBodyTo should have an optional parameter for setting the encoding
> ------------------------------------------------------------------------
>
>                 Key: CAMEL-1573
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1573
>             Project: Apache Camel
>          Issue Type: Improvement
>    Affects Versions: 2.0-M1
>            Reporter: Christian Schneider
>             Fix For: 2.0-M2
>
>
> When converting data  from a binary form the convertBodyTo(String.class) function currently does not support changing the encoding. This should be added.  Additionally it would be nice to have automatic encoding settings for xml files that contain a <?xml header with an encoding attribute.
> The issue happened for me when I tried to read from a FileEndpoint. I have debugged into the code and found that where the file is read there seems to be no support for encoding at all. But maybe I am wrong. I will search for the place in the code and post a link here.
> http://www.nabble.com/Convert-File-to-String-with-encoding-to23291163.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (CAMEL-1573) convertBodyTo should have an optional parameter for setting the encoding

Posted by "Christian Schneider (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-1573?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christian Schneider closed CAMEL-1573.
--------------------------------------


> convertBodyTo should have an optional parameter for setting the encoding
> ------------------------------------------------------------------------
>
>                 Key: CAMEL-1573
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1573
>             Project: Apache Camel
>          Issue Type: Improvement
>    Affects Versions: 2.0-M1
>            Reporter: Christian Schneider
>            Assignee: Claus Ibsen
>             Fix For: 2.0.0
>
>
> When converting data  from a binary form the convertBodyTo(String.class) function currently does not support changing the encoding. This should be added.  Additionally it would be nice to have automatic encoding settings for xml files that contain a <?xml header with an encoding attribute.
> The issue happened for me when I tried to read from a FileEndpoint. I have debugged into the code and found that where the file is read there seems to be no support for encoding at all. But maybe I am wrong. I will search for the place in the code and post a link here.
> http://www.nabble.com/Convert-File-to-String-with-encoding-to23291163.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (CAMEL-1573) convertBodyTo should have an optional parameter for setting the encoding

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-1573?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen reassigned CAMEL-1573:
----------------------------------

    Assignee: Claus Ibsen

> convertBodyTo should have an optional parameter for setting the encoding
> ------------------------------------------------------------------------
>
>                 Key: CAMEL-1573
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1573
>             Project: Apache Camel
>          Issue Type: Improvement
>    Affects Versions: 2.0-M1
>            Reporter: Christian Schneider
>            Assignee: Claus Ibsen
>             Fix For: 2.0.0
>
>
> When converting data  from a binary form the convertBodyTo(String.class) function currently does not support changing the encoding. This should be added.  Additionally it would be nice to have automatic encoding settings for xml files that contain a <?xml header with an encoding attribute.
> The issue happened for me when I tried to read from a FileEndpoint. I have debugged into the code and found that where the file is read there seems to be no support for encoding at all. But maybe I am wrong. I will search for the place in the code and post a link here.
> http://www.nabble.com/Convert-File-to-String-with-encoding-to23291163.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-1573) convertBodyTo should have an optional parameter for setting the encoding

Posted by "Christian Schneider (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1573?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=51457#action_51457 ] 

Christian Schneider commented on CAMEL-1573:
--------------------------------------------

I have found the code that reads the file. It seems to be IOConverter.toString(File file) . As you can see there is no encoding  mentioned. So I think this code will not work with the Exchange.CHARSET_NAME parameter. Btw. I have not yet found this constant.

> convertBodyTo should have an optional parameter for setting the encoding
> ------------------------------------------------------------------------
>
>                 Key: CAMEL-1573
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1573
>             Project: Apache Camel
>          Issue Type: Improvement
>    Affects Versions: 2.0-M1
>            Reporter: Christian Schneider
>             Fix For: 2.0-M2
>
>
> When converting data  from a binary form the convertBodyTo(String.class) function currently does not support changing the encoding. This should be added.  Additionally it would be nice to have automatic encoding settings for xml files that contain a <?xml header with an encoding attribute.
> The issue happened for me when I tried to read from a FileEndpoint. I have debugged into the code and found that where the file is read there seems to be no support for encoding at all. But maybe I am wrong. I will search for the place in the code and post a link here.
> http://www.nabble.com/Convert-File-to-String-with-encoding-to23291163.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-1573) convertBodyTo should have an optional parameter for setting the encoding

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-1573?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=51469#action_51469 ] 

Claus Ibsen commented on CAMEL-1573:
------------------------------------

Hi Christian

Camel have 150+ type converters in the distribution. The new Camel web console have a web page that lists them all.
And I think there is a maven tool that could generate a list of converters as well.

But the rule of thumb is that you should just try to convert to the type you want and Camel will lookup a suitable type convert if any exsits.
If not you get an exception.

The basic converters for String, byte[], streams, XML should be there. There might be some odd combinations missing such as a org.w3c.Document to byte[] or the likes.

Keeping documentation in the wiki is time consuming and it would be much better if we get a tool to be able to slurp the javadoc in the code, then we would be able to generate a full DSL list with documentation.

As we love contributions, you can get karma to the wiki pages so you can edit and add it yourself.

> convertBodyTo should have an optional parameter for setting the encoding
> ------------------------------------------------------------------------
>
>                 Key: CAMEL-1573
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-1573
>             Project: Apache Camel
>          Issue Type: Improvement
>    Affects Versions: 2.0-M1
>            Reporter: Christian Schneider
>             Fix For: 2.0.0
>
>
> When converting data  from a binary form the convertBodyTo(String.class) function currently does not support changing the encoding. This should be added.  Additionally it would be nice to have automatic encoding settings for xml files that contain a <?xml header with an encoding attribute.
> The issue happened for me when I tried to read from a FileEndpoint. I have debugged into the code and found that where the file is read there seems to be no support for encoding at all. But maybe I am wrong. I will search for the place in the code and post a link here.
> http://www.nabble.com/Convert-File-to-String-with-encoding-to23291163.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.