commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmi...@apache.org
Subject cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri JXPathContextReferenceImpl.java
Date Sun, 13 Oct 2002 02:26:50 GMT
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:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message