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/test/org/apache/commons/jxpath/ri/axes SimplePathInterpreterTest.java
Date Thu, 25 Mar 2004 03:49:51 GMT
dmitri      2004/03/24 19:49:51

  Modified:    jxpath/src/java/org/apache/commons/jxpath/ri/axes
                        SimplePathInterpreter.java ParentContext.java
                        AncestorContext.java
                        PrecedingOrFollowingContext.java ChildContext.java
               jxpath/src/java/org/apache/commons/jxpath/ri/model
                        NodePointer.java
               jxpath/src/java/org/apache/commons/jxpath/ri/model/beans
                        CollectionPointer.java NullElementPointer.java
                        NullPropertyPointer.java PropertyPointer.java
                        PropertyIterator.java
               jxpath/src/java/org/apache/commons/jxpath/ri
                        JXPathContextReferenceImpl.java
               jxpath/src/java/org/apache/commons/jxpath/ri/model/dynamic
                        DynamicPropertyPointer.java
               jxpath/src/test/org/apache/commons/jxpath/ri/axes
                        SimplePathInterpreterTest.java
  Log:
  getParent() will now return the actual parent NodePointer, 
  not some intermediate helper NodePointer
  
  Revision  Changes    Path
  1.15      +1 -1      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java
  
  Index: SimplePathInterpreter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- SimplePathInterpreter.java	29 Feb 2004 14:17:38 -0000	1.14
  +++ SimplePathInterpreter.java	25 Mar 2004 03:49:50 -0000	1.15
  @@ -694,7 +694,7 @@
           int quality = PERFECT_MATCH;
           while (pointer != null && !pointer.isActual()) {
               quality--;
  -            pointer = pointer.getParent();
  +            pointer = pointer.getImmediateParentPointer();
           }
           return quality;
       }
  
  
  
  1.15      +3 -3      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/ParentContext.java
  
  Index: ParentContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/ParentContext.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ParentContext.java	29 Feb 2004 14:17:37 -0000	1.14
  +++ ParentContext.java	25 Mar 2004 03:49:50 -0000	1.15
  @@ -64,10 +64,10 @@
           }
           setStarted = true;
           NodePointer thisLocation = parentContext.getCurrentNodePointer();
  -        currentNodePointer = thisLocation.getParent();
  +        currentNodePointer = thisLocation.getImmediateParentPointer();
           while (currentNodePointer != null
               && currentNodePointer.isContainer()) {
  -            currentNodePointer = currentNodePointer.getParent();
  +            currentNodePointer = currentNodePointer.getImmediateParentPointer();
           }
           if (currentNodePointer != null
               && currentNodePointer.testNode(nodeTest)) {
  
  
  
  1.15      +2 -2      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/AncestorContext.java
  
  Index: AncestorContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/AncestorContext.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AncestorContext.java	29 Feb 2004 14:17:37 -0000	1.14
  +++ AncestorContext.java	25 Mar 2004 03:49:50 -0000	1.15
  @@ -86,7 +86,7 @@
           }
   
           while (true) {
  -            currentNodePointer = currentNodePointer.getParent();
  +            currentNodePointer = currentNodePointer.getImmediateParentPointer();
   
               if (currentNodePointer == null) {
                   return false;
  
  
  
  1.15      +4 -18     jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/PrecedingOrFollowingContext.java
  
  Index: PrecedingOrFollowingContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/PrecedingOrFollowingContext.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- PrecedingOrFollowingContext.java	29 Feb 2004 14:17:38 -0000	1.14
  +++ PrecedingOrFollowingContext.java	25 Mar 2004 03:49:50 -0000	1.15
  @@ -80,8 +80,7 @@
           if (!setStarted) {
               setStarted = true;
               currentRootLocation = parentContext.getCurrentNodePointer();
  -            NodePointer parent =
  -                getMaterialPointer(currentRootLocation.getParent());
  +            NodePointer parent = currentRootLocation.getParent();
               if (parent != null) {
                   // TBD: check type
                   stack.push(
  @@ -91,16 +90,14 @@
   
           while (true) {
               if (stack.isEmpty()) {
  -                currentRootLocation =
  -                    getMaterialPointer(currentRootLocation.getParent());
  +                currentRootLocation = currentRootLocation.getParent();
   
                   if (currentRootLocation == null
                       || currentRootLocation.isRoot()) {
                       break;
                   }
   
  -                NodePointer parent =
  -                    getMaterialPointer(currentRootLocation.getParent());
  +                NodePointer parent = currentRootLocation.getParent();
                   if (parent != null) {
                       stack.push(
                           parent.childIterator(
  @@ -164,16 +161,5 @@
               }
           }
           return false;
  -    }
  -
  -    /**
  -     * If  the pointer is auxiliary, return the parent; otherwise - the pointer
  -     * itself
  -     */
  -    private NodePointer getMaterialPointer(NodePointer pointer) {
  -        while (pointer != null && pointer.isContainer()) {
  -            pointer = pointer.getParent();
  -        }
  -        return pointer;
       }
   }
  
  
  
  1.16      +1 -5      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/ChildContext.java
  
  Index: ChildContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/ChildContext.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ChildContext.java	29 Feb 2004 14:17:37 -0000	1.15
  +++ ChildContext.java	25 Mar 2004 03:49:50 -0000	1.16
  @@ -116,10 +116,6 @@
           }
           if (startFromParentLocation) {
               NodePointer pointer = parent.getParent();
  -            while (pointer != null && pointer.isContainer()) {
  -                pointer = pointer.getParent();
  -            }
  -
               iterator = pointer.childIterator(nodeTest, reverse, parent);
           }
           else {
  
  
  
  1.23      +11 -3     jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/NodePointer.java
  
  Index: NodePointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/NodePointer.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- NodePointer.java	29 Feb 2004 14:17:45 -0000	1.22
  +++ NodePointer.java	25 Mar 2004 03:49:50 -0000	1.23
  @@ -110,6 +110,14 @@
       }
   
       public NodePointer getParent() {
  +        NodePointer pointer = parent;
  +        while (pointer != null && pointer.isContainer()) {
  +            pointer = pointer.getImmediateParentPointer();
  +        }
  +        return pointer;
  +    }
  +    
  +    public NodePointer getImmediateParentPointer() {
           return parent;
       }
   
  @@ -745,8 +753,8 @@
                       + pointer.getClass().getName()
                       + ")");
           }
  -        if (pointer.getParent() != null) {
  -            printDeep(pointer.getParent(), indent + "  ");
  +        if (pointer.getImmediateParentPointer() != null) {
  +            printDeep(pointer.getImmediateParentPointer(), indent + "  ");
           }
       }
   }
  
  
  
  1.18      +2 -2      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointer.java
  
  Index: CollectionPointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointer.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- CollectionPointer.java	29 Feb 2004 14:17:41 -0000	1.17
  +++ CollectionPointer.java	25 Mar 2004 03:49:50 -0000	1.18
  @@ -211,7 +211,7 @@
        */
       public String asPath() {
           StringBuffer buffer = new StringBuffer();
  -        NodePointer parent = getParent();
  +        NodePointer parent = getImmediateParentPointer();
           if (parent != null) {
               buffer.append(parent.asPath());
               if (index != WHOLE_COLLECTION) {
  
  
  
  1.17      +10 -8     jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/NullElementPointer.java
  
  Index: NullElementPointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/NullElementPointer.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- NullElementPointer.java	29 Feb 2004 14:17:41 -0000	1.16
  +++ NullElementPointer.java	25 Mar 2004 03:49:50 -0000	1.17
  @@ -87,7 +87,7 @@
       }
   
       public int hashCode() {
  -        return getParent().hashCode() + index;
  +        return getImmediateParentPointer().hashCode() + index;
       }
   
       public boolean equals(Object object) {
  @@ -100,7 +100,8 @@
           }
   
           NullElementPointer other = (NullElementPointer) object;
  -        return getParent() == other.getParent() && index == other.index;
  +        return getImmediateParentPointer() == other.getImmediateParentPointer() 
  +            && index == other.index;
       }
   
       public int getLength() {
  @@ -109,7 +110,7 @@
       
       public String asPath() {
           StringBuffer buffer = new StringBuffer();
  -        NodePointer parent = getParent();
  +        NodePointer parent = getImmediateParentPointer();
           if (parent != null) {
               buffer.append(parent.asPath());
           }
  @@ -118,10 +119,11 @@
               if (parent != null && parent.getIndex() != WHOLE_COLLECTION) {
                   buffer.append("/.");
               }
  -            else if (
  -                parent != null
  -                    && parent.getParent() != null
  -                    && parent.getParent().getIndex() != WHOLE_COLLECTION) {
  +            else if (parent != null
  +                    && parent.getImmediateParentPointer() != null
  +                    && parent.getImmediateParentPointer().getIndex() != 
  +                            WHOLE_COLLECTION) 
  +            {
                   buffer.append("/.");
               }
               buffer.append("[").append(index + 1).append(']');
  
  
  
  1.18      +2 -2      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/NullPropertyPointer.java
  
  Index: NullPropertyPointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/NullPropertyPointer.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- NullPropertyPointer.java	29 Feb 2004 14:17:41 -0000	1.17
  +++ NullPropertyPointer.java	25 Mar 2004 03:49:50 -0000	1.18
  @@ -190,7 +190,7 @@
           }
           else {
               StringBuffer buffer = new StringBuffer();
  -            buffer.append(getParent().asPath());
  +            buffer.append(getImmediateParentPointer().asPath());
               buffer.append("[@name='");
               buffer.append(escape(getPropertyName()));
               buffer.append("']");
  
  
  
  1.13      +3 -3      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyPointer.java
  
  Index: PropertyPointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyPointer.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- PropertyPointer.java	29 Feb 2004 14:17:41 -0000	1.12
  +++ PropertyPointer.java	25 Mar 2004 03:49:50 -0000	1.13
  @@ -57,7 +57,7 @@
   
       public Object getBean() {
           if (bean == null) {
  -            bean = getParent().getNode();
  +            bean = getImmediateParentPointer().getNode();
           }
           return bean;
       }
  @@ -189,7 +189,7 @@
       }
   
       public int hashCode() {
  -        return getParent().hashCode() + propertyIndex + index;
  +        return getImmediateParentPointer().hashCode() + propertyIndex + index;
       }
   
       public boolean equals(Object object) {
  
  
  
  1.13      +6 -4      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyIterator.java
  
  Index: PropertyIterator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyIterator.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- PropertyIterator.java	29 Feb 2004 14:17:41 -0000	1.12
  +++ PropertyIterator.java	25 Mar 2004 03:49:50 -0000	1.13
  @@ -55,8 +55,9 @@
               this.startIndex = -1;
           }
           if (startWith != null) {
  -            while (startWith != null && startWith.getParent() != pointer) {
  -                startWith = startWith.getParent();
  +            while (startWith != null 
  +                    && startWith.getImmediateParentPointer() != pointer) {
  +                startWith = startWith.getImmediateParentPointer();
               }
               if (startWith == null) {
                   throw new JXPathException(
  @@ -109,7 +110,8 @@
           catch (Throwable ex) {
               // @todo: should this exception be reported in any way?
               NullPropertyPointer npp =
  -                new NullPropertyPointer(propertyNodePointer.getParent());
  +                new NullPropertyPointer(
  +                        propertyNodePointer.getImmediateParentPointer());
               npp.setPropertyName(propertyNodePointer.getPropertyName());
               npp.setIndex(propertyNodePointer.getIndex());
               return npp.getValuePointer();
  
  
  
  1.40      +3 -2      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.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- JXPathContextReferenceImpl.java	2 Mar 2004 01:32:20 -0000	1.39
  +++ JXPathContextReferenceImpl.java	25 Mar 2004 03:49:50 -0000	1.40
  @@ -333,7 +333,8 @@
                   // 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();
  +                NodePointer parent = 
  +                    ((NodePointer) result).getImmediateParentPointer();
                   if (parent == null
                       || !parent.isContainer()
                       || !parent.isActual()) {
  
  
  
  1.7       +2 -2      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dynamic/DynamicPropertyPointer.java
  
  Index: DynamicPropertyPointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dynamic/DynamicPropertyPointer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DynamicPropertyPointer.java	29 Feb 2004 14:17:44 -0000	1.6
  +++ DynamicPropertyPointer.java	25 Mar 2004 03:49:50 -0000	1.7
  @@ -267,7 +267,7 @@
       
       public String asPath() {
           StringBuffer buffer = new StringBuffer();
  -        buffer.append(getParent().asPath());
  +        buffer.append(getImmediateParentPointer().asPath());
           if (buffer.length() == 0) {
               buffer.append("/.");
           }
  
  
  
  1.7       +3 -1      jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/axes/SimplePathInterpreterTest.java
  
  Index: SimplePathInterpreterTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/axes/SimplePathInterpreterTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SimplePathInterpreterTest.java	29 Feb 2004 14:17:42 -0000	1.6
  +++ SimplePathInterpreterTest.java	25 Mar 2004 03:49:50 -0000	1.7
  @@ -641,7 +641,9 @@
           else {
               System.err.println("UNKNOWN TYPE: " + pointer.getClass());
           }
  -        return pointerSignature(((NodePointer) pointer).getParent()) + type;
  +        NodePointer parent = 
  +            ((NodePointer) pointer).getImmediateParentPointer();
  +        return pointerSignature(parent) + type;
       }
   }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message