diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleMapAccessor.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleMapAccessor.java index cd4a39af9d..bd5c96114b 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleMapAccessor.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleMapAccessor.java @@ -137,11 +137,11 @@ public final class FlexibleMapAccessor implements Serializable, IsEmpty { if (base == null || this.isEmpty) { return null; } - if (locale != null && !base.containsKey(UelUtil.localizedMapLocaleKey)) { + if (locale != null && !base.containsKey(UelUtil.getLocalizedMapLocaleKey())) { // This method is a hot spot, so placing the cast here instead of in another class. // Map writableMap = UtilGenerics.cast(base); Map writableMap = (Map) base; - writableMap.put(UelUtil.localizedMapLocaleKey, locale); + writableMap.put(UelUtil.getLocalizedMapLocaleKey(), locale); } Object obj = null; try { diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelUtil.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelUtil.java index a279e920f9..25f041b02d 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelUtil.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelUtil.java @@ -47,11 +47,11 @@ import org.apache.ofbiz.base.util.UtilMisc; import org.apache.ofbiz.base.util.collections.LocalizedMap; /** Implements the Unified Expression Language (JSR-245). */ -public class UelUtil { +public final class UelUtil { protected static final String module = UelUtil.class.getName(); - public static final String localizedMapLocaleKey = LocalizedMap.class.getName() + "_locale".replace(".", "_"); - protected static final ExpressionFactory exprFactory = JuelConnector.newExpressionFactory(); - protected static final ELResolver defaultResolver = new ExtendedCompositeResolver() { + private static final String localizedMapLocaleKey = LocalizedMap.class.getName() + "_locale".replace(".", "_"); + private static final ExpressionFactory exprFactory = JuelConnector.newExpressionFactory(); + private static final ELResolver defaultResolver = new ExtendedCompositeResolver() { { add(new ExtendedMapResolver(false)); add(new ExtendedListResolver(false)); @@ -61,7 +61,13 @@ public class UelUtil { add(new BeanELResolver(false)); } }; - + + private UelUtil () {} + + public static String getLocalizedMapLocaleKey() { + return localizedMapLocaleKey; + } + /** Evaluates a Unified Expression Language expression and returns the result. * @param context Evaluation context (variables) * @param expression UEL expression @@ -116,10 +122,10 @@ public class UelUtil { ve.setValue(elContext, null); } - protected static class BasicContext extends ELContext { - protected final Map variables; - protected final VariableMapper variableMapper; - public BasicContext(Map context) { + private static class BasicContext extends ELContext { + private final Map variables; + private final VariableMapper variableMapper; + private BasicContext(Map context) { this.variableMapper = new BasicVariableMapper(this); this.variables = context; } @@ -137,10 +143,10 @@ public class UelUtil { } } - protected static class ReadOnlyContext extends ELContext { - protected final Map variables; - protected final VariableMapper variableMapper; - public ReadOnlyContext(Map context) { + private static class ReadOnlyContext extends ELContext { + private final Map variables; + private final VariableMapper variableMapper; + private ReadOnlyContext(Map context) { this.variableMapper = new ReadOnlyVariableMapper(this); this.variables = UtilGenerics.cast(context); } @@ -156,9 +162,9 @@ public class UelUtil { public VariableMapper getVariableMapper() { return this.variableMapper; } - protected static class ReadOnlyVariableMapper extends VariableMapper { - protected final ReadOnlyContext elContext; - protected ReadOnlyVariableMapper(ReadOnlyContext elContext) { + private static class ReadOnlyVariableMapper extends VariableMapper { + private final ReadOnlyContext elContext; + private ReadOnlyVariableMapper(ReadOnlyContext elContext) { this.elContext = elContext; } @Override @@ -176,9 +182,9 @@ public class UelUtil { } } - protected static class BasicVariableMapper extends VariableMapper { - protected final BasicContext elContext; - protected BasicVariableMapper(BasicContext elContext) { + private static class BasicVariableMapper extends VariableMapper { + private final BasicContext elContext; + private BasicVariableMapper(BasicContext elContext) { this.elContext = elContext; } @@ -207,9 +213,9 @@ public class UelUtil { } @SuppressWarnings("serial") - protected static class ReadOnlyExpression extends ValueExpression { - protected final Object object; - protected ReadOnlyExpression(Object object) { + private static class ReadOnlyExpression extends ValueExpression { + private final Object object; + private ReadOnlyExpression(Object object) { this.object = object; } @@ -268,10 +274,10 @@ public class UelUtil { } @SuppressWarnings("serial") - protected static class BasicValueExpression extends ValueExpression { - protected final BasicContext elContext; - protected final String varName; - public BasicValueExpression(String varName, BasicContext elContext) { + private static class BasicValueExpression extends ValueExpression { + private final BasicContext elContext; + private final String varName; + private BasicValueExpression(String varName, BasicContext elContext) { this.elContext = elContext; this.varName = varName; } @@ -328,7 +334,7 @@ public class UelUtil { /** Custom CompositeELResolver used to handle variable * auto-vivify. */ - protected static class ExtendedCompositeResolver extends CompositeELResolver { + private static class ExtendedCompositeResolver extends CompositeELResolver { @Override public void setValue(ELContext context, Object base, Object property, Object val) { super.setValue(context, base, property, val); @@ -348,9 +354,9 @@ public class UelUtil { /** Custom ListELResolver used to handle OFBiz * List syntax. */ - protected static class ExtendedListResolver extends ListELResolver { - protected boolean isReadOnly; - public ExtendedListResolver(boolean isReadOnly) { + private static class ExtendedListResolver extends ListELResolver { + private boolean isReadOnly; + private ExtendedListResolver(boolean isReadOnly) { super(isReadOnly); this.isReadOnly = isReadOnly; } @@ -397,8 +403,8 @@ public class UelUtil { /** Custom MapELResolver class used to accommodate * LocalizedMap instances. */ - protected static class ExtendedMapResolver extends MapELResolver { - public ExtendedMapResolver(boolean isReadOnly) { + private static class ExtendedMapResolver extends MapELResolver { + private ExtendedMapResolver(boolean isReadOnly) { super(isReadOnly); } @Override