public Each parseEach( final IExpressionContext context, final String input) { Validate.notNull(context, "Context cannot be null"); Validate.notNull(input, "Input cannot be null"); return EachUtils.parseEach(context, input); }
static Each internalParseEach(final String input) { if (StringUtils.isEmptyOrWhitespace(input)) { return null; } final ExpressionParsingState decomposition = ExpressionParsingUtil.decompose(input); if (decomposition == null) { return null; } return composeEach(decomposition, 0); }
public static Each parseEach( final IExpressionContext context, final String input) { Validate.notNull(context, "Context cannot be null"); Validate.notNull(input, "Input cannot be null"); final String preprocessedInput = StandardExpressionPreprocessor.preprocess(context, input); final IEngineConfiguration configuration = context.getConfiguration(); if (configuration != null) { final Each cachedEach = ExpressionCache.getEachFromCache(configuration, preprocessedInput); if (cachedEach != null) { return cachedEach; } } final Each each = internalParseEach(preprocessedInput.trim()); if (each == null) { throw new TemplateProcessingException("Could not parse as each: \"" + input + "\""); } if (configuration != null) { ExpressionCache.putEachIntoCache(configuration, preprocessedInput, each); } return each; }
@Override protected void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final IElementTagStructureHandler structureHandler) { final Each each = EachUtils.parseEach(context, attributeValue); final IStandardExpression iterVarExpr = each.getIterVar(); final Object iterVarValue = iterVarExpr.execute(context); final IStandardExpression statusVarExpr = each.getStatusVar(); final Object statusVarValue; if (statusVarExpr != null) { statusVarValue = statusVarExpr.execute(context); } else { statusVarValue = null; // Will provoke the default behaviour: iterVarValue + 'Stat' } final IStandardExpression iterableExpr = each.getIterable(); final Object iteratedValue = iterableExpr.execute(context); final String iterVarName = (iterVarValue == null? null : iterVarValue.toString()); if (StringUtils.isEmptyOrWhitespace(iterVarName)) { throw new TemplateProcessingException( "Iteration variable name expression evaluated as null: \"" + iterVarExpr + "\""); } final String statusVarName = (statusVarValue == null? null : statusVarValue.toString()); if (statusVarExpr != null && StringUtils.isEmptyOrWhitespace(statusVarName)) { throw new TemplateProcessingException( "Status variable name expression evaluated as null or empty: \"" + statusVarExpr + "\""); } structureHandler.iterateElement(iterVarName, statusVarName, iteratedValue); }
return composeEach(state, pointer);
public static Each parseEach( final Configuration configuration, final IProcessingContext processingContext, final String input) { Validate.notNull(configuration, "Configuration cannot be null"); Validate.notNull(processingContext, "Processing Context cannot be null"); Validate.notNull(input, "Input cannot be null"); final String preprocessedInput = StandardExpressionPreprocessor.preprocess(configuration, processingContext, input); if (configuration != null) { final Each cachedEach = ExpressionCache.getEachFromCache(configuration, preprocessedInput); if (cachedEach != null) { return cachedEach; } } final Each each = internalParseEach(preprocessedInput.trim()); if (each == null) { throw new TemplateProcessingException("Could not parse as each: \"" + input + "\""); } if (configuration != null) { ExpressionCache.putEachIntoCache(configuration, preprocessedInput, each); } return each; }
/** * @since 2.0.9 */ public Each parseEach(final Configuration configuration, final IProcessingContext processingContext, final String input) { return EachUtils.parseEach(configuration, processingContext, input); }
static Each internalParseEach(final String input) { if (StringUtils.isEmptyOrWhitespace(input)) { return null; } final ExpressionParsingState decomposition = ExpressionParsingUtil.decompose(input,ExpressionParsingDecompositionConfig.DECOMPOSE_ALL_AND_UNNEST); if (decomposition == null) { return null; } return composeEach(decomposition, 0); }
/** * * @param configuration * configuration * @param processingContext * processingContext * @param input * input * @return the result * @since 2.0.9 */ public Each parseEach(final Configuration configuration, final IProcessingContext processingContext, final String input) { return EachUtils.parseEach(configuration, processingContext, input); }
return composeEach(state, pointer);
/** * @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 Each parseEach(final Configuration configuration, final IProcessingContext processingContext, final String input) { return EachUtils.parseEach(configuration, processingContext, input); }
/** * @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 Each parseEach(final Arguments arguments, final String input) { return EachUtils.parseEach(arguments.getConfiguration(), arguments, input); }
@Override protected final IterationSpec getIterationSpec( final Arguments arguments, final Element element, final String attributeName) { final String attributeValue = element.getAttributeValue(attributeName); final Configuration configuration = arguments.getConfiguration(); final Each each = EachUtils.parseEach(configuration, arguments, attributeValue); final IStandardExpression iterVarExpr = each.getIterVar(); final Object iterVarValue = iterVarExpr.execute(configuration, arguments); final IStandardExpression statusVarExpr = each.getStatusVar(); final Object statusVarValue; if (statusVarExpr != null) { statusVarValue = statusVarExpr.execute(configuration, arguments); } else { statusVarValue = null; } final IStandardExpression iterableExpr = each.getIterable(); final Object iteratedValue = iterableExpr.execute(configuration, arguments); final String iterVarName = (iterVarValue == null? null : iterVarValue.toString()); if (StringUtils.isEmptyOrWhitespace(iterVarName)) { throw new TemplateProcessingException( "Iteration variable name expression evaluated as null: \"" + iterVarExpr + "\""); } final String statusVarName = (statusVarValue == null? null : statusVarValue.toString()); if (statusVarExpr != null && StringUtils.isEmptyOrWhitespace(statusVarName)) { throw new TemplateProcessingException( "Status variable name expression evaluated as null or empty: \"" + statusVarExpr + "\""); } return new IterationSpec(iterVarName, statusVarName, iteratedValue); }