You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by he...@apache.org on 2023/12/13 13:22:41 UTC
(commons-jexl) branch master updated: JEXL-412: module declares namespace;
This is an automated email from the ASF dual-hosted git repository.
henrib pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git
The following commit(s) were added to refs/heads/master by this push:
new 0b5883d2 JEXL-412: module declares namespace;
0b5883d2 is described below
commit 0b5883d21cb2f981f474c6047238998b0a6a916a
Author: henrib <he...@apache.org>
AuthorDate: Wed Dec 13 14:22:34 2023 +0100
JEXL-412: module declares namespace;
---
.../apache/commons/jexl3/parser/JexlParser.java | 30 ++++++++++++----------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java b/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java
index a5235a53..290e3c01 100644
--- a/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java
+++ b/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java
@@ -207,7 +207,7 @@ public abstract class JexlParser extends StringParser {
}
/**
- * Disables pragma feature is pragma-anywhere feature is disabled.
+ * Disables pragma feature if pragma-anywhere feature is disabled.
*/
protected void controlPragmaAnywhere() {
final JexlFeatures features = getFeatures();
@@ -411,7 +411,7 @@ public abstract class JexlParser extends StringParser {
/**
* Declares a local function.
* @param variable the identifier used to declare
- * @param token the variable name toekn
+ * @param token the variable name token
*/
protected void declareFunction(final ASTVar variable, final Token token) {
final String name = token.image;
@@ -545,19 +545,21 @@ public abstract class JexlParser extends StringParser {
if (pragmas == null) {
pragmas = new TreeMap<>();
}
- // declaring a namespace
- final Predicate<String> ns = features.namespaceTest();
- if (ns != null && key.startsWith(PRAGMA_JEXLNS)) {
- if (!features.supportsNamespacePragma()) {
- throwFeatureException(JexlFeatures.NS_PRAGMA, getToken(0));
- }
- // jexl.namespace.***
- final String nsname = key.substring(PRAGMA_JEXLNS.length());
- if (!nsname.isEmpty()) {
- if (namespaces == null) {
- namespaces = new HashSet<>();
+ // declaring a namespace or module
+ final String[] nsprefixes = { PRAGMA_JEXLNS, PRAGMA_MODULE };
+ for(String nsprefix : nsprefixes) {
+ if (key.startsWith(nsprefix)) {
+ if (!features.supportsNamespacePragma()) {
+ throwFeatureException(JexlFeatures.NS_PRAGMA, getToken(0));
}
- namespaces.add(nsname);
+ final String nsname = key.substring(nsprefix.length());
+ if (!nsname.isEmpty()) {
+ if (namespaces == null) {
+ namespaces = new HashSet<>();
+ }
+ namespaces.add(nsname);
+ }
+ break;
}
}
// merge new value into a set created on the fly if key is already mapped