History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XFIRE-459
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Dan Diephouse
Reporter: Keith Garry Boyce
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
XFire

Getter and setter handling in InterfaceInvocationHandler violates Javabean spec

Created: 15/Jun/06 03:29 PM   Updated: 12/Jul/06 09:22 AM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.2-RC

Time Tracking:
Not Specified


 Description  « Hide
Thus when we extract a property or event name from the middle of an existing Java name, we
normally convert the first character to lower case. However to support the occasional use of
upper-case names, we check if the first two characters of the name are both upper case and
so leave it alone. So for example,
"FooBah" becomes "fooBah"
"Z" becomes "z"
"URL" becomes "URL"
We provide a method Introspector.decapitalize which implements this conversion rule.

Should do something like:

private String convertMethodName(String methodName,int firstCharacter) {
if (methodName.length() >= firstCharacter+2) {
if (! Character.isUpperCase(methodName.charAt(firstCharacter+1))) { return Character.toLowerCase(methodName.charAt(firstCharacter)) + methodName.substring(firstCharacter+1); } else { return methodName.substring(3); }
} else { return Character.toLowerCase(methodName.charAt(firstCharacter)) + methodName.substring(firstCharacter+1); }
}

protected Object doGetter(Method method, Object[] args)
throws Throwable

{ String methodName = method.getName(); String attrName = null; if (methodName.startsWith("get")) attrName = convertMethodName(methodName,3); else if (methodName.startsWith("is")) attrName = convertMethodName(methodName,2); else throw new IllegalAccessError(methodName + " is not a valid getter method."); return readProperty(attrName); }

protected Object doSetter(Method method, Object[] args)
throws Throwable

{ String methodName = method.getName(); String attrName = null; if (methodName.startsWith("set")) attrName = convertMethodName(methodName,3); else throw new IllegalAccessError(methodName + " is not a valid setter method."); writeProperty(attrName, args[0]); return null; }

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Dan Diephouse - 12/Jul/06 09:22 AM
Fixed in SVN now. Thanks.