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 JXPathContext.java JXPathBeanInfo.java JXPathBasicBeanInfo.java JXPath.java ExpressionContext.java
Date Fri, 12 Apr 2002 02:28:07 GMT
dmitri      02/04/11 19:28:07

  Modified:    jxpath/src/java/org/apache/commons/jxpath/ri/pointers
                        VariablePointer.java PropertyPointer.java
                        PropertyOwnerPointer.java NodePointer.java
                        NamespacePointer.java LangAttributePointer.java
                        DynamicPointerFactory.java DOMNodePointer.java
                        ContainerPointer.java BeanPointerFactory.java
                        BeanAttributeIterator.java
               jxpath/src/test/org/apache/commons/jxpath
                        NestedTestBean.java
               jxpath/src/java/org/apache/commons/jxpath/ri
                        JXPathContextReferenceImpl.java EvalContext.java
               jxpath/src/java/org/apache/commons/jxpath JXPathContext.java
                        JXPathBeanInfo.java JXPathBasicBeanInfo.java
                        JXPath.java ExpressionContext.java
  Log:
  Removed dependency on DOM from everywhere except where needed
  
  Revision  Changes    Path
  1.5       +4 -9      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/VariablePointer.java
  
  Index: VariablePointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/VariablePointer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- VariablePointer.java	10 Apr 2002 03:40:20 -0000	1.4
  +++ VariablePointer.java	12 Apr 2002 02:28:06 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/VariablePointer.java,v
