It's very easy to override this behavior if you want to handle a char value as a single character string, without modifying the code. Just define the same methods you've listed below in your own code, then reference them in your binding as serializer/deserializer. You can use the serializer/deserializer on a particular value, or define them as the defaults for all values of this type with a <format>. See the tutorial at http://jibx.sourceforge.net/tutorial/binding-extend.html#serdeser for details. This would probably be a good item to add to the Wiki, if one of you would be willing to do that.

For the next version I'll include these as part of the Utility classes (with names like parseCharString and serializerCharString) just to make it even easier. If there's that much interest I can even make them the default for chars. I hate changing defaults unnecessarily, though, since that may break someone else's code.

 - Dennis

Thomas Jones-Low wrote:

Robert,
I don't know how to write the marshaller/unmarhsaller. I found it easier to modify the Utility.java code and rebuild the JiBX library.


Find the following two functions in the src\org\jibx\runtime\Utility.java file (line 369ff) and replace them with the following:

    public static char parseChar(String text) throws JiBXException {
        if (text.length() != 1)
                throw new JiBXException ("Value out of range");
        return text.charAt(0);
    }

    public static String serializeChar(char value) {
        return Character.toString(value);
    }

        I'm going to repost this bug.






------------------------------------------------------- This SF.Net email is sponsored by: SourceForge.net Broadband Sign-up now for SourceForge Broadband and get the fastest 6.0/768 connection for only $19.95/mo for the first 3 months! http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click _______________________________________________ jibx-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to