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 07:18:27 UTC

[jira] Created: (JXPATH-146) JavaBean XPath with uppercase initial characters

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.


[jira] Commented: (JXPATH-146) JavaBean XPath with uppercase initial characters

Posted by "Ram (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Resolved: (JXPATH-146) JavaBean XPath with uppercase initial characters

Posted by "Matt Benson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JXPATH-146?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Benson resolved JXPATH-146.
--------------------------------

    Resolution: Not A Problem

To be honest I can't see how this feature fits into JXPath's mission to provide xpath handling of Java object graphs.  I could argue it would be just as easy for you to write a convenience layer over JXPath that does what you want, or simply clone BeanPointer, BeanPropertyPointer, and BeanPointerFactory and register your factory with a higher priority than BEAN_POINTER_FACTORY_ORDER to intercept the normal creation of BeanPropertyPointers with your own pointer implementation that includes the behavior you desire.

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