1 17 package org.apache.jasper.el; 18 19 import java.lang.reflect.Method ; 20 import java.util.HashMap ; 21 import java.util.Map ; 22 23 import javax.el.ELContext; 24 import javax.el.ELResolver; 25 import javax.el.FunctionMapper; 26 import javax.el.ValueExpression; 27 import javax.el.VariableMapper; 28 29 34 public final class ELContextImpl extends ELContext { 35 36 private final static FunctionMapper NullFunctionMapper = new FunctionMapper() { 37 public Method resolveFunction(String prefix, String localName) { 38 return null; 39 } 40 }; 41 42 private final static class VariableMapperImpl extends VariableMapper { 43 44 private Map <String , ValueExpression> vars; 45 46 public ValueExpression resolveVariable(String variable) { 47 if (vars == null) { 48 return null; 49 } 50 return vars.get(variable); 51 } 52 53 public ValueExpression setVariable(String variable, 54 ValueExpression expression) { 55 if (vars == null) 56 vars = new HashMap <String , ValueExpression>(); 57 return vars.put(variable, expression); 58 } 59 60 } 61 62 private final ELResolver resolver; 63 64 private FunctionMapper functionMapper = NullFunctionMapper; 66 private VariableMapper variableMapper; 67 68 public ELContextImpl() { 69 this(ELResolverImpl.DefaultResolver); 70 } 71 72 public ELContextImpl(ELResolver resolver) { 73 this.resolver = resolver; 74 } 75 76 public ELResolver getELResolver() { 77 return this.resolver; 78 } 79 80 public FunctionMapper getFunctionMapper() { 81 return this.functionMapper; 82 } 83 84 public VariableMapper getVariableMapper() { 85 if (this.variableMapper == null) { 86 this.variableMapper = new VariableMapperImpl(); 87 } 88 return this.variableMapper; 89 } 90 91 public void setFunctionMapper(FunctionMapper functionMapper) { 92 this.functionMapper = functionMapper; 93 } 94 95 public void setVariableMapper(VariableMapper variableMapper) { 96 this.variableMapper = variableMapper; 97 } 98 99 } 100 | Popular Tags |