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 Pointer.java PackageFunctions.java JXPathContext.java JXPathBasicBeanInfo.java Functions.java DynamicPropertyHandler.java Container.java CompiledExpression.java ClassFunctions.java AbstractFactory.java JXPathContextFactory.xalan.readme.txt JXPath.java
Date Sun, 16 Jun 2002 03:22:22 GMT
dmitri      2002/06/15 20:22:22

  Modified:    jxpath/src/java/org/apache/commons/jxpath/util
                        ValueUtils.java TypeUtils.java
                        BasicTypeConverter.java
               jxpath/src/java/org/apache/commons/jxpath/ri QName.java
                        JXPathCompiledExpression.java InfoSetUtil.java
                        EvalContext.java
               jxpath/src/java/org/apache/commons/jxpath/ri/model/beans
                        PropertyIterator.java
               jxpath/src/java/org/apache/commons/jxpath Pointer.java
                        PackageFunctions.java JXPathContext.java
                        JXPathBasicBeanInfo.java Functions.java
                        DynamicPropertyHandler.java Container.java
                        CompiledExpression.java ClassFunctions.java
                        AbstractFactory.java
  Removed:     jxpath/src/java/org/apache/commons/jxpath
                        JXPathContextFactory.xalan.readme.txt JXPath.java
  Log:
  Documentation clean-up and removal of deprecated methods
  
  Revision  Changes    Path
  1.6       +119 -72   jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/ValueUtils.java
  
  Index: ValueUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/ValueUtils.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ValueUtils.java	8 May 2002 23:03:28 -0000	1.5
  +++ ValueUtils.java	16 Jun 2002 03:22:21 -0000	1.6
  @@ -70,20 +70,17 @@
   import org.apache.commons.jxpath.DynamicPropertyHandler;
   
   /**
  + * Collection and property access utilities.
  + *
    * @author Dmitri Plotnikov
    * @version $Revision$ $Date$
    */
   public class ValueUtils {
       private static Map dynamicPropertyHandlerMap = new HashMap();
   
  -    public static boolean isCollection(PropertyDescriptor propertyDescriptor){
  -        return false;
  -    }
  -
  -    public static boolean isCollection(PropertyDescriptor propertyDescriptor, Object value){
  -        return isCollection(value);
  -    }
  -
  +    /**
  +     * Returns true if the object is an array or a Collection
  +     */
       public static boolean isCollection(Object value){
           if (value == null){
               return false;
  @@ -97,11 +94,10 @@
           return false;
       }
   
  -    public static int getLength(Object bean, PropertyDescriptor propertyDescriptor){
  -        Object obj = getValue(bean, propertyDescriptor);
  -        return getLength(obj);
  -    }
  -
  +    /**
  +     * Returns the length of the supplied collection. If the supplied object
  +     * is not a collection, returns 1. If collection is null, returns 0.
  +     */
       public static int getLength(Object collection){
           if (collection == null){
               return 0;
  @@ -117,6 +113,11 @@
           }
       }
   
  +    /**
  +     * Returns an iterator for the supplied collection. If the argument
  +     * is null, returns an empty iterator. If the argument is not
  +     * a collection, returns an iterator that produces just that one object.
  +     */
       public static Iterator iterate(Object collection){
           if (collection == null){
               return Collections.EMPTY_LIST.iterator();
  @@ -140,13 +141,19 @@
           }
       }
   
  +    /**
  +     * Grows the collection if necessary to the specified size. Returns
  +     * the new, expanded collection.
  +     */
       public static Object expandCollection(Object collection, int size){
           if (collection == null){
               return null;
           }
           else if (collection.getClass().isArray()){
  -            Object bigger = Array.newInstance(collection.getClass().getComponentType(),
size);
  -            System.arraycopy(collection, 0, bigger, 0, Array.getLength(collection));
  +            Object bigger = Array.newInstance(
  +                  collection.getClass().getComponentType(), size);
  +            System.arraycopy(
  +                  collection, 0, bigger, 0, Array.getLength(collection));
               return bigger;
           }
           else if (collection instanceof Collection){
  @@ -161,13 +168,17 @@
           }
       }
   
  +    /**
  +     * Returns the index'th element from the supplied collection.
  +     */
       public static Object remove(Object collection, int index){
           if (collection == null){
               return null;
           }
           else if (collection.getClass().isArray()){
               int length = Array.getLength(collection);
  -            Object smaller = Array.newInstance(collection.getClass().getComponentType(),
length-1);
  +            Object smaller = Array.newInstance(
  +                  collection.getClass().getComponentType(), length-1);
               if (index > 0){
                   System.arraycopy(collection, 0, smaller, 0, index);
               }
  @@ -204,48 +215,9 @@
           }
       }
   
  -    public static Object getValue(Object bean, PropertyDescriptor propertyDescriptor, int
index){
  -        if (propertyDescriptor instanceof IndexedPropertyDescriptor){
  -            Object value;
  -            try {
  -                IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor)propertyDescriptor;
  -                Method method = ipd.getIndexedReadMethod();
  -                if (method != null){
  -                    return method.invoke(bean, new Object[]{new Integer(index)});
  -                }
  -            }
  -            catch (Exception ex){
  -                throw new JXPathException(
  -                    "Cannot access property: " + propertyDescriptor.getName(),
  -                    ex);
  -            }
  -        }
  -        // We will fall through if there is no indexed read
  -
  -        return getValue(getValue(bean, propertyDescriptor), index);
  -    }
  -
  -    public static void setValue(Object bean, PropertyDescriptor propertyDescriptor, int
index, Object value){
  -        if (propertyDescriptor instanceof IndexedPropertyDescriptor){
  -            try {
  -                IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor)propertyDescriptor;
  -                Method method = ipd.getIndexedWriteMethod();
  -                if (method != null){
  -                    method.invoke(bean,
  -                        new Object[]{new Integer(index),
  -                                     convert(value, ipd.getIndexedPropertyType())});
  -                    return;
  -                }
  -            }
  -            catch (Exception ex){
  -                throw new RuntimeException("Cannot access property: " + propertyDescriptor.getName()
+
  -                    ", " + ex.getMessage());
  -            }
  -        }
  -        // We will fall through if there is no indexed read
  -        setValue(getValue(bean, propertyDescriptor), index, value);
  -    }
  -
  +    /**
  +     * Returns the index'th element of the supplied collection.
  +     */
       public static Object getValue(Object collection, int index){
           Object value = collection;
           if (collection != null){
  @@ -278,25 +250,37 @@
           return value;
       }
   
  +    /**
  +     * Modifies the index'th element of the supplied collection.
  +     * Converts the value to the required type if necessary.
  +     */
       public static void setValue(Object collection, int index, Object value){
           if (collection != null){
               if (collection.getClass().isArray()){
  -                Array.set(collection, index, convert(value, collection.getClass().getComponentType()));
  +                Array.set(collection, index,
  +                    convert(value, collection.getClass().getComponentType()));
               }
               else if (collection instanceof List){
                   ((List)collection).set(index, value);
               }
               else if (collection instanceof Collection){
  -                throw new UnsupportedOperationException("Cannot set value of an element
of a " +
  +                throw new UnsupportedOperationException(
  +                        "Cannot set value of an element of a " +
                           collection.getClass().getName());
               }
           }
       }
   
  -    public static Object getValue(Object bean, PropertyDescriptor propertyDescriptor){
  +    /**
  +     * Returns the value of the bean's property represented by
  +     * the supplied property descriptor.
  +     */
  +    public static Object getValue(Object bean,
  +                    PropertyDescriptor propertyDescriptor){
           Object value;
           try {
  -            Method method = getAccessibleMethod(propertyDescriptor.getReadMethod());
  +            Method method =
  +                getAccessibleMethod(propertyDescriptor.getReadMethod());
               if (method == null){
                   throw new JXPathException("No read method");
               }
  @@ -309,9 +293,15 @@
           return value;
       }
   
  -    public static void setValue(Object bean, PropertyDescriptor propertyDescriptor, Object
value){
  +    /**
  +     * Modifies the value of the bean's property represented by
  +     * the supplied property descriptor.
  +     */
  +    public static void setValue(Object bean,
  +            PropertyDescriptor propertyDescriptor, Object value){
           try {
  -            Method method = getAccessibleMethod(propertyDescriptor.getWriteMethod());
  +            Method method =
  +                getAccessibleMethod(propertyDescriptor.getWriteMethod());
               if (method == null){
                   throw new JXPathException("No write method");
               }
  @@ -337,11 +327,68 @@
       }
   
       /**
  +     * Returns the index'th element of the bean's property represented by
  +     * the supplied property descriptor.
  +     */
  +    public static Object getValue(Object bean,
  +            PropertyDescriptor propertyDescriptor, int index){
  +        if (propertyDescriptor instanceof IndexedPropertyDescriptor){
  +            Object value;
  +            try {
  +                IndexedPropertyDescriptor ipd =
  +                    (IndexedPropertyDescriptor)propertyDescriptor;
  +                Method method = ipd.getIndexedReadMethod();
  +                if (method != null){
  +                    return method.invoke(bean, new Object[]{new Integer(index)});
  +                }
  +            }
  +            catch (Exception ex){
  +                throw new JXPathException(
  +                    "Cannot access property: " + propertyDescriptor.getName(),
  +                    ex);
  +            }
  +        }
  +
  +        // We will fall through if there is no indexed read
  +
  +        return getValue(getValue(bean, propertyDescriptor), index);
  +    }
  +
  +    /**
  +     * Modifies the index'th element of the bean's property represented by
  +     * the supplied property descriptor. Converts the value to the required
  +     * type if necessary.
  +     */
  +    public static void setValue(Object bean,
  +              PropertyDescriptor propertyDescriptor, int index, Object value){
  +        if (propertyDescriptor instanceof IndexedPropertyDescriptor){
  +            try {
  +                IndexedPropertyDescriptor ipd =
  +                      (IndexedPropertyDescriptor)propertyDescriptor;
  +                Method method = ipd.getIndexedWriteMethod();
  +                if (method != null){
  +                    method.invoke(bean,
  +                        new Object[]{new Integer(index),
  +                                     convert(value, ipd.getIndexedPropertyType())});
  +                    return;
  +                }
  +            }
  +            catch (Exception ex){
  +                throw new RuntimeException("Cannot access property: " +
  +                    propertyDescriptor.getName() + ", " + ex.getMessage());
  +            }
  +        }
  +        // We will fall through if there is no indexed read
  +        setValue(getValue(bean, propertyDescriptor), index, value);
  +    }
  +
  +    /**
        * Returns a shared instance of the dynamic property handler class
        * returned by <code>getDynamicPropertyHandlerClass()</code>.
        */
  -    public static DynamicPropertyHandler getDynamicPropertyHandler(Class clazz) {
  -        DynamicPropertyHandler handler = (DynamicPropertyHandler)dynamicPropertyHandlerMap.get(clazz);
  +    public static DynamicPropertyHandler getDynamicPropertyHandler(Class clazz){
  +        DynamicPropertyHandler handler =
  +            (DynamicPropertyHandler)dynamicPropertyHandlerMap.get(clazz);
           if (handler == null){
               try {
                   handler = (DynamicPropertyHandler)clazz.newInstance();
  @@ -359,8 +406,8 @@
       // -------------------------------------------------------- Private Methods
       //
       //  The rest of the code in this file was copied FROM
  -    //  org.apache.commons.beanutils.PropertyUtil. We don't want to introduce a dependency
  -    //  on BeanUtils yet - DP.
  +    //  org.apache.commons.beanutils.PropertyUtil. We don't want to introduce
  +    //  a dependency on BeanUtils yet - DP.
       //
   
       /**
  
  
  
  1.8       +10 -23    jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/TypeUtils.java
  
  Index: TypeUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/TypeUtils.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TypeUtils.java	12 Jun 2002 21:02:05 -0000	1.7
  +++ TypeUtils.java	16 Jun 2002 03:22:21 -0000	1.8
  @@ -92,30 +92,17 @@
       }
   
       /**
  -     * @deprecated Use MethodLookupUtils
  +     * Returns true if the global converter can convert the supplied
  +     * object to the specified type.
        */
  -    public static Constructor lookupConstructor(Class targetClass, Object[] parameters){
  -        return MethodLookupUtils.lookupConstructor(targetClass, parameters);
  -    }
  -
  -    /**
  -     * @deprecated Use MethodLookupUtils
  -     */
  -    public static Method lookupStaticMethod(Class targetClass, String name, Object[] parameters){
  -        return MethodLookupUtils.lookupStaticMethod(targetClass, name, parameters);
  -    }
  -
  -    /**
  -     * @deprecated Use MethodLookupUtils
  -     */
  -    public static Method lookupMethod(Class targetClass, String name, Object[] parameters){
  -        return MethodLookupUtils.lookupMethod(targetClass, name, parameters);
  -    }
  -
       public static boolean canConvert(Object object, Class toType){
           return typeConverter.canConvert(object, toType);
       }
   
  +    /**
  +     * Converts the supplied object to the specified type. May
  +     * throw a RuntimeException.
  +     */
       public static Object convert(Object object, Class toType){
           return typeConverter.convert(object, toType);
       }
  
  
  
  1.2       +5 -5      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/BasicTypeConverter.java
  
  Index: BasicTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/BasicTypeConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BasicTypeConverter.java	12 Jun 2002 21:02:05 -0000	1.1
  +++ BasicTypeConverter.java	16 Jun 2002 03:22:21 -0000	1.2
  @@ -68,7 +68,7 @@
   import java.lang.reflect.*;
   
   /**
  - * The default delegate of JXPathContext that is used for type conversion.
  + * The default implementation of TypeConverter.
    *
    * @author Dmitri Plotnikov
    * @version $Revision$ $Date$
  
  
  
  1.3       +7 -5      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/QName.java
  
  Index: QName.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/QName.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- QName.java	24 Apr 2002 04:05:40 -0000	1.2
  +++ QName.java	16 Jun 2002 03:22:21 -0000	1.3
  @@ -62,6 +62,9 @@
   package org.apache.commons.jxpath.ri;
   
   /**
  + * A qualified name: a combination of an optional namespace prefix
  + * and an local name.
  + *
    * @author Dmitri Plotnikov
    * @version $Revision$ $Date$
    */
  @@ -112,5 +115,4 @@
   
           return true;
       }
  -
   }
  
  
  
  1.4       +11 -10    jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/JXPathCompiledExpression.java
  
  Index: JXPathCompiledExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/JXPathCompiledExpression.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JXPathCompiledExpression.java	9 Jun 2002 01:58:41 -0000	1.3
  +++ JXPathCompiledExpression.java	16 Jun 2002 03:22:21 -0000	1.4
  @@ -107,18 +107,19 @@
       }
   
       /**
  -     * @see CompiledExpression#createPath(JXPathContext, Object)
  +     * @see CompiledExpression#createPath(JXPathContext)
        */
  -    public Pointer createPathAndSetValue(JXPathContext context, Object value) {
  +    public Pointer createPath(JXPathContext context) {
           return ((JXPathContextReferenceImpl)context).
  -                    createPathAndSetValue(xpath, expression, value);
  +                    createPath(xpath, expression);
       }
   
       /**
  -     * @deprecated use createPathAndSetValue
  +     * @see CompiledExpression#createPathAndSetValue(JXPathContext, Object)
        */
  -    public void createPath(JXPathContext context, Object value) {
  -        createPathAndSetValue(context, value);
  +    public Pointer createPathAndSetValue(JXPathContext context, Object value) {
  +        return ((JXPathContextReferenceImpl)context).
  +                    createPathAndSetValue(xpath, expression, value);
       }
   
       /**
  
  
  
  1.3       +6 -4      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/InfoSetUtil.java
  
  Index: InfoSetUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/InfoSetUtil.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InfoSetUtil.java	8 Jun 2002 22:43:15 -0000	1.2
  +++ InfoSetUtil.java	16 Jun 2002 03:22:21 -0000	1.3
  @@ -65,6 +65,8 @@
   import org.apache.commons.jxpath.ri.model.NodePointer;
   
   /**
  + * Type conversions, XPath style.
  + *
    * @author Dmitri Plotnikov
    * @version $Revision$ $Date$
    */
  
  
  
  1.16      +9 -29     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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- EvalContext.java	29 May 2002 00:41:33 -0000	1.15
  +++ EvalContext.java	16 Jun 2002 03:22:21 -0000	1.16
  @@ -222,7 +222,8 @@
       }
   
       /**
  -     * Returns the list of all Pointers in this context
  +     * Returns the list of all Pointers in this context for the current
  +     * position of the parent context.
        */
       public List getContextNodeList() {
           int pos = position;
  @@ -243,7 +244,8 @@
       }
   
       /**
  -     * Returns the list of all node values in this context
  +     * Returns the list of all Pointers in this context for all positions
  +     * of the parent contexts.
        */
       public List getPointerList() {
           int pos = position;
  @@ -265,29 +267,6 @@
           return list;
       }
   
  -    /**
  -     * Returns the list of all node values in this context
  -     */
  -    public List getValueList() {
  -        int pos = position;
  -        if (pos != 0) {
  -            reset();
  -        }
  -        List list = new ArrayList();
  -        while (nextSet()){
  -            while (nextNode()) {
  -                list.add(getCurrentNodePointer().getValue());
  -            }
  -        }
  -        if (pos != 0) {
  -            setPosition(pos);
  -        }
  -        else {
  -            reset();
  -        }
  -        return list;
  -    }
  -
       public String toString() {
           Pointer ptr = getContextNodePointer();
           if (ptr == null) {
  @@ -297,6 +276,7 @@
               return "Expression context [" + getPosition() + "] " + ptr.asPath();
           }
       }
  +
       /**
        * Returns the root context of the path, which provides easy
        * access to variables and functions.
  
  
  
  1.4       +4 -6      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PropertyIterator.java	26 Apr 2002 03:28:37 -0000	1.3
  +++ PropertyIterator.java	16 Jun 2002 03:22:22 -0000	1.4
  @@ -270,7 +270,6 @@
   
           String names[] = propertyNodePointer.getPropertyNames();
           if (!reverse){
  -//            int startPropertyIndex = propertyNodePointer.getPropertyIndex();
               if (startPropertyIndex == PropertyPointer.UNSPECIFIED_PROPERTY){
                   startPropertyIndex = 0;
               }
  @@ -290,7 +289,6 @@
               }
           }
           else {
  -//            int startPropertyIndex = propertyNodePointer.getPropertyIndex();
               if (startPropertyIndex == PropertyPointer.UNSPECIFIED_PROPERTY){
                   startPropertyIndex = names.length - 1;
               }
  
  
  
  1.3       +11 -11    jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/Pointer.java
  
  Index: Pointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/Pointer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Pointer.java	24 Apr 2002 03:29:33 -0000	1.2
  +++ Pointer.java	16 Jun 2002 03:22:22 -0000	1.3
  @@ -64,13 +64,13 @@
   /**
    * Pointers represent locations of objects and their properties
    * in Java object graphs. JXPathContext has methods
  - * ({@link JXPathContext#locate(java.lang.String) locate()}
  - * and ({@link JXPathContext#locateValue(java.lang.String) locateValue()}
  - * that, given an XPath, produce Pointers for the objects or properties
  - * described the the path. For example, <code>ctx.locateValue("foo/bar")</code>
  + * ({@link JXPathContext#getPointer(java.lang.String) getPointer()}
  + * and ({@link JXPathContext#iteratePointers(java.lang.String) iteratePointers()},
  + * which, given an XPath, produce Pointers for the objects or properties
  + * described the the path. For example, <code>ctx.getPointer("foo/bar")</code>
    * will produce a Pointer that can get and set the property "bar" of
    * the object which is the value of the property "foo" of the root object.
  - * The value of <code>ctx.locateValue("aMap/aKey[3]")</code> will be a pointer
  + * The value of <code>ctx.getPointer("aMap/aKey[3]")</code> will be a pointer
    * to the 3'rd element of the array, which is the value for the key "aKey" of
    * the map, which is the value of the property "aMap" of the root object.
    *
  @@ -92,9 +92,9 @@
       void setValue(Object value);
   
       /**
  -     * Returns a string that is a proper XPath that corresponds to
  +     * Returns a string that is a proper "canonical" XPath that corresponds to
        * this pointer.  Consider this example:
  -     * <p><code>Pointer ptr = ctx.locateValue("//employees[firstName = 'John']")</code>
  +     * <p><code>Pointer ptr = ctx.getPointer("//employees[firstName = 'John']")</code>
        * <p>The value of <code>ptr.asPath()</code> will look something
like
        * <code>"/departments[2]/employees[3]"</code>, so, basically, it represents
the
        * concrete location(s) of the result of a search performed by JXPath.
  
  
  
  1.6       +10 -8     jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/PackageFunctions.java
  
  Index: PackageFunctions.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/PackageFunctions.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PackageFunctions.java	26 Apr 2002 03:28:36 -0000	1.5
  +++ PackageFunctions.java	16 Jun 2002 03:22:22 -0000	1.6
  @@ -68,7 +68,7 @@
   
   import org.apache.commons.jxpath.functions.ConstructorFunction;
   import org.apache.commons.jxpath.functions.MethodFunction;
  -import org.apache.commons.jxpath.util.TypeUtils;
  +import org.apache.commons.jxpath.util.MethodLookupUtils;
   
   /**
    * Extension functions provided by Java classes.  The class prefix specified
  @@ -170,7 +170,8 @@
                   }
               }
               if (target != null) {
  -                Method method = TypeUtils.lookupMethod(target.getClass(), name, parameters);
  +                Method method = MethodLookupUtils.
  +                    lookupMethod(target.getClass(), name, parameters);
                   if (method != null) {
                       return new MethodFunction(method);
                   }
  @@ -198,14 +199,15 @@
   
           if (methodName.endsWith("new")) {
               Constructor constructor =
  -                TypeUtils.lookupConstructor(functionClass, parameters);
  +                MethodLookupUtils.lookupConstructor(functionClass, parameters);
               if (constructor != null) {
                   return new ConstructorFunction(constructor);
               }
           }
           else {
               Method method =
  -                TypeUtils.lookupStaticMethod(functionClass, methodName, parameters);
  +                MethodLookupUtils.
  +                    lookupStaticMethod(functionClass, methodName, parameters);
               if (method != null) {
                   return new MethodFunction(method);
               }
  
  
  
  1.11      +40 -59    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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JXPathContext.java	8 Jun 2002 22:47:24 -0000	1.10
  +++ JXPathContext.java	16 Jun 2002 03:22:22 -0000	1.11
  @@ -74,7 +74,8 @@
    * allocating JXPathContext directly, you should call a static <code>newContext</code>
    * method.  This method will utilize the JXPathContextFactory API to locate
    * a suitable implementation of JXPath.
  - * JXPath comes bundled with a default implementation called Reference Implementation.
  + * Bundled with JXPath comes a default implementation called
  + * Reference Implementation.
    * </p>
    *
    * <h2>JXPath Interprets XPath Syntax on Java Object Graphs</h2>
  @@ -396,12 +397,15 @@
    *     like "para[@type='warning']" are legitimate, they will always produce empty results.
    *     The only attribute supported for JavaBeans is "name".  The XPath "foo/bar" is
    *     equivalent to "foo[@name='bar']".
  - * <li>The current version of JXPath does not support the <code>id(string)</code>
  - *     and <code>key(key, value)</code> XPath functions.
    * </ul>
    *
    * See <a href="http://www.w3schools.com/xpath">XPath Tutorial by W3Schools</a><br>
  - * Also see <a href="http://www.w3.org/TR/xpath">XML Path Language (XPath) Version
1.0 </a>
  + * Also see <a href="http://www.w3.org/TR/xpath">XML Path Language (XPath)
  + *    Version 1.0 </a><br><br>
  + * You will also find more information and examples in
  + * <a href="http://jakarta.apache.org/commons/jxpath/users-guide.html">
  + * JXPath User's Guide</a>
  + *
    *
    * @author Dmitri Plotnikov
    * @version $Revision$ $Date$
  @@ -420,7 +424,7 @@
       private static JXPathContext compilationContext;
   
       /**
  -     * Creates a new JXPathContext with the specified bean as the root node.
  +     * Creates a new JXPathContext with the specified object as the root node.
        */
       public static JXPathContext newContext(Object contextBean){
           return JXPathContextFactory.newInstance().newContext(null, contextBean);
  @@ -463,14 +467,18 @@
        */
       public abstract Pointer getContextPointer();
   
  +    /**
  +     * Installs a custom implementation of the Variables interface.
  +     */
       public void setVariables(Variables vars){
           this.vars = vars;
       }
   
       /**
        * Returns the variable pool associated with the context. If no such
  -     * pool was specified during the construction of the context,
  -     * returns the default implementation of Variables, {@link BasicVariables BasicVariables}.
  +     * pool was specified with the <code>setVariables()</code> method,
  +     * returns the default implementation of Variables,
  +     * {@link BasicVariables BasicVariables}.
        */
       public Variables getVariables(){
           if (vars == null){
  @@ -479,23 +487,35 @@
           return vars;
       }
   
  +    /**
  +     * Install a library of extension functions.
  +     *
  +     * @see FunctionLibrary
  +     */
       public void setFunctions(Functions functions){
           this.functions = functions;
       }
   
  +    /**
  +     * Returns the set of functions installed on the context.
  +     */
       public Functions getFunctions(){
  -        // TBD: default lib
           return functions;
       }
   
  +    /**
  +     * Install an abstract factory that should be used by the
  +     * <code>createPath()</code> and <code>createPathAndSetValue()</code>
  +     * methods.
  +     */
       public void setFactory(AbstractFactory factory){
           this.factory = factory;
       }
   
       /**
        * Returns the AbstractFactory installed on this context.
  -     * If none has been installed, it calls getFactory() on
  -     * the parent context.
  +     * If none has been installed and this context has a parent context,
  +     * returns the parent's factory.  Otherwise returns null.
        */
       public AbstractFactory getFactory(){
           if (factory == null && parentContext != null){
  @@ -515,8 +535,9 @@
       }
   
       /**
  -     * Returns the locale set with setLocale or Locale.getDefault()
  -     * by default.
  +     * Returns the locale set with setLocale. If none was set and
  +     * the context has a parent, returns the parent's locale.
  +     * Otherwise, returns Locale.getDefault().
        */
       protected Locale getLocale(){
           if (locale == null){
  @@ -566,7 +587,7 @@
   
       /**
        * Overridden by each concrete implementation of JXPathContext
  -     * to perform compilation.
  +     * to perform compilation. Is called by <code>compile()</code>.
        */
       protected abstract CompiledExpression compilePath(String xpath);
   
  @@ -592,7 +613,6 @@
        */
       public abstract void setValue(String xpath, Object value);
   
  -
       /**
        * Creates missing elements of the path by invoking an AbstractFactory,
        * which should first be installed on the context by calling "setFactory".
  @@ -629,39 +649,12 @@
       public abstract void removeAll(String xpath);
   
       /**
  -     * @deprecated please use createPathAndSetValue(xpath, value)
  -     */
  -    public void createPath(String xpath, Object value){
  -        createPathAndSetValue(xpath, value);
  -    }
  -
  -    /**
  -     * @deprecated Please use iterate
  -     */
  -    public List eval(String xpath){
  -        ArrayList list = new ArrayList();
  -        Iterator it = iterate(xpath);
  -        while (it.hasNext()){
  -            list.add(it.next());
  -        }
  -        return list;
  -    }
  -
  -    /**
  -     * Traverses the xpath and returns a Iterator of all results found
  +     * Traverses the xpath and returns an Iterator of all results found
        * for the path. If the xpath matches no properties
  -     * in the graph, the Iterator will not be null.
  +     * in the graph, the Iterator will be empty, but not null.
        */
       public abstract Iterator iterate(String xpath);
   
  -
  -    /**
  -     * @deprecated Please use getPointer(String xpath)
  -     */
  -    public Pointer locateValue(String xpath){
  -        return getPointer(xpath);
  -    }
  -
       /**
        * Traverses the xpath and returns a Pointer.
        * A Pointer provides easy access to a property.
  @@ -669,18 +662,6 @@
        * in the graph, the pointer will be null.
        */
       public abstract Pointer getPointer(String xpath);
  -
  -    /**
  -     * @deprecated Please use iteratePointers
  -     */
  -    public List locate(String xpath){
  -        ArrayList list = new ArrayList();
  -        Iterator it = iteratePointers(xpath);
  -        while (it.hasNext()){
  -            list.add(it.next());
  -        }
  -        return list;
  -    }
   
       /**
        * Traverses the xpath and returns an Iterator of Pointers.
  
  
  
  1.4       +5 -8      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JXPathBasicBeanInfo.java	21 Apr 2002 21:52:31 -0000	1.3
  +++ JXPathBasicBeanInfo.java	16 Jun 2002 03:22:22 -0000	1.4
  @@ -146,10 +146,7 @@
                   propertyNames[i] = pds[i].getName();
               }
           }
  -//        int inx = Arrays.binarySearch(propertyNames, propertyName);
  -//        if (inx < 0){
  -//            return null;
  -//        }
  +
           for (int i = 0; i < propertyNames.length; i++){
               if (propertyNames[i] == propertyName){
                   return propertyDescriptors[i];
  
  
  
  1.3       +6 -5      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/Functions.java
  
  Index: Functions.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/Functions.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Functions.java	24 Apr 2002 04:05:41 -0000	1.2
  +++ Functions.java	16 Jun 2002 03:22:22 -0000	1.3
  @@ -64,7 +64,8 @@
   import java.util.Set;
   
   /**
  - * A group of Function objects sharing a common namespace. Use classes
  + * A group of Function objects sharing a common namespace or a set of
  + * common namespaces. Use the classes
    * {@link ClassFunctions ClassFunctions} and {@link PackageFunctions PackageFunctions}
    * to register extension functions implemented as Java methods.
    *
  
  
  
  1.2       +4 -4      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/DynamicPropertyHandler.java
  
  Index: DynamicPropertyHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/DynamicPropertyHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DynamicPropertyHandler.java	23 Aug 2001 00:46:58 -0000	1.1
  +++ DynamicPropertyHandler.java	16 Jun 2002 03:22:22 -0000	1.2
  @@ -69,7 +69,7 @@
    * <ol>
    * <li>Build an implementation of the DynamicPropertyHandler interface
    * for the desired collection type.</li>
  - * <li>Invoke static method {@link JXPathIntrospector#registerDynamicClass
  + * <li>Invoke the static method {@link JXPathIntrospector#registerDynamicClass
    * JXPathIntrospector.registerDynamicClass(class, handlerClass)}</li>
    * </ol>
    * JXPath allows access to dynamic properties using these three formats:
  
  
  
  1.3       +5 -5      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/Container.java
  
  Index: Container.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/Container.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Container.java	24 Apr 2002 04:05:41 -0000	1.2
  +++ Container.java	16 Jun 2002 03:22:22 -0000	1.3
  @@ -66,7 +66,7 @@
    * mechanism transparent to JXPath.  For example, if property
    * "foo" of the context node has a Container as its value,
    * the XPath "foo" will produce the contents of that Container,
  - * not the container itself.
  + * rather than the container itself.
    *
    * @author Dmitri Plotnikov
    * @version $Revision$ $Date$
  
  
  
  1.3       +11 -9     jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/CompiledExpression.java
  
  Index: CompiledExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/CompiledExpression.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CompiledExpression.java	8 May 2002 23:05:05 -0000	1.2
  +++ CompiledExpression.java	16 Jun 2002 03:22:22 -0000	1.3
  @@ -103,6 +103,13 @@
       void setValue(JXPathContext context, Object value);
   
       /**
  +     * Creates intermediate elements of
  +     * the path by invoking an AbstractFactory, which should first be
  +     * installed on the context by calling "setFactory".
  +     */
  +    Pointer createPath(JXPathContext context);
  +
  +    /**
        * The same as setValue, except it creates intermediate elements of
        * the path by invoking an AbstractFactory, which should first be
        * installed on the context by calling "setFactory".
  @@ -117,11 +124,6 @@
        * </ul>
        */
       Pointer createPathAndSetValue(JXPathContext context, Object value);
  -
  -    /**
  -     * @deprecated switch to createPathAndSetValue
  -     */
  -    void createPath(JXPathContext context, Object value);
   
       /**
        * Traverses the xpath and returns a Iterator of all results found
  
  
  
  1.5       +13 -11    jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ClassFunctions.java
  
  Index: ClassFunctions.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ClassFunctions.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ClassFunctions.java	24 Apr 2002 03:29:33 -0000	1.4
  +++ ClassFunctions.java	16 Jun 2002 03:22:22 -0000	1.5
  @@ -68,7 +68,7 @@
   
   import org.apache.commons.jxpath.functions.ConstructorFunction;
   import org.apache.commons.jxpath.functions.MethodFunction;
  -import org.apache.commons.jxpath.util.TypeUtils;
  +import org.apache.commons.jxpath.util.MethodLookupUtils;
   
   /**
    * Extension functions provided by a Java class.
  @@ -108,7 +108,7 @@
   
       /**
        * Returns a set of one namespace - the one specified in the constructor.
  -     * 
  +     *
        * @returns a singleton
        */
       public Set getUsedNamespaces(){
  @@ -118,11 +118,11 @@
       /**
        * Returns a Function, if any, for the specified namespace,
        * name and parameter types.
  -     * 
  +     *
        * @param namespace if it is not the namespace specified in the constructor,
        *     the method returns null
        * @param name is a function name or "new" for a constructor.
  -     * 
  +     *
        * @return a MethodFunction, a ConstructorFunction or null if there is no
        *      such function.
        */
  @@ -137,18 +137,20 @@
   
           if (name.equals("new")) {
               Constructor constructor =
  -                TypeUtils.lookupConstructor(functionClass, parameters);
  +                MethodLookupUtils.lookupConstructor(functionClass, parameters);
               if (constructor != null) {
                   return new ConstructorFunction(constructor);
               }
           }
           else {
  -            Method method = TypeUtils.lookupStaticMethod(functionClass, name, parameters);
  +            Method method = MethodLookupUtils.
  +                lookupStaticMethod(functionClass, name, parameters);
               if (method != null) {
                   return new MethodFunction(method);
               }
   
  -            method = TypeUtils.lookupMethod(functionClass, name, parameters);
  +            method = MethodLookupUtils.
  +                lookupMethod(functionClass, name, parameters);
               if (method != null) {
                   return new MethodFunction(method);
               }
  
  
  
  1.4       +5 -5      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/AbstractFactory.java
  
  Index: AbstractFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/AbstractFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractFactory.java	24 Apr 2002 03:29:33 -0000	1.3
  +++ AbstractFactory.java	16 Jun 2002 03:22:22 -0000	1.4
  @@ -99,7 +99,7 @@
       }
   
       /**
  -     * Create a new object and set it on the specified variable
  +     * Declare the specified variable
        * 
        * @param context hosts variable pools. See {@link JXPathContext#getVariables() 
        *        JXPathContext.getVariables()}
  
  
  

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