Use generics to improve type safetyness.
authorrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 18 Sep 2008 17:03:38 +0000 (17:03 +0000)
committerrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 18 Sep 2008 17:03:38 +0000 (17:03 +0000)
Please check readExternal() in FunctionMapperImpl
and VariableMapperImpl. The type of the persisted
Map has changed. Does this pose a consistency
problem with other components or older, already
persisted Maps?

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@696714 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/el/lang/ExpressionBuilder.java
java/org/apache/el/lang/FunctionMapperImpl.java
java/org/apache/el/lang/VariableMapperImpl.java

index f6546aa..61d351c 100644 (file)
@@ -50,7 +50,7 @@ import org.apache.el.util.MessageFactory;
  */
 public final class ExpressionBuilder implements NodeVisitor {
 
-    private static final ConcurrentCache cache = new ConcurrentCache(5000);
+    private static final ConcurrentCache<String, Node> cache = new ConcurrentCache<String, Node>(5000);
 
     private FunctionMapper fnMapper;
 
@@ -87,7 +87,7 @@ public final class ExpressionBuilder implements NodeVisitor {
             throw new ELException(MessageFactory.get("error.null"));
         }
 
-        Node n = (Node) cache.get(expr);
+        Node n = cache.get(expr);
         if (n == null) {
             try {
                 n = (new ELParser(new StringReader(expr)))
index 4ca06cb..2c41820 100644 (file)
@@ -39,7 +39,7 @@ public class FunctionMapperImpl extends FunctionMapper implements
 
     private static final long serialVersionUID = 1L;
 
-    protected Map functions = null;
+    protected Map<String, Function> functions = null;
 
     /*
      * (non-Javadoc)
@@ -49,7 +49,7 @@ public class FunctionMapperImpl extends FunctionMapper implements
      */
     public Method resolveFunction(String prefix, String localName) {
         if (this.functions != null) {
-            Function f = (Function) this.functions.get(prefix + ":" + localName);
+            Function f = this.functions.get(prefix + ":" + localName);
             return f.getMethod();
         }
         return null;
@@ -57,7 +57,7 @@ public class FunctionMapperImpl extends FunctionMapper implements
 
     public void addFunction(String prefix, String localName, Method m) {
         if (this.functions == null) {
-            this.functions = new HashMap();
+            this.functions = new HashMap<String, Function>();
         }
         Function f = new Function(prefix, localName, m);
         synchronized (this) {
@@ -81,7 +81,7 @@ public class FunctionMapperImpl extends FunctionMapper implements
      */
     public void readExternal(ObjectInput in) throws IOException,
             ClassNotFoundException {
-        this.functions = (Map) in.readObject();
+        this.functions = (Map<String, Function>) in.readObject();
     }
 
     public static class Function implements Externalizable {
index d226175..765c60a 100644 (file)
@@ -31,23 +31,23 @@ public class VariableMapperImpl extends VariableMapper implements Externalizable
 
     private static final long serialVersionUID = 1L;
 
-    private Map vars = new HashMap();
+    private Map<String, ValueExpression> vars = new HashMap<String, ValueExpression>();
 
     public VariableMapperImpl() {
         super();
     }
 
     public ValueExpression resolveVariable(String variable) {
-        return (ValueExpression) this.vars.get(variable);
+        return this.vars.get(variable);
     }
 
     public ValueExpression setVariable(String variable,
             ValueExpression expression) {
-        return (ValueExpression) this.vars.put(variable, expression);
+        return this.vars.put(variable, expression);
     }
 
     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        this.vars = (Map) in.readObject();
+        this.vars = (Map<String, ValueExpression>) in.readObject();
     }
 
     public void writeExternal(ObjectOutput out) throws IOException {