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/03/17 18:52:45 UTC

(commons-jxpath) branch master updated (df44300 -> cdee263)

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 df44300  Next version will be 1.4.0
     new c3008da  Functions.getUsedNamespaces() is now typed with generics
     new cdee263  Internal refactorings using generics

The 2 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                            |  1 +
 .../org/apache/commons/jxpath/ClassFunctions.java  |  2 +-
 .../org/apache/commons/jxpath/FunctionLibrary.java | 44 +++++++++++-----------
 .../java/org/apache/commons/jxpath/Functions.java  | 10 ++---
 .../apache/commons/jxpath/PackageFunctions.java    |  2 +-
 5 files changed, 29 insertions(+), 30 deletions(-)


(commons-jxpath) 01/02: Functions.getUsedNamespaces() is now typed with 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 c3008daf0fc4358f7d9f250934e62e8cd2b3795c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Mar 17 14:45:47 2025 -0400

    Functions.getUsedNamespaces() is now typed with generics
---
 src/changes/changes.xml                                       |  1 +
 src/main/java/org/apache/commons/jxpath/ClassFunctions.java   |  2 +-
 src/main/java/org/apache/commons/jxpath/FunctionLibrary.java  |  8 ++++----
 src/main/java/org/apache/commons/jxpath/Functions.java        | 10 +++++-----
 src/main/java/org/apache/commons/jxpath/PackageFunctions.java |  2 +-
 5 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 360ee7d..84de454 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -115,6 +115,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="fix" due-to="Gary Gregory">Deprecate TypeUtils.TypeUtils().</action>
       <action dev="ggregory" type="fix" due-to="Gary Gregory">Deprecate ValueUtils.ValueUtils().</action>
       <action dev="ggregory" type="fix" due-to="Gary Gregory">PageScopeContext.getAttributeNames() is now typed with generics.</action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">Functions.getUsedNamespaces() is now typed with 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/ClassFunctions.java b/src/main/java/org/apache/commons/jxpath/ClassFunctions.java
