You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/04/12 14:55:40 UTC

(commons-jxpath) branch master updated (ced1bc4 -> 6bd9410)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jxpath.git


    from ced1bc4  Fix PMD AvoidDecimalLiteralsInBigDecimalConstructor in org.apache.commons.jxpath.util.BasicTypeConverter.allocateNumber(Class, double)
     new 87f4472  Javadoc
     new b2e40ba  org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.iteratePointers(String) now uses generics
     new 688bc8e  org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.iteratePointers(String, Expression) now uses generics
     new 868105b  org.apache.commons.jxpath.CompiledExpression.iteratePointers(JXPathContext) now uses generics
     new 56fa34a  Fix typos in Javadoc and exception messages
     new 6bd9410  ClassLoaderUtil.getClass(*) now uses generics

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                            |  8 +++++++
 .../apache/commons/jxpath/CompiledExpression.java  | 14 +++++------
 .../org/apache/commons/jxpath/JXPathContext.java   | 18 +++++++--------
 .../commons/jxpath/JXPathContextFactory.java       |  3 +--
 .../apache/commons/jxpath/JXPathIntrospector.java  |  3 +--
 .../apache/commons/jxpath/PackageFunctions.java    |  2 +-
 .../java/org/apache/commons/jxpath/Pointer.java    |  7 ++++--
 .../org/apache/commons/jxpath/ri/Compiler.java     |  2 +-
 .../jxpath/ri/JXPathCompiledExpression.java        |  2 +-
 .../jxpath/ri/JXPathContextReferenceImpl.java      | 27 +++++++++++-----------
 .../commons/jxpath/ri/compiler/Expression.java     |  2 +-
 .../commons/jxpath/ri/model/NodePointer.java       |  2 +-
 .../commons/jxpath/util/ClassLoaderUtil.java       | 19 +++++++++------
 .../commons/jxpath/xml/DocumentContainer.java      |  3 +--
 src/site/xdoc/users-guide.xml                      |  4 ++--
 .../jxpath/ri/JXPathCompiledExpressionTest.java    |  2 +-
 16 files changed, 65 insertions(+), 53 deletions(-)


(commons-jxpath) 03/06: org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.iteratePointers(String, Expression) now uses generics

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jxpath.git

commit 688bc8e95d9723dc86b375428ed22f92e7a875dd
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat Apr 12 09:58:46 2025 -0400

    org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.iteratePointers(String,
    Expression) now uses generics
---
 src/changes/changes.xml                                                 | 1 +
 .../java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java   | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 2b3d637..e803554 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -136,6 +136,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="fix" due-to="Gary Gregory">BasicTypeConverter.unmodifiableCollection(Collection) now uses generics.</action>
       <action dev="ggregory" type="fix" due-to="Gary Gregory. PMD">Fix PMD AvoidDecimalLiteralsInBigDecimalConstructor in org.apache.commons.jxpath.util.BasicTypeConverter.allocateNumber(Class, double).</action>
       <action dev="ggregory" type="fix" due-to="Gary Gregory">org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.iteratePointers(String) now uses generics.</action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.iteratePointers(String, Expression) now uses generics.</action>
       <!-- ADD -->
       <action issue="JXPATH-123" dev="mbenson" type="add">
         XPath function "ends-with" is not implemented (although "starts-with" is).
