Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.1 Final
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: Other

      Description

      ConvertUtils from commons BeanUtils package should be used instead of TypeUtils
      for type conversions because it is more 'pluggable' (you can add/register any
      converter you want).

      Until it's changed, I'm using something like this (I'm not sure this is a good
      solution):

      TypeUtils.setTypeConverter(new TypeConverter() {
      public boolean canConvert(Object object, Class toType)

      { return ConvertUtils.lookup(toType) != null; }

      public Object convert(Object object, Class toType)

      { return ConvertUtils.convert(object.toString(), toType); }

      });

        Activity

        Hide
        Dmitri Plotnikov added a comment -

        I added the integration with ConvertUtils, but rather than being the
        replacement for TypeUtils, it is integrated with it and is invoked only as the
        last resort. The reason for this is that the XPath standard defines a bunch of
        conversions and we want to stick to the standard, regardless of the
        ConvertUtils configuration.

        Show
        Dmitri Plotnikov added a comment - I added the integration with ConvertUtils, but rather than being the replacement for TypeUtils, it is integrated with it and is invoked only as the last resort. The reason for this is that the XPath standard defines a bunch of conversions and we want to stick to the standard, regardless of the ConvertUtils configuration.
        Hide
        Xavier Dury added a comment -

        Better use something like this:

        TypeUtils.setTypeConverter(new TypeConverter() {
        public boolean canConvert(Object object, Class toType)

        { return ConvertUtils.lookup(toType) != null; }

        public Object convert(Object object, Class toType)

        { return ConvertUtils.lookup(toType).convert(toType, object); }

        });

        Show
        Xavier Dury added a comment - Better use something like this: TypeUtils.setTypeConverter(new TypeConverter() { public boolean canConvert(Object object, Class toType) { return ConvertUtils.lookup(toType) != null; } public Object convert(Object object, Class toType) { return ConvertUtils.lookup(toType).convert(toType, object); } });

          People

          • Assignee:
            Unassigned
            Reporter:
            Xavier Dury
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development