1.4 2002/04/10 03:40:20 dmitri Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/04/10 03:40:20 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/VariablePointer.java,v
1.5 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -62,19 +62,14 @@
   package org.apache.commons.jxpath.ri.pointers;
   
   import org.apache.commons.jxpath.*;
  -import org.apache.commons.jxpath.ri.Compiler;
   import org.apache.commons.jxpath.ri.compiler.*;
  -
  -import java.lang.reflect.*;
   import java.util.*;
  -import java.beans.*;
  -import org.w3c.dom.Node;
   
   /**
    * Pointer to a context variable.
    *
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.4 $ $Date: 2002/04/10 03:40:20 $
  + * @version $Revision: 1.5 $ $Date: 2002/04/12 02:28:06 $
    */
   public class VariablePointer extends NodePointer {
       private Variables variables;
  
  
  
  1.5       +8 -19     jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/PropertyPointer.java
  
  Index: PropertyPointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/PropertyPointer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PropertyPointer.java	10 Apr 2002 03:40:20 -0000	1.4
  +++ PropertyPointer.java	12 Apr 2002 02:28:06 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/PropertyPointer.java,v
1.4 2002/04/10 03:40:20 dmitri Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/04/10 03:40:20 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/PropertyPointer.java,v
1.5 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -62,17 +62,16 @@
   package org.apache.commons.jxpath.ri.pointers;
   
   import org.apache.commons.jxpath.*;
  -import org.apache.commons.jxpath.ri.Compiler;
   import org.apache.commons.jxpath.ri.compiler.*;
   
  -import java.lang.reflect.*;
   import java.util.*;
  -import java.beans.*;
  -import org.w3c.dom.Node;
   
   /**
  + * A pointer allocated by a PropertyOwnerPointer to represent the value of
  + * a property of the parent object.
  + *
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.4 $ $Date: 2002/04/10 03:40:20 $
  + * @version $Revision: 1.5 $ $Date: 2002/04/12 02:28:06 $
    */
   public abstract class PropertyPointer extends PropertyOwnerPointer {
       protected int propertyIndex = UNSPECIFIED_PROPERTY;
  @@ -124,22 +123,12 @@
           return super.isActual();
       }
   
  -
       /**
        * Returns a NodePointer that can be used to access the currently
        * selected property value.
        */
       public NodePointer childNodePointer(){
  -        Object bean = getValue();
  -
  -        if (bean instanceof Node){
  -            return new DOMNodePointer(this, (Node)bean);
  -        }
  -        else if (bean instanceof Container){
  -            return new ContainerPointer(this, (Container)bean);
  -        }
  -
  -        return (NodePointer)clone();
  +        return createNodePointer(this, null, getValue());
       }
   
       public int hashCode(){
  
  
  
  1.4       +5 -7      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/PropertyOwnerPointer.java
  
  Index: PropertyOwnerPointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/PropertyOwnerPointer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PropertyOwnerPointer.java	26 Sep 2001 01:21:54 -0000	1.3
  +++ PropertyOwnerPointer.java	12 Apr 2002 02:28:06 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/PropertyOwnerPointer.java,v
1.3 2001/09/26 01:21:54 dmitri Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/09/26 01:21:54 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/PropertyOwnerPointer.java,v
1.4 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -65,17 +65,15 @@
   import org.apache.commons.jxpath.ri.Compiler;
   import org.apache.commons.jxpath.ri.compiler.*;
   
  -import java.lang.reflect.*;
   import java.util.*;
  -import java.beans.*;
  -import org.w3c.dom.*;
  +
   
   /**
    * A pointer describing a node that has properties, each of which could be
    * a collection.
    *
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.3 $ $Date: 2001/09/26 01:21:54 $
  + * @version $Revision: 1.4 $ $Date: 2002/04/12 02:28:06 $
    */
   public abstract class PropertyOwnerPointer extends NodePointer {
   
  
  
  
  1.6       +14 -11    jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/NodePointer.java
  
  Index: NodePointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/NodePointer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- NodePointer.java	10 Apr 2002 03:40:20 -0000	1.5
  +++ NodePointer.java	12 Apr 2002 02:28:06 -0000	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/NodePointer.java,v
1.5 2002/04/10 03:40:20 dmitri Exp $
  - * $Revision: 1.5 $
  - * $Date: 2002/04/10 03:40:20 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/NodePointer.java,v
1.6 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.6 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -63,19 +63,16 @@
   
   import org.apache.commons.jxpath.*;
   import org.apache.commons.jxpath.ri.JXPathContextReferenceImpl;
  -import org.apache.commons.jxpath.ri.Compiler;
   import org.apache.commons.jxpath.ri.compiler.*;
  +import org.apache.commons.jxpath.functions.Types;
   
  -import java.lang.reflect.*;
   import java.util.*;
  -import java.beans.*;
  -import org.w3c.dom.Node;
   
   /**
    * Common superclass for Pointers of all kinds.
    *
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.5 $ $Date: 2002/04/10 03:40:20 $
  + * @version $Revision: 1.6 $ $Date: 2002/04/12 02:28:06 $
    */
   public abstract class NodePointer implements Pointer, Cloneable {
   
  @@ -98,9 +95,6 @@
       }
   
       public static NodePointer createNodePointer(NodePointer parent, QName name, Object
bean){
  -        if (bean == null){
  -            return new NullPointer(parent, name);
  -        }
           NodePointerFactory[] factories = JXPathContextReferenceImpl.getNodePointerFactories();
           for (int i = 0; i < factories.length; i++){
               NodePointer pointer = factories[i].createNodePointer(parent, name, bean);
  @@ -185,6 +179,15 @@
   
       public QName getExpandedName(){
           return getName();
  +    }
  +
  +    /**
  +     * By default, returns <code>getValue()</code>, can be overridden to
  +     * return a "canonical" value, like for instance a DOM element should
  +     * return its string value.
  +     */
  +    public Object getPrimitiveValue(){
  +        return getValue();
       }
   
       protected NodePointer parent;
  
  
  
  1.2       +3 -7      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/NamespacePointer.java
  
  Index: NamespacePointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/NamespacePointer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NamespacePointer.java	21 Sep 2001 23:22:45 -0000	1.1
  +++ NamespacePointer.java	12 Apr 2002 02:28:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/NamespacePointer.java,v
1.1 2001/09/21 23:22:45 dmitri Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/09/21 23:22:45 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/NamespacePointer.java,v
1.2 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -61,20 +61,16 @@
    */
   package org.apache.commons.jxpath.ri.pointers;
   
  -import org.apache.commons.jxpath.*;
   import org.apache.commons.jxpath.ri.Compiler;
   import org.apache.commons.jxpath.ri.compiler.*;
   
  -import java.lang.reflect.*;
   import java.util.*;
  -import java.beans.*;
  -import org.w3c.dom.*;
   
   /**
    * Represents a namespace node.
    *
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.1 $ $Date: 2001/09/21 23:22:45 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/12 02:28:06 $
    */
   public class NamespacePointer extends NodePointer {
       private String prefix;
  
  
  
  1.2       +4 -10     jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/LangAttributePointer.java
  
  Index: LangAttributePointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/LangAttributePointer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LangAttributePointer.java	26 Sep 2001 01:21:54 -0000	1.1
  +++ LangAttributePointer.java	12 Apr 2002 02:28:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/LangAttributePointer.java,v
1.1 2001/09/26 01:21:54 dmitri Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/09/26 01:21:54 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/LangAttributePointer.java,v
1.2 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -61,21 +61,15 @@
    */
   package org.apache.commons.jxpath.ri.pointers;
   
  -import org.apache.commons.jxpath.*;
  -import org.apache.commons.jxpath.ri.Compiler;
   import org.apache.commons.jxpath.ri.compiler.*;
  -
  -import java.lang.reflect.*;
   import java.util.*;
  -import java.beans.*;
  -import org.w3c.dom.*;
   
   /**
    * A Pointer that points to the "lang" attribute of a JavaBean. The value
    * of the attribute is based on the locale supplied to it in the constructor.
    *
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.1 $ $Date: 2001/09/26 01:21:54 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/12 02:28:06 $
    */
   public class LangAttributePointer extends NodePointer {
       public LangAttributePointer(NodePointer parent){
  
  
  
  1.2       +12 -4     jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/DynamicPointerFactory.java
  
  Index: DynamicPointerFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/DynamicPointerFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DynamicPointerFactory.java	10 Apr 2002 03:40:20 -0000	1.1
  +++ DynamicPointerFactory.java	12 Apr 2002 02:28:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/DynamicPointerFactory.java,v
1.1 2002/04/10 03:40:20 dmitri Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/04/10 03:40:20 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/DynamicPointerFactory.java,v
1.2 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -69,7 +69,7 @@
    * Implements NodePointerFactory for Dynamic classes like Map.
    *
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.1 $ $Date: 2002/04/10 03:40:20 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/12 02:28:06 $
    */
   public class DynamicPointerFactory implements NodePointerFactory {
   
  @@ -89,6 +89,14 @@
       }
   
       public NodePointer createNodePointer(NodePointer parent, QName name, Object bean){
  +        if (name == null && parent instanceof PropertyPointer){
  +            return (NodePointer)parent.clone();
  +        }
  +
  +        if (bean == null){
  +            return new NullPointer(parent, name);
  +        }
  +
           JXPathBeanInfo bi = JXPathIntrospector.getBeanInfo(bean.getClass());
           if (bi.isDynamic()){
               DynamicPropertyHandler handler = PropertyAccessHelper.getDynamicPropertyHandler(bi.getDynamicPropertyHandlerClass());
  
  
  
  1.6       +39 -4     jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/DOMNodePointer.java
  
  Index: DOMNodePointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/DOMNodePointer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DOMNodePointer.java	11 Apr 2002 02:59:42 -0000	1.5
  +++ DOMNodePointer.java	12 Apr 2002 02:28:06 -0000	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/DOMNodePointer.java,v
1.5 2002/04/11 02:59:42 dmitri Exp $
  - * $Revision: 1.5 $
  - * $Date: 2002/04/11 02:59:42 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/DOMNodePointer.java,v
1.6 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.6 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -74,7 +74,7 @@
    * A Pointer that points to a DOM node.
    *
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.5 $ $Date: 2002/04/11 02:59:42 $
  + * @version $Revision: 1.6 $ $Date: 2002/04/12 02:28:06 $
    */
   public class DOMNodePointer extends NodePointer {
       private Node node;
  @@ -444,5 +444,40 @@
           }
   
           return name.substring(index + 1);
  +    }
  +
  +    public Object getPrimitiveValue(){
  +        return stringValue(node);
  +    }
  +
  +    private String stringValue(Node node){
  +        int nodeType = node.getNodeType();
  +        if (nodeType == Node.COMMENT_NODE){
  +            String text = ((Comment)node).getData();
  +            return text == null ? "" : text.trim();
  +        }
  +        else if (nodeType == Node.TEXT_NODE ||
  +                nodeType == Node.CDATA_SECTION_NODE){
  +            String text = node.getNodeValue();
  +            return text == null ? "" : text.trim();
  +        }
  +        else if (nodeType == Node.PROCESSING_INSTRUCTION_NODE){
  +            String text = ((ProcessingInstruction)node).getData();
  +            return text == null ? "" : text.trim();
  +        }
  +        else {
  +            NodeList list = node.getChildNodes();
  +            StringBuffer buf = new StringBuffer(16);
  +            for(int i = 0; i < list.getLength();i++) {
  +                Node child = list.item(i);
  +                if (child.getNodeType() == Node.TEXT_NODE){
  +                    buf.append(child.getNodeValue());
  +                }
  +                else {
  +                    buf.append(stringValue(child));
  +                }
  +            }
  +            return buf.toString().trim();
  +        }
       }
   }
  
  
  
  1.5       +4 -9      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/ContainerPointer.java
  
  Index: ContainerPointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/ContainerPointer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ContainerPointer.java	10 Apr 2002 03:40:20 -0000	1.4
  +++ ContainerPointer.java	12 Apr 2002 02:28:06 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/ContainerPointer.java,v
1.4 2002/04/10 03:40:20 dmitri Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/04/10 03:40:20 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/ContainerPointer.java,v
1.5 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -62,13 +62,8 @@
   package org.apache.commons.jxpath.ri.pointers;
   
   import org.apache.commons.jxpath.*;
  -import org.apache.commons.jxpath.ri.Compiler;
   import org.apache.commons.jxpath.ri.compiler.*;
  -
  -import java.lang.reflect.*;
   import java.util.*;
  -import java.beans.*;
  -import org.w3c.dom.Node;
   
   /**
    * Transparent pointer to a Container. The getValue() method
  @@ -76,7 +71,7 @@
    * itself.
    *
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.4 $ $Date: 2002/04/10 03:40:20 $
  + * @version $Revision: 1.5 $ $Date: 2002/04/12 02:28:06 $
    */
   public class ContainerPointer extends NodePointer {
       private Container container;
  
  
  
  1.2       +12 -4     jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/BeanPointerFactory.java
  
  Index: BeanPointerFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/BeanPointerFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BeanPointerFactory.java	10 Apr 2002 03:40:20 -0000	1.1
  +++ BeanPointerFactory.java	12 Apr 2002 02:28:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/BeanPointerFactory.java,v
1.1 2002/04/10 03:40:20 dmitri Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/04/10 03:40:20 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/BeanPointerFactory.java,v
1.2 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -69,7 +69,7 @@
    * Implements NodePointerFactory for JavaBeans.
    *
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.1 $ $Date: 2002/04/10 03:40:20 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/12 02:28:06 $
    */
   public class BeanPointerFactory implements NodePointerFactory {
   
  @@ -85,6 +85,14 @@
       }
   
       public NodePointer createNodePointer(NodePointer parent, QName name, Object bean){
  +        if (name == null && parent instanceof PropertyPointer){
  +            return (NodePointer)parent.clone();
  +        }
  +
  +        if (bean == null){
  +            return new NullPointer(parent, name);
  +        }
  +
           JXPathBeanInfo bi = JXPathIntrospector.getBeanInfo(bean.getClass());
           return new BeanPointer(parent, name, bean, bi);
       }
  
  
  
  1.2       +4 -5      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/BeanAttributeIterator.java
  
  Index: BeanAttributeIterator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/BeanAttributeIterator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BeanAttributeIterator.java	26 Sep 2001 01:21:54 -0000	1.1
  +++ BeanAttributeIterator.java	12 Apr 2002 02:28:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/BeanAttributeIterator.java,v
1.1 2001/09/26 01:21:54 dmitri Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/09/26 01:21:54 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/pointers/BeanAttributeIterator.java,v
1.2 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -68,14 +68,13 @@
   import java.lang.reflect.*;
   import java.util.*;
   import java.beans.*;
  -import org.w3c.dom.*;
   
   /**
    * An iterator of attributes of a JavaBean. Currently supports only one
    * attribute - "lang".
    *
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.1 $ $Date: 2001/09/26 01:21:54 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/12 02:28:06 $
    */
   public class BeanAttributeIterator implements NodeIterator {
       private NodePointer parent;
  
  
  
  1.3       +4 -8      jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/NestedTestBean.java
  
  Index: NestedTestBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/NestedTestBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NestedTestBean.java	10 Apr 2002 03:40:21 -0000	1.2
  +++ NestedTestBean.java	12 Apr 2002 02:28:06 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/NestedTestBean.java,v
1.2 2002/04/10 03:40:21 dmitri Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/04/10 03:40:21 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/NestedTestBean.java,v
1.3 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -61,15 +61,11 @@
    */
   package org.apache.commons.jxpath;
   
  -import org.w3c.dom.*;
  -import java.beans.PropertyDescriptor;
  -import java.lang.reflect.*;
  -
   /**
    * A general purpose JavaBean for JUnit tests for the "jxpath" component.
    *
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.2 $ $Date: 2002/04/10 03:40:21 $
  + * @version $Revision: 1.3 $ $Date: 2002/04/12 02:28:06 $
    */
   public class NestedTestBean {
       private String name = "Name 0";
  
  
  
  1.8       +9 -10     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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JXPathContextReferenceImpl.java	10 Apr 2002 03:40:19 -0000	1.7
  +++ JXPathContextReferenceImpl.java	12 Apr 2002 02:28:06 -0000	1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java,v
1.7 2002/04/10 03:40:19 dmitri Exp $
  - * $Revision: 1.7 $
  - * $Date: 2002/04/10 03:40:19 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java,v
1.8 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.8 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -77,11 +77,10 @@
   import org.apache.commons.jxpath.ri.axes.*;
   import org.apache.commons.jxpath.functions.Types;
   import java.lang.ref.SoftReference;
  -import org.w3c.dom.*;
   
   /**
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.7 $ $Date: 2002/04/10 03:40:19 $
  + * @version $Revision: 1.8 $ $Date: 2002/04/12 02:28:06 $
    */
   public class JXPathContextReferenceImpl extends JXPathContext
   {
  @@ -196,11 +195,11 @@
               result = ctx.getContextNodePointer();
           }
   
  -        if (result instanceof Pointer){
  -            result = ((Pointer)result).getValue();
  -        }
  -        if (result instanceof Node){
  -            result = EvalContext.stringValue((Node)result);
  +//        if (result instanceof DOMNodePointer){
  +//            result = ((DOMNodePointer)result).stringValue();
  +//        }
  +        if (result instanceof NodePointer){
  +            result = ((NodePointer)result).getPrimitiveValue();
           }
           return result;
       }
  
  
  
  1.7       +22 -59    jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/EvalContext.java
  
  Index: EvalContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/EvalContext.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- EvalContext.java	10 Apr 2002 03:40:19 -0000	1.6
  +++ EvalContext.java	12 Apr 2002 02:28:06 -0000	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/EvalContext.java,v
1.6 2002/04/10 03:40:19 dmitri Exp $
  - * $Revision: 1.6 $
  - * $Date: 2002/04/10 03:40:19 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/EvalContext.java,v
1.7 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.7 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -70,7 +70,6 @@
   import org.apache.commons.jxpath.ExpressionContext;
   import org.apache.commons.jxpath.Pointer;
   import java.util.*;
  -import org.w3c.dom.*;
   
   /**
    * An XPath evaluation context.
  @@ -80,7 +79,7 @@
    * implement behavior of various XPath axes: "child::", "parent::" etc.
    *
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.6 $ $Date: 2002/04/10 03:40:19 $
  + * @version $Revision: 1.7 $ $Date: 2002/04/12 02:28:06 $
    */
   public abstract class EvalContext {
       protected EvalContext parentContext;
  @@ -546,11 +545,11 @@
               }
           }
   
  -        if (l instanceof Pointer){
  -            l = ((Pointer)l).getValue();
  +        if (l instanceof NodePointer){
  +            l = ((NodePointer)l).getPrimitiveValue();
           }
  -        if (r instanceof Pointer){
  -            r = ((Pointer)r).getValue();
  +        if (r instanceof NodePointer){
  +            r = ((NodePointer)r).getPrimitiveValue();
           }
   
           if (l instanceof Boolean || r instanceof Boolean){
  @@ -578,8 +577,8 @@
           HashSet set = new HashSet();
           while(nextSet()){
               while(next()){
  -                Pointer pointer = getCurrentNodePointer();
  -                set.add(pointer.getValue());
  +                NodePointer pointer = getCurrentNodePointer();
  +                set.add(pointer.getPrimitiveValue());
               }
           }
           return set;
  @@ -625,39 +624,8 @@
           else if (object == null){
               return "";
           }
  -        else if (object instanceof Node){
  -            Node node = (Node)object;
  -            int nodeType = node.getNodeType();
  -            if (nodeType == Node.COMMENT_NODE){
  -                String text = ((Comment)node).getData();
  -                return text == null ? "" : text.trim();
  -            }
  -            else if (nodeType == Node.TEXT_NODE ||
  -                    nodeType == Node.CDATA_SECTION_NODE){
  -                String text = node.getNodeValue();
  -                return text == null ? "" : text.trim();
  -            }
  -            else if (nodeType == Node.PROCESSING_INSTRUCTION_NODE){
  -                String text = ((ProcessingInstruction)node).getData();
  -                return text == null ? "" : text.trim();
  -            }
  -            else {
  -                NodeList list = node.getChildNodes();
  -                StringBuffer buf = new StringBuffer(16);
  -                for(int i = 0; i < list.getLength();i++) {
  -                    Node child = list.item(i);
  -                    if (child.getNodeType() == Node.TEXT_NODE){
  -                        buf.append(child.getNodeValue());
  -                    }
  -                    else {
  -                        buf.append(stringValue(child));
  -                    }
  -                }
  -                return buf.toString().trim();
  -            }
  -        }
           else if (object instanceof NodePointer){
  -            return stringValue(((NodePointer)object).getValue());
  +            return stringValue(((NodePointer)object).getPrimitiveValue());
           }
           else if (object instanceof EvalContext){
               EvalContext ctx = (EvalContext)object;
  @@ -690,15 +658,16 @@
               }
               return value;
           }
  -        else if (object instanceof Node){
  -            return number(stringValue(object));
  -        }
           else if (object instanceof EvalContext){
               return number(stringValue(object));
           }
           else if (object instanceof NodePointer){
  -            return number(((NodePointer)object).getValue());
  +            return number(((NodePointer)object).getPrimitiveValue());
           }
  +//        else if (object instanceof Node){
  +//            System.err.println("HERE");
  +//            return number(stringValue(object));
  +//        }
           return ZERO;
       }
   
  @@ -726,11 +695,8 @@
               }
               return value;
           }
  -        else if (object instanceof Node){
  -            return doubleValue(stringValue(object));
  -        }
           else if (object instanceof NodePointer){
  -            return doubleValue(((NodePointer)object).getValue());
  +            return doubleValue(((NodePointer)object).getPrimitiveValue());
           }
           else if (object instanceof EvalContext){
               return doubleValue(stringValue(object));
  @@ -756,11 +722,8 @@
           else if (object instanceof String){
               return ((String)object).length() != 0;
           }
  -        else if (object instanceof Node){
  -            return stringValue(object).length() != 0;
  -        }
           else if (object instanceof NodePointer){
  -            return booleanValue(((NodePointer)object).getValue());
  +            return booleanValue(((NodePointer)object).getPrimitiveValue());
           }
           return false;
       }
  @@ -839,8 +802,8 @@
                   if (predicate instanceof EvalContext){
                       predicate = ((EvalContext)predicate).getContextNodePointer();
                   }
  -                if (predicate instanceof Pointer){
  -                    predicate = ((Pointer)predicate).getValue();
  +                if (predicate instanceof NodePointer){
  +                    predicate = ((NodePointer)predicate).getPrimitiveValue();
                   }
                   if (predicate == null){
                       throw new RuntimeException("Predicate is null: " + predicates[i]);
  @@ -1110,8 +1073,8 @@
           Expression arg1 = function.getArg1();
           int count = 0;
           Object value = eval(arg1, false);
  -        if (value instanceof Pointer){
  -            value = ((Pointer)value).getValue();
  +        if (value instanceof NodePointer){
  +            value = ((NodePointer)value).getPrimitiveValue();
           }
           if (value instanceof EvalContext){
               EvalContext ctx = (EvalContext)value;
  
  
  
  1.6       +4 -5      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathContext.java
  
  Index: JXPathContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathContext.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JXPathContext.java	10 Apr 2002 03:40:19 -0000	1.5
  +++ JXPathContext.java	12 Apr 2002 02:28:06 -0000	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathContext.java,v
1.5 2002/04/10 03:40:19 dmitri Exp $
  - * $Revision: 1.5 $
  - * $Date: 2002/04/10 03:40:19 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathContext.java,v
1.6 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.6 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -62,7 +62,6 @@
   package org.apache.commons.jxpath;
   
   import java.util.List;
  -import org.w3c.dom.Node;
   import java.util.Locale;
   
   /**
  @@ -406,7 +405,7 @@
    * Also see <a href="http://www.w3.org/TR/xpath">XML Path Language (XPath) Version
1.0 </a>
    *
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.5 $ $Date: 2002/04/10 03:40:19 $
  + * @version $Revision: 1.6 $ $Date: 2002/04/12 02:28:06 $
    */
   public abstract class JXPathContext {
       protected JXPathContext parentContext;
  
  
  
  1.2       +3 -4      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathBeanInfo.java
  
  Index: JXPathBeanInfo.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathBeanInfo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JXPathBeanInfo.java	23 Aug 2001 00:46:58 -0000	1.1
  +++ JXPathBeanInfo.java	12 Apr 2002 02:28:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathBeanInfo.java,v
1.1 2001/08/23 00:46:58 dmitri Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/08/23 00:46:58 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathBeanInfo.java,v
1.2 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -61,7 +61,6 @@
    */
   package org.apache.commons.jxpath;
   
  -import org.w3c.dom.*;
   import java.beans.PropertyDescriptor;
   
   /**
  @@ -76,7 +75,7 @@
    * "com.foo.BarXBeanInfo" and make it implement the JXPathBeanInfo interface.
    *
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.1 $ $Date: 2001/08/23 00:46:58 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/12 02:28:06 $
    */
   public interface JXPathBeanInfo  {
   
  
  
  
  1.2       +3 -4      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathBasicBeanInfo.java
  
  Index: JXPathBasicBeanInfo.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathBasicBeanInfo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JXPathBasicBeanInfo.java	23 Aug 2001 00:46:58 -0000	1.1
  +++ JXPathBasicBeanInfo.java	12 Apr 2002 02:28:06 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathBasicBeanInfo.java,v
1.1 2001/08/23 00:46:58 dmitri Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/08/23 00:46:58 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathBasicBeanInfo.java,v
1.2 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -61,7 +61,6 @@
    */
   package org.apache.commons.jxpath;
   
  -import org.w3c.dom.*;
   import java.beans.*;
   import java.util.*;
   
  @@ -73,7 +72,7 @@
    * See java.beans.BeanInfo, java.beans.Introspector
    *
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.1 $ $Date: 2001/08/23 00:46:58 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/12 02:28:06 $
    */
   public class JXPathBasicBeanInfo implements JXPathBeanInfo {
       private boolean atomic = false;
  
  
  
  1.3       +4 -5      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPath.java
  
  Index: JXPath.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPath.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JXPath.java	10 Apr 2002 03:40:19 -0000	1.2
  +++ JXPath.java	12 Apr 2002 02:28:06 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPath.java,v
1.2 2002/04/10 03:40:19 dmitri Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/04/10 03:40:19 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPath.java,v
1.3 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -62,7 +62,6 @@
   package org.apache.commons.jxpath;
   
   import java.util.List;
  -import org.w3c.dom.Node;
   
   /**
    * This class defines convenience methods for XPath traversal. Each method
  @@ -80,7 +79,7 @@
    * </ul>
    *
    * @author Dmitri Plotnikov
  - * @version $Revision: 1.2 $ $Date: 2002/04/10 03:40:19 $
  + * @version $Revision: 1.3 $ $Date: 2002/04/12 02:28:06 $
    */
   public final class JXPath {
   
  
  
  
  1.3       +3 -4      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ExpressionContext.java
  
  Index: ExpressionContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ExpressionContext.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ExpressionContext.java	10 Apr 2002 03:40:19 -0000	1.2
  +++ ExpressionContext.java	12 Apr 2002 02:28:06 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ExpressionContext.java,v
1.2 2002/04/10 03:40:19 dmitri Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/04/10 03:40:19 $
  + * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ExpressionContext.java,v
1.3 2002/04/12 02:28:06 dmitri Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/04/12 02:28:06 $
    *
    * ====================================================================
    * The Apache Software License, Version 1.1
  @@ -61,7 +61,6 @@
    */
   package org.apache.commons.jxpath;
   
  -import org.w3c.dom.Node;
   import java.util.*;
   
   /**
  
  
  

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