diff --git a/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java b/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
index 593aab7..0119d12 100644
--- a/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
+++ b/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
@@ -649,7 +649,7 @@ public class JXPathContextReferenceImpl extends JXPathContext {
      * @param expr  compiled Expression
      * @return Iterator
      */
-    public Iterator iteratePointers(final String xpath, final Expression expr) {
+    public Iterator<Pointer> iteratePointers(final String xpath, final Expression expr) {
         return expr.iteratePointers(getEvalContext());
     }
 


(commons-jxpath) 04/06: org.apache.commons.jxpath.CompiledExpression.iteratePointers(JXPathContext) now uses generics

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jxpath.git

commit 868105bbc642a235c6cb28be5c59d6ab1a637c6e
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat Apr 12 10:13:46 2025 -0400

    org.apache.commons.jxpath.CompiledExpression.iteratePointers(JXPathContext)
    now uses generics
    
    - org.apache.commons.jxpath.JXPathCompiledExpression.iteratePointers(JXPathContext)
    now uses generics
---
 src/changes/changes.xml                                                 | 2 ++
 src/main/java/org/apache/commons/jxpath/CompiledExpression.java         | 2 +-
 .../java/org/apache/commons/jxpath/ri/JXPathCompiledExpression.java     | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index e803554..bb6cac7 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -137,6 +137,8 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="fix" due-to="Gary Gregory. PMD">Fix PMD AvoidDecimalLiteralsInBigDecimalConstructor in org.apache.commons.jxpath.util.BasicTypeConverter.allocateNumber(Class, double).</action>
       <action dev="ggregory" type="fix" due-to="Gary Gregory">org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.iteratePointers(String) now uses generics.</action>
       <action dev="ggregory" type="fix" due-to="Gary Gregory">org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.iteratePointers(String, Expression) now uses generics.</action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">org.apache.commons.jxpath.CompiledExpression.iteratePointers(JXPathContext) now uses generics.</action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">org.apache.commons.jxpath.JXPathCompiledExpression.iteratePointers(JXPathContext) now uses generics.</action>
       <!-- ADD -->
       <action issue="JXPATH-123" dev="mbenson" type="add">
         XPath function "ends-with" is not implemented (although "starts-with" is).
diff --git a/src/main/java/org/apache/commons/jxpath/CompiledExpression.java b/src/main/java/org/apache/commons/jxpath/CompiledExpression.java
index abe94f7..bc5423a 100644
--- a/src/main/java/org/apache/commons/jxpath/CompiledExpression.java
+++ b/src/main/java/org/apache/commons/jxpath/CompiledExpression.java
@@ -99,7 +99,7 @@ public interface CompiledExpression {
      * @param context to iterate
      * @return Iterator
      */
-    Iterator iteratePointers(JXPathContext context);
+    Iterator<Pointer> iteratePointers(JXPathContext context);
 
     /**
      * Remove all graph elements described by this expression.
diff --git a/src/main/java/org/apache/commons/jxpath/ri/JXPathCompiledExpression.java b/src/main/java/org/apache/commons/jxpath/ri/JXPathCompiledExpression.java
index df76f3f..8794039 100644
--- a/src/main/java/org/apache/commons/jxpath/ri/JXPathCompiledExpression.java
+++ b/src/main/java/org/apache/commons/jxpath/ri/JXPathCompiledExpression.java
@@ -92,7 +92,7 @@ public class JXPathCompiledExpression implements CompiledExpression {
     }
 
     @Override
-    public Iterator iteratePointers(final JXPathContext context) {
+    public Iterator<Pointer> iteratePointers(final JXPathContext context) {
         return ((JXPathContextReferenceImpl) context).iteratePointers(xpath, expression);
     }
 


(commons-jxpath) 01/06: Javadoc

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jxpath.git

commit 87f4472603e35268519bb03e55dcde2e01aacd0e
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat Apr 12 09:55:00 2025 -0400

    Javadoc
---
 src/main/java/org/apache/commons/jxpath/Pointer.java | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/jxpath/Pointer.java b/src/main/java/org/apache/commons/jxpath/Pointer.java
index 437a756..c1589e9 100644
--- a/src/main/java/org/apache/commons/jxpath/Pointer.java
+++ b/src/main/java/org/apache/commons/jxpath/Pointer.java
@@ -34,6 +34,7 @@ public interface Pointer extends Cloneable, Comparable, Serializable {
      * <p>
      * {@code Pointer  ptr = ctx.getPointer("//employees[firstName = 'John']")
      * }
+     * </p>
      * <p>
      * The value of {@code ptr.asPath()} will look something like {@code "/departments[2]/employees[3]"}, so, basically, it represents the concrete location(s)
      * of the result of a search performed by JXPath. If an object in the pointer's path is a Dynamic Property object (like a Map), the asPath method generates
@@ -54,8 +55,9 @@ public interface Pointer extends Cloneable, Comparable, Serializable {
     /**
      * Returns the raw value of the object, property or collection element this pointer represents. Never converts the object to a canonical type: returns it as
      * is.
-     *
+     * <p>
      * For example, for an XML element, getNode() will return the element itself rather than the text it contains.
+     * </p>
      *
      * @return Object node
      */
@@ -71,8 +73,9 @@ public interface Pointer extends Cloneable, Comparable, Serializable {
     /**
      * Returns the value of the object, property or collection element this pointer represents. May convert the value to one of the canonical InfoSet types:
      * String, Number, Boolean, Set.
-     *
+     * <p>
      * For example, in the case of an XML element, getValue() will return the text contained by the element rather than the element itself.
+     * </p>
      *
      * @return Object value
      */


(commons-jxpath) 05/06: Fix typos in Javadoc and exception messages

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jxpath.git

commit 56fa34a4fca471bf82690a27c3c2b64f2104d1ed
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat Apr 12 10:30:18 2025 -0400

    Fix typos in Javadoc and exception messages
---
 .../apache/commons/jxpath/CompiledExpression.java    | 12 ++++++------
 .../org/apache/commons/jxpath/JXPathContext.java     | 18 +++++++++---------
 .../java/org/apache/commons/jxpath/ri/Compiler.java  |  2 +-
 .../jxpath/ri/JXPathContextReferenceImpl.java        | 20 ++++++++++----------
 .../commons/jxpath/ri/compiler/Expression.java       |  2 +-
 .../apache/commons/jxpath/ri/model/NodePointer.java  |  2 +-
 src/site/xdoc/users-guide.xml                        |  4 ++--
 .../jxpath/ri/JXPathCompiledExpressionTest.java      |  2 +-
 8 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/src/main/java/org/apache/commons/jxpath/CompiledExpression.java b/src/main/java/org/apache/commons/jxpath/CompiledExpression.java
index bc5423a..27e68f7 100644
--- a/src/main/java/org/apache/commons/jxpath/CompiledExpression.java
+++ b/src/main/java/org/apache/commons/jxpath/CompiledExpression.java
@@ -45,7 +45,7 @@ public interface CompiledExpression {
      * <p>
      * Will throw an exception if one of the following conditions occurs:
      * <ul>
-     * <li>Elements of the xpath aleady exist, by the path does not in fact describe an existing property
+     * <li>Elements of the XPath aleady exist, by the path does not in fact describe an existing property
      * <li>The AbstractFactory fails to create an instance for an intermediate element.
      * <li>The property is not writable (no public, non-static set method)
      * </ul>
@@ -57,7 +57,7 @@ public interface CompiledExpression {
     Pointer createPathAndSetValue(JXPathContext context, Object value);
 
     /**
-     * Traverses the xpath and returns a Pointer. A Pointer provides easy access to a property. If the xpath matches no properties in the graph, the pointer
+     * Traverses the XPath and returns a Pointer. A Pointer provides easy access to a property. If the XPath matches no properties in the graph, the pointer
      * will be null.
      *
      * @param context base
@@ -67,7 +67,7 @@ public interface CompiledExpression {
     Pointer getPointer(JXPathContext context, String xpath);
 
     /**
-     * Evaluates the xpath and returns the resulting object. Primitive types are wrapped into objects.
+     * Evaluates the XPath and returns the resulting object. Primitive types are wrapped into objects.
      *
      * @param context to evaluate
      * @return Object
@@ -84,7 +84,7 @@ public interface CompiledExpression {
     Object getValue(JXPathContext context, Class requiredType);
 
     /**
-     * Traverses the xpath and returns a Iterator of all results found for the path. If the xpath matches no properties in the graph, the Iterator will not be
+     * Traverses the XPath and returns a Iterator of all results found for the path. If the XPath matches no properties in the graph, the Iterator will not be
      * null.
      *
      * @param context base
@@ -93,7 +93,7 @@ public interface CompiledExpression {
     Iterator iterate(JXPathContext context);
 
     /**
-     * Traverses the xpath and returns an Iterator of Pointers. A Pointer provides easy access to a property. If the xpath matches no properties in the graph,
+     * Traverses the XPath and returns an Iterator of Pointers. A Pointer provides easy access to a property. If the XPath matches no properties in the graph,
      * the Iterator be empty, but not null.
      *
      * @param context to iterate
@@ -118,7 +118,7 @@ public interface CompiledExpression {
     /**
      * Modifies the value of the property described by the supplied xpath. Will throw an exception if one of the following conditions occurs:
      * <ul>
-     * <li>The xpath does not in fact describe an existing property
+     * <li>The XPath does not in fact describe an existing property
      * <li>The property is not writable (no public, non-static set method)
      * </ul>
      *
diff --git a/src/main/java/org/apache/commons/jxpath/JXPathContext.java b/src/main/java/org/apache/commons/jxpath/JXPathContext.java
index ddd64e0..5f19744 100644
--- a/src/main/java/org/apache/commons/jxpath/JXPathContext.java
+++ b/src/main/java/org/apache/commons/jxpath/JXPathContext.java
@@ -37,7 +37,7 @@ import org.apache.commons.jxpath.util.KeyManagerUtils;
  *
  * <h2>JXPath Interprets XPath Syntax on Java Object Graphs</h2>
  *
- * JXPath uses an intuitive interpretation of the xpath syntax in the context of Java object graphs. Here are some examples:
+ * JXPath uses an intuitive interpretation of the XPath syntax in the context of Java object graphs. Here are some examples:
  *
  * <h3>Example 1: JavaBean Property Access</h3>
  *
@@ -83,7 +83,7 @@ import org.apache.commons.jxpath.util.KeyManagerUtils;
  *
  * In this case XPath is used to access a property of a nested bean.
  * <p>
- * A property identified by the xpath does not have to be a "leaf" property. For instance, we can extract the whole Address object in above example:
+ * A property identified by the XPath does not have to be a "leaf" property. For instance, we can extract the whole Address object in above example:
  * </p>
  *
  * <pre>
@@ -467,7 +467,7 @@ public abstract class JXPathContext {
      * <p>
      * Will throw an exception if one of the following conditions occurs:
      * <ul>
-     * <li>Elements of the xpath aleady exist, but the path does not in fact describe an existing property
+     * <li>Elements of the XPath aleady exist, but the path does not in fact describe an existing property
      * <li>The AbstractFactory fails to create an instance for an intermediate element.
      * <li>The property is not writable (no public, non-static set method)
      * </ul>
@@ -621,9 +621,9 @@ public abstract class JXPathContext {
     }
 
     /**
-     * Traverses the xpath and returns a Pointer. A Pointer provides easy access to a property.
+     * Traverses the XPath and returns a Pointer. A Pointer provides easy access to a property.
      * <p>
-     * If the xpath <a href='#matches_no_property_in_the_graph'>matches no properties in the graph</a> the behavior depends on the value that has been
+     * If the XPath <a href='#matches_no_property_in_the_graph'>matches no properties in the graph</a> the behavior depends on the value that has been
      * configured with {@link #setLenient(boolean)}:
      * </p>
      * <ul>
@@ -687,7 +687,7 @@ public abstract class JXPathContext {
     public abstract JXPathContext getRelativeContext(Pointer pointer);
 
     /**
-     * Evaluates the xpath and returns the resulting object. Primitive types are wrapped into objects.
+     * Evaluates the XPath and returns the resulting object. Primitive types are wrapped into objects.
      *
      * @param xpath to evaluate
      * @return Object found
@@ -730,7 +730,7 @@ public abstract class JXPathContext {
     }
 
     /**
-     * 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 be
+     * 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 be
      * empty, but not null.
      *
      * @param <E>   the type of elements returned by the iterator.
@@ -740,7 +740,7 @@ public abstract class JXPathContext {
     public abstract <E> Iterator<E> iterate(String xpath);
 
     /**
-     * Traverses the xpath and returns an Iterator of Pointers. A Pointer provides easy access to a property. If the xpath matches no properties in the graph,
+     * Traverses the XPath and returns an Iterator of Pointers. A Pointer provides easy access to a property. If the XPath matches no properties in the graph,
      * the Iterator be empty, but not null.
      *
      * @param xpath to iterate
@@ -898,7 +898,7 @@ public abstract class JXPathContext {
     /**
      * Modifies the value of the property described by the supplied xpath. Will throw an exception if one of the following conditions occurs:
      * <ul>
-     * <li>The xpath does not in fact describe an existing property
+     * <li>The XPath does not in fact describe an existing property
      * <li>The property is not writable (no public, non-static set method)
      * </ul>
      *
diff --git a/src/main/java/org/apache/commons/jxpath/ri/Compiler.java b/src/main/java/org/apache/commons/jxpath/ri/Compiler.java
index 451b656..b0ee110 100644
--- a/src/main/java/org/apache/commons/jxpath/ri/Compiler.java
+++ b/src/main/java/org/apache/commons/jxpath/ri/Compiler.java
@@ -24,7 +24,7 @@ package org.apache.commons.jxpath.ri;
  * Since objects returned by Compiler methods are passed as arguments to other Compiler methods, the descriptions of these methods use virtual types. There are
  * four virtual object types: EXPRESSION, QNAME, STEP and NODE_TEST.
  * <p>
- * The following example illustrates this notion. This sequence compiles the xpath "foo[round(1 div 2)]/text()": <blockquote>
+ * The following example illustrates this notion. This sequence compiles the XPath "foo[round(1 div 2)]/text()": <blockquote>
  *
  * <pre>
  *      Object qname1 = compiler.qname(null, "foo")
diff --git a/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java b/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
index 0119d12..549ef2a 100644
--- a/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
+++ b/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
@@ -328,7 +328,7 @@ public class JXPathContextReferenceImpl extends JXPathContext {
             }
             return ((NodePointer) pointer).createPath(this);
         } catch (final Throwable ex) {
-            throw new JXPathException("Exception trying to create xpath " + xpath, ex);
+            throw new JXPathException("Exception trying to create XPath " + xpath, ex);
         }
     }
 
@@ -344,7 +344,7 @@ public class JXPathContextReferenceImpl extends JXPathContext {
         try {
             return setValue(xpath, expr, value, true);
         } catch (final Throwable ex) {
-            throw new JXPathException("Exception trying to create xpath " + xpath, ex);
+            throw new JXPathException("Exception trying to create XPath " + xpath, ex);
         }
     }
 
@@ -488,7 +488,7 @@ public class JXPathContextReferenceImpl extends JXPathContext {
     }
 
     /**
-     * Traverses the xpath and returns the resulting object. Primitive types are wrapped into objects.
+     * Traverses the XPath and returns the resulting object. Primitive types are wrapped into objects.
      *
      * @param xpath expression
      * @return Object found
@@ -606,7 +606,7 @@ public class JXPathContextReferenceImpl extends JXPathContext {
     }
 
     /**
-     * Traverses the xpath and returns a Iterator of all results found for the path. If the xpath matches no properties in the graph, the Iterator will not be
+     * Traverses the XPath and returns a Iterator of all results found for the path. If the XPath matches no properties in the graph, the Iterator will not be
      * null.
      *
      * @param xpath expression
@@ -618,7 +618,7 @@ public class JXPathContextReferenceImpl extends JXPathContext {
     }
 
     /**
-     * Traverses the xpath and returns a Iterator of all results found for the path. If the xpath matches no properties in the graph, the Iterator will not be
+     * Traverses the XPath and returns a Iterator of all results found for the path. If the XPath matches no properties in the graph, the Iterator will not be
      * null.
      *
      * @param xpath expression
@@ -630,7 +630,7 @@ public class JXPathContextReferenceImpl extends JXPathContext {
     }
 
     /**
-     * Traverses the xpath and returns an Iterator of Pointers. A Pointer provides easy access to a property. If the xpath matches no properties in the graph,
+     * Traverses the XPath and returns an Iterator of Pointers. A Pointer provides easy access to a property. If the XPath matches no properties in the graph,
      * the Iterator be empty, but not null.
      *
      * @param xpath expression
@@ -642,7 +642,7 @@ public class JXPathContextReferenceImpl extends JXPathContext {
     }
 
     /**
-     * Traverses the xpath and returns an Iterator of Pointers. A Pointer provides easy access to a property. If the xpath matches no properties in the graph,
+     * Traverses the XPath and returns an Iterator of Pointers. A Pointer provides easy access to a property. If the XPath matches no properties in the graph,
      * the Iterator be empty, but not null.
      *
      * @param xpath expression
@@ -711,7 +711,7 @@ public class JXPathContextReferenceImpl extends JXPathContext {
                 pointer.remove();
             }
         } catch (final Throwable ex) {
-            throw new JXPathException("Exception trying to remove xpath " + xpath, ex);
+            throw new JXPathException("Exception trying to remove XPath " + xpath, ex);
         }
     }
 
@@ -734,7 +734,7 @@ public class JXPathContextReferenceImpl extends JXPathContext {
     }
 
     /**
-     * Sets the value of xpath to value.
+     * Sets the value of XPath to value.
      *
      * @param xpath path
      * @param expr  compiled Expression
@@ -744,7 +744,7 @@ public class JXPathContextReferenceImpl extends JXPathContext {
         try {
             setValue(xpath, expr, value, false);
         } catch (final Throwable ex) {
-            throw new JXPathException("Exception trying to set value with xpath " + xpath, ex);
+            throw new JXPathException("Exception trying to set value with XPath " + xpath, ex);
         }
     }
 
diff --git a/src/main/java/org/apache/commons/jxpath/ri/compiler/Expression.java b/src/main/java/org/apache/commons/jxpath/ri/compiler/Expression.java
index 712afa0..09ebb3d 100644
--- a/src/main/java/org/apache/commons/jxpath/ri/compiler/Expression.java
+++ b/src/main/java/org/apache/commons/jxpath/ri/compiler/Expression.java
@@ -30,7 +30,7 @@ import org.apache.commons.jxpath.util.ValueUtils;
 
 /**
  * Common superclass for several types of nodes in the parse tree. Provides APIs for optimization of evaluation of expressions. Specifically, an expression only
- * needs to executed once during the evaluation of an xpath if that expression is context-independent. Expression.isContextDependent() provides that hint.
+ * needs to executed once during the evaluation of an XPath if that expression is context-independent. Expression.isContextDependent() provides that hint.
  */
 public abstract class Expression {
 
diff --git a/src/main/java/org/apache/commons/jxpath/ri/model/NodePointer.java b/src/main/java/org/apache/commons/jxpath/ri/model/NodePointer.java
index e3b030a..76ba5ce 100644
--- a/src/main/java/org/apache/commons/jxpath/ri/model/NodePointer.java
+++ b/src/main/java/org/apache/commons/jxpath/ri/model/NodePointer.java
@@ -188,7 +188,7 @@ public abstract class NodePointer implements Pointer {
     /**
      * Returns an XPath that maps to this Pointer.
      *
-     * @return String xpath expression
+     * @return String XPath expression
      */
     @Override
     public String asPath() {
diff --git a/src/site/xdoc/users-guide.xml b/src/site/xdoc/users-guide.xml
index 2f48e71..49d0003 100644
--- a/src/site/xdoc/users-guide.xml
+++ b/src/site/xdoc/users-guide.xml
@@ -218,7 +218,7 @@ String fName = (String)context.getValue("firstName");
       <subsection name="Lenient Mode">
         <p>
           The <code>context.getValue(xpath)</code>  method throws
-          an exception if the supplied xpath does not map to an
+          an exception if the supplied XPath does not map to an
           existing property. This constraint can be relaxed by
           calling <code>context.setLenient(true)</code>. In the
           lenient mode the method merely returns null if the path
@@ -743,7 +743,7 @@ String fName = (String)context.getValue("firstName");
     <section name="Exceptions During XPath Evaluation">
       <p>
         Exceptions thrown by accessor methods are treated differently depending
-        on the evaluated xpath and the particular method used to do the
+        on the evaluated XPath and the particular method used to do the
         evaluation.
       </p>
       <p>
diff --git a/src/test/java/org/apache/commons/jxpath/ri/JXPathCompiledExpressionTest.java b/src/test/java/org/apache/commons/jxpath/ri/JXPathCompiledExpressionTest.java
index 0668628..5819a7c 100644
--- a/src/test/java/org/apache/commons/jxpath/ri/JXPathCompiledExpressionTest.java
+++ b/src/test/java/org/apache/commons/jxpath/ri/JXPathCompiledExpressionTest.java
@@ -55,7 +55,7 @@ public class JXPathCompiledExpressionTest extends AbstractJXPathTest {
     }
 
     /**
-     * Compiles the xpath into an Expression, checks the expression class, converts the expression to string and checks that the string matches the expected
+     * Compiles the XPath into an Expression, checks the expression class, converts the expression to string and checks that the string matches the expected
      * one.
      */
     private void assertXPathExpression(final String xpath, final Class expectedClass, final String expected) {


(commons-jxpath) 06/06: ClassLoaderUtil.getClass(*) now uses generics

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jxpath.git

commit 6bd9410ade712f577d7cb03cdee8f45201100ab2
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat Apr 12 10:55:35 2025 -0400

    ClassLoaderUtil.getClass(*) now uses generics
---
 src/changes/changes.xml                               |  4 ++++
 .../apache/commons/jxpath/JXPathContextFactory.java   |  3 +--
 .../org/apache/commons/jxpath/JXPathIntrospector.java |  3 +--
 .../org/apache/commons/jxpath/PackageFunctions.java   |  2 +-
 .../commons/jxpath/ri/JXPathContextReferenceImpl.java |  3 +--
 .../apache/commons/jxpath/util/ClassLoaderUtil.java   | 19 ++++++++++++-------
 .../apache/commons/jxpath/xml/DocumentContainer.java  |  3 +--
 7 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index bb6cac7..4b7d7f3 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -139,6 +139,10 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="fix" due-to="Gary Gregory">org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.iteratePointers(String, Expression) now uses generics.</action>
       <action dev="ggregory" type="fix" due-to="Gary Gregory">org.apache.commons.jxpath.CompiledExpression.iteratePointers(JXPathContext) now uses generics.</action>
       <action dev="ggregory" type="fix" due-to="Gary Gregory">org.apache.commons.jxpath.JXPathCompiledExpression.iteratePointers(JXPathContext) now uses generics.</action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">org.apache.commons.jxpath.util.ClassLoaderUtil.getClass(ClassLoader, String) now uses generics.</action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">org.apache.commons.jxpath.util.ClassLoaderUtil.getClass(ClassLoader, String, boolean) now uses generics.</action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">org.apache.commons.jxpath.util.ClassLoaderUtil.getClass(String) now uses generics.</action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">org.apache.commons.jxpath.util.ClassLoaderUtil.getClass(String, boolean) now uses generics.</action>
       <!-- ADD -->
       <action issue="JXPATH-123" dev="mbenson" type="add">
         XPath function "ends-with" is not implemented (although "starts-with" is).
diff --git a/src/main/java/org/apache/commons/jxpath/JXPathContextFactory.java b/src/main/java/org/apache/commons/jxpath/JXPathContextFactory.java
index 10b3d36..dd36b3b 100644
--- a/src/main/java/org/apache/commons/jxpath/JXPathContextFactory.java
+++ b/src/main/java/org/apache/commons/jxpath/JXPathContextFactory.java
@@ -156,8 +156,7 @@ public abstract class JXPathContextFactory {
     public static JXPathContextFactory newInstance() {
         JXPathContextFactory factoryImpl;
         try {
-            final Class clazz = ClassLoaderUtil.getClass(FACTORY_IMPL_NAME, true);
-            factoryImpl = (JXPathContextFactory) clazz.getConstructor().newInstance();
+            factoryImpl = ClassLoaderUtil.<JXPathContextFactory>getClass(FACTORY_IMPL_NAME, true).getConstructor().newInstance();
         } catch (final ReflectiveOperationException ie) {
             throw new JXPathContextFactoryConfigurationError(ie);
         }
diff --git a/src/main/java/org/apache/commons/jxpath/JXPathIntrospector.java b/src/main/java/org/apache/commons/jxpath/JXPathIntrospector.java
index ed13843..e5ada65 100644
--- a/src/main/java/org/apache/commons/jxpath/JXPathIntrospector.java
+++ b/src/main/java/org/apache/commons/jxpath/JXPathIntrospector.java
@@ -166,8 +166,7 @@ public class JXPathIntrospector {
             }
         }
         // Now try the ClassLoaderUtil.
-        final Class cls = ClassLoaderUtil.getClass(className);
-        return cls.newInstance();
+        return ClassLoaderUtil.getClass(className).newInstance();
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/jxpath/PackageFunctions.java b/src/main/java/org/apache/commons/jxpath/PackageFunctions.java
index 0d8038f..ecadc3e 100644
--- a/src/main/java/org/apache/commons/jxpath/PackageFunctions.java
+++ b/src/main/java/org/apache/commons/jxpath/PackageFunctions.java
@@ -144,7 +144,7 @@ public class PackageFunctions implements Functions {
         }
         final String className = fullName.substring(0, inx);
         final String methodName = fullName.substring(inx + 1);
-        Class functionClass;
+        Class<?> functionClass;
         try {
             functionClass = ClassLoaderUtil.getClass(className, true);
         } catch (final ClassNotFoundException ex) {
diff --git a/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java b/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
index 549ef2a..f3580a0 100644
--- a/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
+++ b/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
@@ -125,8 +125,7 @@ public class JXPathContextReferenceImpl extends JXPathContext {
             } catch (final ClassNotFoundException ex) {
                 return null;
             }
-            final Class<NodePointerFactory> cls = ClassLoaderUtil.getClass(className, true);
-            return cls.getConstructor().newInstance();
+            return ClassLoaderUtil.getClass(className, true).getConstructor().newInstance();
         } catch (final Exception ex) {
             throw new JXPathException("Cannot allocate " + className, ex);
         }
diff --git a/src/main/java/org/apache/commons/jxpath/util/ClassLoaderUtil.java b/src/main/java/org/apache/commons/jxpath/util/ClassLoaderUtil.java
index 9e40bac..7311436 100644
--- a/src/main/java/org/apache/commons/jxpath/util/ClassLoaderUtil.java
+++ b/src/main/java/org/apache/commons/jxpath/util/ClassLoaderUtil.java
@@ -62,12 +62,13 @@ public class ClassLoaderUtil {
      * Returns the (initialized) class represented by {@code className} using the {@code classLoader}. This implementation supports names like
      * "{@code java.lang.String[]}" as well as "{@code [Ljava.lang.String;}".
      *
+     * @param <T> The expected class type.
      * @param classLoader the class loader to use to load the class
      * @param className   the class name
      * @return the class represented by {@code className} using the {@code classLoader}
      * @throws ClassNotFoundException if the class is not found
      */
-    public static Class getClass(final ClassLoader classLoader, final String className) throws ClassNotFoundException {
+    public static <T> Class<T> getClass(final ClassLoader classLoader, final String className) throws ClassNotFoundException {
         return getClass(classLoader, className, true);
     }
 
@@ -76,19 +77,21 @@ public class ClassLoaderUtil {
      * Returns the class represented by {@code className} using the {@code classLoader}. This implementation supports names like "{@code java.lang.String[]}" as
      * well as "{@code [Ljava.lang.String;}".
      *
+     * @param <T> The expected class type.
      * @param classLoader the class loader to use to load the class
      * @param className   the class name
      * @param initialize  whether the class must be initialized
      * @return the class represented by {@code className} using the {@code classLoader}
      * @throws ClassNotFoundException if the class is not found
      */
-    public static Class getClass(final ClassLoader classLoader, final String className, final boolean initialize) throws ClassNotFoundException {
-        Class clazz;
+    @SuppressWarnings("unchecked") // assume the call site knows what it's doing.
+    public static <T> Class<T> getClass(final ClassLoader classLoader, final String className, final boolean initialize) throws ClassNotFoundException {
+        Class<T> clazz;
         if (abbreviationMap.containsKey(className)) {
             final String clsName = "[" + abbreviationMap.get(className);
-            clazz = Class.forName(clsName, initialize, classLoader).getComponentType();
+            clazz = (Class<T>) Class.forName(clsName, initialize, classLoader).getComponentType();
         } else {
-            clazz = Class.forName(toCanonicalName(className), initialize, classLoader);
+            clazz = (Class<T>) Class.forName(toCanonicalName(className), initialize, classLoader);
         }
         return clazz;
     }
@@ -97,11 +100,12 @@ public class ClassLoaderUtil {
      * Returns the (initialized) class represented by {@code className} using the current thread's context class loader. This implementation supports names like
      * "{@code java.lang.String[]}" as well as "{@code [Ljava.lang.String;}".
      *
+     * @param <T> The expected class type.
      * @param className the class name
      * @return the class represented by {@code className} using the current thread's context class loader
      * @throws ClassNotFoundException if the class is not found
      */
-    public static Class getClass(final String className) throws ClassNotFoundException {
+    public static <T> Class<T> getClass(final String className) throws ClassNotFoundException {
         return getClass(className, true);
     }
 
@@ -109,12 +113,13 @@ public class ClassLoaderUtil {
      * Returns the class represented by {@code className} using the current thread's context class loader. This implementation supports names like
      * "{@code java.lang.String[]}" as well as "{@code [Ljava.lang.String;}".
      *
+     * @param <T> The expected class type.
      * @param className  the class name
      * @param initialize whether the class must be initialized
      * @return the class represented by {@code className} using the current thread's context class loader
      * @throws ClassNotFoundException if the class is not found
      */
-    public static Class getClass(final String className, final boolean initialize) throws ClassNotFoundException {
+    public static <T> Class<T> getClass(final String className, final boolean initialize) throws ClassNotFoundException {
         final ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
         final ClassLoader currentCL = ClassLoaderUtil.class.getClassLoader();
         if (contextCL != null) {
diff --git a/src/main/java/org/apache/commons/jxpath/xml/DocumentContainer.java b/src/main/java/org/apache/commons/jxpath/xml/DocumentContainer.java
index c4ad189..d8aad23 100644
--- a/src/main/java/org/apache/commons/jxpath/xml/DocumentContainer.java
+++ b/src/main/java/org/apache/commons/jxpath/xml/DocumentContainer.java
@@ -60,8 +60,7 @@ public class DocumentContainer extends XMLParser2 implements Container {
                 throw new JXPathException("Unsupported XML model: " + model);
             }
             try {
-                final Class<XMLParser> clazz = ClassLoaderUtil.getClass(className, true);
-                return clazz.getConstructor().newInstance();
+                return ClassLoaderUtil.<XMLParser>getClass(className, true).getConstructor().newInstance();
             } catch (final Exception ex) {
                 throw new JXPathException("Cannot allocate XMLParser: " + className, ex);
             }


(commons-jxpath) 02/06: org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.iteratePointers(String) now uses generics

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jxpath.git

commit b2e40bafdca3de5f86e7cef01134b6fcecad0a98
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat Apr 12 09:56:25 2025 -0400

    org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.iteratePointers(String)
    now uses generics
---
 src/changes/changes.xml                                                 | 1 +
 .../java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java   | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 0ab0a20..2b3d637 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -135,6 +135,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="fix" due-to="Gary Gregory">ExpressionContext.getContextNodeList() now uses generics.</action>
       <action dev="ggregory" type="fix" due-to="Gary Gregory">BasicTypeConverter.unmodifiableCollection(Collection) now uses generics.</action>
       <action dev="ggregory" type="fix" due-to="Gary Gregory. PMD">Fix PMD AvoidDecimalLiteralsInBigDecimalConstructor in org.apache.commons.jxpath.util.BasicTypeConverter.allocateNumber(Class, double).</action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.iteratePointers(String) now uses generics.</action>
       <!-- ADD -->
       <action issue="JXPATH-123" dev="mbenson" type="add">
         XPath function "ends-with" is not implemented (although "starts-with" is).
diff --git a/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java b/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
index e28960e..593aab7 100644
--- a/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
+++ b/src/main/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
@@ -637,7 +637,7 @@ public class JXPathContextReferenceImpl extends JXPathContext {
      * @return Iterator
      */
     @Override
-    public Iterator iteratePointers(final String xpath) {
+    public Iterator<Pointer> iteratePointers(final String xpath) {
         return iteratePointers(xpath, compileExpression(xpath));
     }