Uploaded image for project: 'Commons BeanUtils'
  1. Commons BeanUtils
  2. BEANUTILS-180

java.util.List to be permitted for indexed properties.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • None
    • None
    • None
    • Operating System: other
      Platform: Other

    • 5639

    Description

      Indexed properties are of the following formats as per the spec.

      public Object getIndexedProperty(int i) {}
      or
      public Object[] getIndexedProperty() {}

      It's a big help when using indexed properties to be able to return an
      implementation of java.util.List rather than return an array primitive all the time.
      The BeanUtils package already uses implementations of Map, so using List
      implementations isn't stepping out of line.
      To fix this, open PropertyUtils.java and replace lines 418 to 423 with the code
      below (line numbers are inclusive, and as of 30th Dec. 2001)...

      Code start --==>>

      // Call the property getter and return the value
      Object value = readMethod.invoke(bean, new Object[0]);
      if (!value.getClass().isArray()) {
      if (!(value instanceof java.util.List))

      { throw new IllegalArgumentException("Property '" + name + "' is not indexed"); }

      else

      { return ((java.util.List)value).get(index); }

      }
      return (Array.get(value, index));

      <<==-- code finish.
      If the code has changed since then, it's at the end of the getIndexedProperty
      method, the comment and the next line in the code block above is the same.

      Attachments

        Activity

          People

            Unassigned Unassigned
            arron@keyboardmonkey.com Arron Bates
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: