Uploaded image for project: 'Commons JXPath'
  1. Commons JXPath
  2. JXPATH-8

Better integration with ConvertUtils

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • Operating System: other
      Platform: Other

    • 30272

    Description

      actually, ConvertUtils from BeanUtils is used like this in the
      BasicTypeConverter:

      if (ConvertUtils.lookup(toType) != null) {
      return ConvertUtils.convert(object.toString(), toType);
      }

      the toString() could cause some problem: imagine that my property is a Date and
      I would like it to be converted to an Integer like this:

      context.getValue("record/lastModificationDate", Integer.class);

      The toString() will get me something like 'November Wed 17h, 2002' then will
      try to convert this to a number which is kinda problematic because it is now a
      string and you've lost the fact that it was a date before (which is required to
      know how to convert it).

      I propose to skip the toString() by directly using the looked up Converter
      which can take an object as argument instead of a string:

      Converter converter = ConvertUtils.lookup(toType);
      if (converter != null) {
      return converter.convert(toType, object);
      }

      By the way, did you take a look at the Convert component in the commons sandbox?

      Attachments

        Activity

          People

            Unassigned Unassigned
            xdury@hotmail.com Xavier Dury
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: