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))
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.