You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by dm...@apache.org on 2002/10/13 04:26:50 UTC

cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri JXPathContextReferenceImpl.java

dmitri      2002/10/12 19:26:50

  Modified:    jxpath/src/java/org/apache/commons/jxpath/ri
                        JXPathContextReferenceImpl.java
  Log:
  Fixed this bug: setLenient(true) did not have the advertised effect in some cases
  
  Revision  Changes    Path
  1.22      +19 -8     jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
  
  Index: JXPathContextReferenceImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- JXPathContextReferenceImpl.java	26 Aug 2002 22:29:49 -0000	1.21
  +++ JXPathContextReferenceImpl.java	13 Oct 2002 02:26:50 -0000	1.22
  @@ -211,15 +211,26 @@
   
       public Object getValue(String xpath, Expression expr){
           Object result = expr.computeValue(getRootContext());
  -        if (result == null && !lenient){
  -            throw new JXPathException("No value for xpath: " + xpath);
  -        }
  -
           if (result instanceof EvalContext){
               EvalContext ctx = (EvalContext)result;
               result = ctx.getSingleNodePointer();
  +            if (!lenient && result == null){
  +                throw new JXPathException("No value for xpath: " + xpath);
  +            }
           }
           if (result instanceof NodePointer){
  +            if (!lenient && !((NodePointer)result).isActual()){
  +                // We need to differentiate between pointers representing
  +                // a non-existing property and one representing a property
  +                // whose value is null.  In the latter case, the pointer
  +                // is going to have isActual == false, but its parent,
  +                // which is a non-node pointer identifying the bean property,
  +                // will return isActual() == true.
  +                NodePointer parent = ((NodePointer)result).getParent();
  +                if (parent == null || parent.isNode() || !parent.isActual()){
  +                    throw new JXPathException("No value for xpath: " + xpath);
  +                }
  +            }
               result = ((NodePointer)result).getValue();
           }
           return result;
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>