/** * {@inheritDoc} */ @Override public <T> void setVariable(String key, T value, Class<? extends T> type) { ValueExpression valueExpression = expressionFactory.createValueExpression(value, type); VariableMapper variableMapper = elContext.getVariableMapper(); variableMapper.setVariable(key, valueExpression); }
/** * Removes page attributes that we have exposed and, if applicable, * restores them to their prior values (and scopes). */ private void unExposeVariables() { // "nested" variables are now simply removed if (itemId != null) { pageContext.removeAttribute(itemId, PageContext.PAGE_SCOPE); VariableMapper vm = pageContext.getELContext().getVariableMapper(); if (vm != null) vm.setVariable(itemId, oldMappedValue); } if (statusId != null) pageContext.removeAttribute(statusId, PageContext.PAGE_SCOPE); }
private Object evaluateFormatExpression(ELContext context, Object method, Object[] params) { if ( !FORMAT.equals( method ) ) { throw new ELException( "Wrong method name 'formatter#" + method + "' does not exist. Only formatter#format is supported." ); } if ( params.length == 0 ) { throw new ELException( "Invalid number of arguments to Formatter#format" ); } if ( !( params[0] instanceof String ) ) { throw new ELException( "The first argument to Formatter#format must be String" ); } FormatterWrapper formatterWrapper = (FormatterWrapper) context.getVariableMapper() .resolveVariable( FORMATTER ) .getValue( context ); Object[] formattingParameters = new Object[params.length - 1]; System.arraycopy( params, 1, formattingParameters, 0, params.length - 1 ); Object returnValue; try { returnValue = formatterWrapper.format( (String) params[0], formattingParameters ); context.setPropertyResolved( true ); } catch (IllegalFormatException e) { throw new ELException( "Error in Formatter#format call", e ); } return returnValue; }
public Object getValue(EvaluationContext ctx) throws ELException { VariableMapper varMapper = ctx.getVariableMapper(); if (varMapper != null) { ValueExpression expr = varMapper.resolveVariable(this.image); if (expr != null) { return expr.getValue(ctx.getELContext()); } } ctx.setPropertyResolved(false); return ctx.getELResolver().getValue(ctx, null, this.image); }
ValueExpression ve = null; if (varMapper != null) { ve = varMapper.resolveVariable(this.image); if (ve != null) { obj = ve.getValue(ctx); obj = ctx.getELResolver().getValue(ctx, null, this.image); + "' was null and was unable to invoke"); } else { throw new ELException( "Identity '" + this.image
/** * First tries to resolve agains the inner Map, then the wrapped * ValueExpression. * * @see javax.el.VariableMapper#resolveVariable(java.lang.String) */ public ValueExpression resolveVariable(String variable) { ValueExpression ve = null; try { if (this.vars != null) { ve = (ValueExpression) this.vars.get(variable); } if (ve == null) { return this.target.resolveVariable(variable); } return ve; } catch (StackOverflowError e) { throw new ELException("Could not Resolve Variable [Overflow]: " + variable, e); } }
public Object getAttribute(String name) { if (this.varMapper != null) { ValueExpression ve = this.varMapper.resolveVariable(name); if (ve != null) { return ve.getValue(this); } } return null; }
public boolean isReadOnly(EvaluationContext ctx) throws ELException { VariableMapper varMapper = ctx.getVariableMapper(); if (varMapper != null) { ValueExpression expr = varMapper.resolveVariable(this.image); if (expr != null) { return expr.isReadOnly(ctx.getELContext()); } } ctx.setPropertyResolved(false); return ctx.getELResolver().isReadOnly(ctx, null, this.image); }
public Class getType(EvaluationContext ctx) throws ELException { VariableMapper varMapper = ctx.getVariableMapper(); if (varMapper != null) { ValueExpression expr = varMapper.resolveVariable(this.image); if (expr != null) { return expr.getType(ctx.getELContext()); } } ctx.setPropertyResolved(false); return ctx.getELResolver().getType(ctx, null, this.image); }
public void setValue(EvaluationContext ctx, Object value) throws ELException { VariableMapper varMapper = ctx.getVariableMapper(); if (varMapper != null) { ValueExpression expr = varMapper.resolveVariable(this.image); if (expr != null) { expr.setValue(ctx.getELContext(), value); return; } } ctx.setPropertyResolved(false); ctx.getELResolver().setValue(ctx, null, this.image, value); }
public static void setValueVariable(PageContext pageContext, String variable, ValueExpression expression) { ELContextImpl elctxt = (ELContextImpl)pageContext.getELContext(); elctxt.getVariableMapper().setVariable(variable, expression); }
public ValueExpression resolveVariable(String variable) { ValueExpression expr = this.target.resolveVariable(variable); if (expr != null) { if (this.momento == null) { this.momento = new VariableMapperImpl(); } this.momento.setVariable(variable, expr); } return expr; }
private void doMapVariable(ValueExpression valueExpr) { VariableMapper mapper = pageContext.getELContext().getVariableMapper(); mapper.setVariable(_var, valueExpr); }
private <T> void variable(VariableMapper variables, String varName, T object, Class<T> objectClass) { ValueExpression variable = ef.createValueExpression(object, objectClass); variables.setVariable(varName, variable); }
@Override public ValueReference getValueReference(EvaluationContext ctx) { VariableMapper varMapper = ctx.getVariableMapper(); if (varMapper == null) { return null; } ValueExpression expr = varMapper.resolveVariable(this.image); if (expr == null) { return null; } return expr.getValueReference(ctx); }
private static Node checkUndefinedIdentifier(final Node node, final ELContext elContext, final Set<String> absentIdentifiers) { if (node instanceof AstIdentifier) { final String name = node.getImage(); final boolean hasVariable = elContext.getVariableMapper().resolveVariable(name) != null; if (!hasVariable && !absentIdentifiers.contains(name)) { return node; } } else { for (int i = 0; i < node.jjtGetNumChildren(); i++) { final Node result = checkUndefinedIdentifier(node.jjtGetChild(i), elContext, absentIdentifiers); if (result != null) { return result; } } } return null; }
/** * @see javax.el.VariableMapper#resolveVariable(java.lang.String) */ public ValueExpression resolveVariable(String name) { ValueExpression ve = this.var0.resolveVariable(name); if (ve == null) { return this.var1.resolveVariable(name); } return ve; }
/** * Removes page attributes that we have exposed and, if applicable, * restores them to their prior values (and scopes). */ private void unExposeVariables() { // "nested" variables are now simply removed if (itemId != null) { pageContext.removeAttribute(itemId, PageContext.PAGE_SCOPE); VariableMapper vm = pageContext.getELContext().getVariableMapper(); if (vm != null) vm.setVariable(itemId, null); } if (statusId != null) pageContext.removeAttribute(statusId, PageContext.PAGE_SCOPE); }
private Object evaluateFormatExpression(final ELContext context, final Object method, final Object[] params) { if(!FORMAT.equals(method)) { throw new ELException(String.format("Wrong method name 'formatter#%s' does not exist. Only formatter#format is supported.", method)); } if(params.length == 0) { throw new ELException("Invalid number of arguments to Formatter#format"); } if(!(params[0] instanceof String)) { throw new ELException("The first argument to Formatter#format must be String"); } final FormatterWrapper formatterWrapper = (FormatterWrapper)context.getVariableMapper() .resolveVariable(FORMATTER) .getValue(context); final Object[] formattingParameters = new Object[params.length - 1]; System.arraycopy( params, 1, formattingParameters, 0, params.length - 1 ); Object returnValue; try { returnValue = formatterWrapper.format( (String) params[0], formattingParameters ); context.setPropertyResolved(true); } catch (IllegalFormatException e) { throw new ELException("Error in Formatter#format call", e); } return returnValue; }
public Object getValue(EvaluationContext ctx) throws ELException { VariableMapper varMapper = ctx.getVariableMapper(); if (varMapper != null) { ValueExpression expr = varMapper.resolveVariable(this.image); if (expr != null) { return expr.getValue(ctx.getELContext()); } } ctx.setPropertyResolved(false); return ctx.getELResolver().getValue(ctx, null, this.image); }