index a5c8af3..d5c9cf6 100644
--- a/src/main/java/org/apache/commons/jxpath/ClassFunctions.java
+++ b/src/main/java/org/apache/commons/jxpath/ClassFunctions.java
@@ -111,7 +111,7 @@ public class ClassFunctions implements Functions {
      * @return a singleton
      */
     @Override
-    public Set getUsedNamespaces() {
+    public Set<String> getUsedNamespaces() {
         return Collections.singleton(namespace);
     }
 }
diff --git a/src/main/java/org/apache/commons/jxpath/FunctionLibrary.java b/src/main/java/org/apache/commons/jxpath/FunctionLibrary.java
index fec869c..8530f5e 100644
--- a/src/main/java/org/apache/commons/jxpath/FunctionLibrary.java
+++ b/src/main/java/org/apache/commons/jxpath/FunctionLibrary.java
@@ -56,9 +56,9 @@ public class FunctionLibrary implements Functions {
             final int count = allFunctions.size();
             for (int i = 0; i < count; i++) {
                 final Functions funcs = (Functions) allFunctions.get(i);
-                final Set namespaces = funcs.getUsedNamespaces();
-                for (final Iterator it = namespaces.iterator(); it.hasNext();) {
-                    final String ns = (String) it.next();
+                final Set<String> namespaces = funcs.getUsedNamespaces();
+                for (final Iterator<String> it = namespaces.iterator(); it.hasNext();) {
+                    final String ns = it.next();
                     final Object candidates = byNamespace.get(ns);
                     if (candidates == null) {
                         byNamespace.put(ns, funcs);
@@ -109,7 +109,7 @@ public class FunctionLibrary implements Functions {
      * @return Set
      */
     @Override
-    public Set getUsedNamespaces() {
+    public Set<String> getUsedNamespaces() {
         return functionCache().keySet();
     }
 
diff --git a/src/main/java/org/apache/commons/jxpath/Functions.java b/src/main/java/org/apache/commons/jxpath/Functions.java
index fde11c8..c55d733 100644
--- a/src/main/java/org/apache/commons/jxpath/Functions.java
+++ b/src/main/java/org/apache/commons/jxpath/Functions.java
@@ -26,7 +26,7 @@ import java.util.Set;
 public interface Functions {
 
     /**
-     * Returns a Function, if any, for the specified namespace, name and parameter types.
+     * Gets a Function, if any, for the specified namespace, name and parameter types.
      * 
      * @param namespace  ns
      * @param name       function name
@@ -36,9 +36,9 @@ public interface Functions {
     Function getFunction(String namespace, String name, Object[] parameters);
 
     /**
-     * Returns all namespaces in which this function collection defines functions.
-     * 
-     * @return Set
+     * Gets all namespaces in which this function collection defines functions.
+     *
+     * @return all namespaces in which this function collection defines functions.
      */
-    Set getUsedNamespaces();
+    Set<String> getUsedNamespaces();
 }
diff --git a/src/main/java/org/apache/commons/jxpath/PackageFunctions.java b/src/main/java/org/apache/commons/jxpath/PackageFunctions.java
index e23ea81..089cd42 100644
--- a/src/main/java/org/apache/commons/jxpath/PackageFunctions.java
+++ b/src/main/java/org/apache/commons/jxpath/PackageFunctions.java
@@ -170,7 +170,7 @@ public class PackageFunctions implements Functions {
      * @return (singleton) namespace Set
      */
     @Override
-    public Set getUsedNamespaces() {
+    public Set<String> getUsedNamespaces() {
         return Collections.singleton(namespace);
     }
 }


(commons-jxpath) 02/02: Internal refactorings using 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 cdee2636992e730233c269ffb8133b9368336055
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Mar 17 14:52:40 2025 -0400

    Internal refactorings using generics
    
    Use for-each loop
---
 .../org/apache/commons/jxpath/FunctionLibrary.java | 40 ++++++++++------------
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/src/main/java/org/apache/commons/jxpath/FunctionLibrary.java b/src/main/java/org/apache/commons/jxpath/FunctionLibrary.java
index 8530f5e..8572666 100644
--- a/src/main/java/org/apache/commons/jxpath/FunctionLibrary.java
+++ b/src/main/java/org/apache/commons/jxpath/FunctionLibrary.java
@@ -19,7 +19,6 @@ package org.apache.commons.jxpath;
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -30,12 +29,12 @@ import java.util.Set;
  */
 public class FunctionLibrary implements Functions {
 
-    private final List allFunctions = new ArrayList();
-    private Map byNamespace;
+    private final List<Functions> allFunctions = new ArrayList<>();
+    private Map<String, Object> byNamespace;
 
     /**
      * Add functions to the library
-     * 
+     *
      * @param functions to add
      */
     public void addFunctions(final Functions functions) {
@@ -47,23 +46,22 @@ public class FunctionLibrary implements Functions {
 
     /**
      * Prepare the cache.
-     * 
+     *
      * @return cache map keyed by namespace
      */
-    private synchronized Map functionCache() {
+    private synchronized Map<String, Object> functionCache() {
         if (byNamespace == null) {
-            byNamespace = new HashMap();
+            byNamespace = new HashMap<>();
             final int count = allFunctions.size();
             for (int i = 0; i < count; i++) {
-                final Functions funcs = (Functions) allFunctions.get(i);
+                final Functions funcs = allFunctions.get(i);
                 final Set<String> namespaces = funcs.getUsedNamespaces();
-                for (final Iterator<String> it = namespaces.iterator(); it.hasNext();) {
-                    final String ns = it.next();
+                for (final String ns : namespaces) {
                     final Object candidates = byNamespace.get(ns);
                     if (candidates == null) {
                         byNamespace.put(ns, funcs);
                     } else if (candidates instanceof Functions) {
-                        final List lst = new ArrayList();
+                        final List<Object> lst = new ArrayList<>();
                         lst.add(candidates);
                         lst.add(funcs);
                         byNamespace.put(ns, lst);
@@ -77,8 +75,8 @@ public class FunctionLibrary implements Functions {
     }
 
     /**
-     * Returns a Function, if any, for the specified namespace, name and parameter types.
-     * 
+     * Gets a Function, if any, for the specified namespace, name and parameter types.
+     *
      * @param namespace  function namespace
      * @param name       function name
      * @param parameters parameters
@@ -91,10 +89,10 @@ public class FunctionLibrary implements Functions {
             return ((Functions) candidates).getFunction(namespace, name, parameters);
         }
         if (candidates instanceof List) {
-            final List list = (List) candidates;
+            final List<Functions> list = (List<Functions>) candidates;
             final int count = list.size();
             for (int i = 0; i < count; i++) {
-                final Function function = ((Functions) list.get(i)).getFunction(namespace, name, parameters);
+                final Function function = list.get(i).getFunction(namespace, name, parameters);
                 if (function != null) {
                     return function;
                 }
@@ -104,9 +102,9 @@ public class FunctionLibrary implements Functions {
     }
 
     /**
-     * Returns a set containing all namespaces used by the aggregated Functions.
-     * 
-     * @return Set
+     * Gets a set containing all namespaces used by the aggregated Functions.
+     *
+     * @return a set containing all namespaces used by the aggregated Functions.
      */
     @Override
     public Set<String> getUsedNamespaces() {
@@ -114,9 +112,9 @@ public class FunctionLibrary implements Functions {
     }
 
     /**
-     * Remove functions from the library.
-     * 
-     * @param functions to remove
+     * Removes functions from the library.
+     *
+     * @param functions to remove.
      */
     public void removeFunctions(final Functions functions) {
         allFunctions.remove(functions);