Author: arunpatidar
Date: Fri Aug 5 15:38:00 2016 New Revision: 1755348 URL: http://svn.apache.org/viewvc?rev=1755348&view=rev Log: Applied patch from jira issue - OFBIZ-7810 - Enforce noninstantiability to UelUtil class. Thanks Rohit Koushal and Rishi Solanki for your contribution. Modified: ofbiz/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleMapAccessor.java ofbiz/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelUtil.java Modified: ofbiz/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleMapAccessor.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleMapAccessor.java?rev=1755348&r1=1755347&r2=1755348&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleMapAccessor.java (original) +++ ofbiz/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleMapAccessor.java Fri Aug 5 15:38:00 2016 @@ -137,11 +137,11 @@ public final class FlexibleMapAccessor<T 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<String, Object> writableMap = UtilGenerics.cast(base); Map<String, Object> writableMap = (Map<String, Object>) base; - writableMap.put(UelUtil.localizedMapLocaleKey, locale); + writableMap.put(UelUtil.getLocalizedMapLocaleKey(), locale); } Object obj = null; try { Modified: ofbiz/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelUtil.java?rev=1755348&r1=1755347&r2=1755348&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelUtil.java (original) +++ ofbiz/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelUtil.java Fri Aug 5 15:38:00 2016 @@ -47,11 +47,11 @@ import org.apache.ofbiz.base.util.UtilMi 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<String, Object> variables; - protected final VariableMapper variableMapper; - public BasicContext(Map<String, Object> context) { + private static class BasicContext extends ELContext { + private final Map<String, Object> variables; + private final VariableMapper variableMapper; + private BasicContext(Map<String, Object> 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<String, ? extends Object> variables; - protected final VariableMapper variableMapper; - public ReadOnlyContext(Map<String, ? extends Object> context) { + private static class ReadOnlyContext extends ELContext { + private final Map<String, ? extends Object> variables; + private final VariableMapper variableMapper; + private ReadOnlyContext(Map<String, ? extends Object> 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 <code>CompositeELResolver</code> 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 <code>ListELResolver</code> used to handle OFBiz * <code>List</code> 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 <code>MapELResolver</code> class used to accommodate * <code>LocalizedMap</code> instances. */ - protected static class ExtendedMapResolver extends MapELResolver { - public ExtendedMapResolver(boolean isReadOnly) { + private static class ExtendedMapResolver extends MapELResolver { + private ExtendedMapResolver(boolean isReadOnly) { super(isReadOnly); } @Override |
Free forum by Nabble | Edit this page |