You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Ram (JIRA)" <ji...@apache.org> on 2010/03/26 08:18:27 UTC
[jira] Commented: (JXPATH-146) JavaBean XPath with uppercase
initial characters
[ https://issues.apache.org/jira/browse/JXPATH-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12850025#action_12850025 ]
Ram commented on JXPATH-146:
----------------------------
The following change seems to work. The code tries to convert the first character to lowercase (see last 4 lines of new code.).
{code:title=BeanPropertyPointer.java}
private PropertyDescriptor getPropertyDescriptor() {
if (propertyDescriptor == null) {
int inx = getPropertyIndex();
if (inx == UNSPECIFIED_PROPERTY) {
propertyDescriptor =
beanInfo.getPropertyDescriptor(propertyName);
char fc = propertyName.charAt(0);
if (propertyDescriptor == null && fc <= 'Z') {
String newPropName = new String(fc+"").toLowerCase() + propertyName.substring(1);
propertyDescriptor = beanInfo.getPropertyDescriptor(newPropName);
}
}
....
{code}
I only did a quick test for "getValue". Not sure if this impacts anything else.
> JavaBean XPath with uppercase initial characters
> ------------------------------------------------
>
> Key: JXPATH-146
> URL: https://issues.apache.org/jira/browse/JXPATH-146
> Project: Commons JXPath
> Issue Type: Improvement
> Affects Versions: 1.3
> Reporter: Ram
> Priority: Minor
>
> XPath expressions executed against a JavaBean only work when the initial character is lower case.
> context.getValue("firstName") //works
> context.getValue("FirstName") //doesn't work
> The code internally is looking at PropertyDescriptors and these start with lower case as per the JavaBean spec.
> I will be nice if both versions work ( just like 'firstName' and '@firstName' work even though JavaBeans don't differentiate attributes vs elements).
> The fix may be simple as converting the initial character to lower case before the PropertyDescriptor lookup. Haven't looked at the impacts in detail though.
> Thoughts ?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.