@Override protected boolean isVisible( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue) { final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(context.getConfiguration()); final IStandardExpression expression = expressionParser.parseExpression(context, attributeValue); final Object value = expression.execute(context); return !EvaluationUtils.evaluateAsBoolean(value); }
throw new TemplateProcessingException("Expression content is null, which is not allowed"); (useSelectionAsRoot && templateContext != null && templateContext.hasSelectionTarget()? templateContext.getSelectionTarget() : templateContext); StandardExpressions.getConversionService(configuration); throw new TemplateProcessingException( "Exception evaluating OGNL expression: \"" + expression.getExpression() + "\"", e);
StandardExpressions.getVariableExpressionEvaluator(context.getConfiguration()); leftValue = leftExpr.execute(context, expContext); rightValue = rightExpr.execute(context, expContext);
EscapedAttributeUtils.unescapeAttribute(context.getTemplateMode(), attribute.getValue()); final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(context.getConfiguration()); if (attributeValue != null) { final IStandardExpression expression = expressionParser.parseExpression(context, attributeValue); expressionResult = expression.execute(context, StandardExpressionExecutionContext.RESTRICTED); if (!e.hasTemplateName()) { e.setTemplateName(tag.getTemplateName()); if (!e.hasLineAndCol()) { e.setLineAndCol(attribute.getLine(), attribute.getCol());
public static Object evaluate(IExpressionContext context, String expressionValue) { final String value = String.valueOf(expressionValue).trim(); final IStandardExpressionParser expressionParser = StandardExpressions .getExpressionParser(context.getConfiguration()); final IStandardExpression expression = expressionParser.parseExpression(context, value); return expression.execute(context); }
public static IThymeleafBindStatus getBindStatus( final IExpressionContext context, final boolean optional, final String expression) { Validate.notNull(expression, "Expression cannot be null"); if (GLOBAL_EXPRESSION.equals(expression) || ALL_EXPRESSION.equals(expression) || ALL_FIELDS.equals(expression)) { // If "global", "all" or "*" are used without prefix, they must be inside a form, so we add *{...} final String completeExpression = "*{" + expression + "}"; return getBindStatus(context, optional, completeExpression); } final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(context.getConfiguration()); final IStandardExpression expressionObj = expressionParser.parseExpression(context, expression); if (expressionObj == null) { throw new TemplateProcessingException( "Expression \"" + expression + "\" is not valid: cannot perform Spring bind"); } if (expressionObj instanceof SelectionVariableExpression) { final String bindExpression = ((SelectionVariableExpression)expressionObj).getExpression(); return getBindStatusFromParsedExpression(context, optional, true, bindExpression); } if (expressionObj instanceof VariableExpression) { final String bindExpression = ((VariableExpression)expressionObj).getExpression(); return getBindStatusFromParsedExpression(context, optional, false, bindExpression); } throw new TemplateProcessingException( "Expression \"" + expression + "\" is not valid: only variable expressions ${...} or " + "selection expressions *{...} are allowed in Spring field bindings"); }
/** * @since 2.0.9 * @deprecated the StandardExpressionProcessor class was deprecated in 2.1.0 for semantic and refactoring reasons. * Should use the equivalent {@link StandardExpressions} instead if you want to obtain * parser instances registered by the standard dialects, or instance your * parser instances using their constructors directly if you are building your own dialect * including these parserss. As for expression execution, this is no longer managed by executor * objects (also deprecated) but by the expressions themselves. Will be removed in 3.0. */ @Deprecated public static Expression parseExpression(final Configuration configuration, final IProcessingContext processingContext, final String input) { final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(configuration); return (Expression) expressionParser.parseExpression(configuration, processingContext, input); }
(StandardSwitchTagProcessor.SwitchStructure) context.getVariable(StandardSwitchTagProcessor.SWITCH_VARIABLE_NAME); throw new TemplateProcessingException( "Cannot specify a \"" + attributeName + "\" attribute in an environment where no " + "switch operator has been defined before."); new Object[] {TemplateEngine.threadIndex(), LoggingUtils.loggifyTemplateName(context.getTemplateData().getTemplate()), attributeValue, attributeName, attributeValue, Boolean.TRUE}); final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(context.getConfiguration()); expressionParser.parseExpression(context, attributeValue);
private static IStandardExpression parseAttributeExpression(final ITemplateContext context, final String attributeValue) { final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(context.getConfiguration()); return expressionParser.parseExpression(context, attributeValue); }
StandardExpressions.getExpressionParser(context.getConfiguration());
final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(context.getConfiguration()); if (!(expressionParser instanceof StandardExpressionParser)) { final Object result = expression.execute(context, StandardExpressionExecutionContext.RESTRICTED);
StandardExpressions.getConversionService(configuration); throw new TemplateProcessingException( "Exception evaluating OGNL expression: \"" + expression + "\"", e);
public Object convert(final Object target, final Class<?> clazz) { final IStandardConversionService conversionService = StandardExpressions.getConversionService(this.context.getConfiguration()); return conversionService.convert(this.context, target, clazz); }
public Object execute( final IExpressionContext context, final StandardExpressionExecutionContext expContext) { Validate.notNull(context, "Context cannot be null"); final IStandardVariableExpressionEvaluator variableExpressionEvaluator = StandardExpressions.getVariableExpressionEvaluator(context.getConfiguration()); final Object result = execute(context, this, variableExpressionEvaluator, expContext); return LiteralValue.unwrap(result); }
private void processDataAttribute(ITemplateContext context, IProcessableElementTag tag, IAttribute attribute, IElementTagStructureHandler structureHandler) { try { AttributeName attributeName = attribute.getAttributeDefinition().getAttributeName(); String attributeValue = EscapedAttributeUtils.unescapeAttribute(context.getTemplateMode(), attribute.getValue()); IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(context.getConfiguration()); IStandardExpression expression = expressionParser.parseExpression(context, attributeValue); expressionResult = expression.execute(context); } else { expressionResult = null; if (!e.hasTemplateName()) { e.setTemplateName(tag.getTemplateName()); if (!e.hasLineAndCol()) { e.setLineAndCol(attribute.getLine(), attribute.getCol());
public static Object evaluate(IExpressionContext context, String expressionValue) { final String value = String.valueOf(expressionValue).trim(); final IStandardExpressionParser expressionParser = StandardExpressions .getExpressionParser(context.getConfiguration()); final IStandardExpression expression = expressionParser.parseExpression(context, value); return expression.execute(context); }
public static BindStatus getBindStatus( final IExpressionContext context, final boolean optional, final String expression) { Validate.notNull(expression, "Expression cannot be null"); if (GLOBAL_EXPRESSION.equals(expression) || ALL_EXPRESSION.equals(expression) || ALL_FIELDS.equals(expression)) { // If "global", "all" or "*" are used without prefix, they must be inside a form, so we add *{...} final String completeExpression = "*{" + expression + "}"; return getBindStatus(context, optional, completeExpression); } final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(context.getConfiguration()); final IStandardExpression expressionObj = expressionParser.parseExpression(context, expression); if (expressionObj == null) { throw new TemplateProcessingException( "Expression \"" + expression + "\" is not valid: cannot perform Spring bind"); } if (expressionObj instanceof SelectionVariableExpression) { final String bindExpression = ((SelectionVariableExpression)expressionObj).getExpression(); return getBindStatusFromParsedExpression(context, optional, true, bindExpression); } if (expressionObj instanceof VariableExpression) { final String bindExpression = ((VariableExpression)expressionObj).getExpression(); return getBindStatusFromParsedExpression(context, optional, false, bindExpression); } throw new TemplateProcessingException( "Expression \"" + expression + "\" is not valid: only variable expressions ${...} or " + "selection expressions *{...} are allowed in Spring field bindings"); }
/** * @deprecated the StandardExpressionProcessor class was deprecated in 2.1.0 for semantic and refactoring reasons. * Should use the equivalent {@link StandardExpressions} instead if you want to obtain * parser instances registered by the standard dialects, or instance your * parser instances using their constructors directly if you are building your own dialect * including these parserss. As for expression execution, this is no longer managed by executor * objects (also deprecated) but by the expressions themselves. Will be removed in 3.0. */ @Deprecated public static Expression parseExpression(final Arguments arguments, final String input) { final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(arguments.getConfiguration()); return (Expression) expressionParser.parseExpression(arguments.getConfiguration(), arguments, input); }
@Override protected void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final IElementTagStructureHandler structureHandler) { final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(context.getConfiguration()); final IStandardExpression switchExpression = expressionParser.parseExpression(context, attributeValue); structureHandler.setLocalVariable(SWITCH_VARIABLE_NAME, new SwitchStructure(switchExpression)); }
/** * obtain standard expression parser * @param context Template context * @return standard expression parser */ IStandardExpressionParser getParser(final ITemplateContext context) { final IEngineConfiguration configuration = context.getConfiguration(); return StandardExpressions.getExpressionParser(configuration); } }