this.context.increaseLevel(); this.context.setVariable(this.iterVariableName, this.iterStatusVariable.current); this.context.setVariable(this.iterStatusVariableName, this.iterStatusVariable); this.context.decreaseLevel();
void performTearDownChecks(final ITemplateEnd itemplateEnd) { if (this.modelController.getModelLevel() != 0) { throw new TemplateProcessingException( "Bad markup or template processing sequence. Model level is != 0 (" + this.modelController.getModelLevel() + ") " + "at template end.", itemplateEnd.getTemplateName(), itemplateEnd.getLine(), itemplateEnd.getCol()); } if (this.engineContext != null) { if (this.engineContext.level() != this.initialContextLevel.intValue()) { throw new TemplateProcessingException( "Bad markup or template processing sequence. Context level after processing (" + this.engineContext.level() + ") " + "does not correspond to context level before processing (" + this.initialContextLevel.intValue() + ").", itemplateEnd.getTemplateName(), itemplateEnd.getLine(), itemplateEnd.getCol()); } final List<IProcessableElementTag> elementStack = this.engineContext.getElementStackAbove(this.initialContextLevel.intValue()); if (!elementStack.isEmpty()) { throw new TemplateProcessingException( "Bad markup or template processing sequence. Element stack after processing is not empty: " + elementStack, itemplateEnd.getTemplateName(), itemplateEnd.getLine(), itemplateEnd.getCol()); } } }
private void reportFinish(final String outputType) { if (this.allProcessingFinished) { if (logger.isTraceEnabled()) { logger.trace( "[THYMELEAF][{}] Finished throttled processing of template \"{}\" with locale {}. Maximum overflow was {} {} (overflow buffer grown {} times).", new Object[]{TemplateEngine.threadIndex(), this.templateSpec, this.context.getLocale(), Integer.valueOf(this.writer.getMaxOverflowSize()), outputType, this.writer.getOverflowGrowCount() }); } } }
engineContext.setVariable(newVariableName, rightValue); } else {
private static boolean isLocalVariableOverriding(final IExpressionContext context, final String expression) { if (!(context instanceof IEngineContext)) { // We don't even have support for local variables! return false; } // NOTE this IEngineContext interface is internal and should not be used in users' code final IEngineContext engineContext = (IEngineContext) context; final int dotPos = expression.indexOf('.'); if (dotPos == -1) { return false; } // Once we extract the first part of the expression, we check whether it is a local variable... final String expressionFirstComponent = expression.substring(0, dotPos); return engineContext.isVariableLocal(expressionFirstComponent); }
final ITemplateHandler handler, final Writer writer) { final IEngineConfiguration configuration = context.getConfiguration(); final Set<IPreProcessor> preProcessors = configuration.getPreProcessors(context.getTemplateMode()); if (preProcessors != null && preProcessors.size() > 0) { for (final IPreProcessor preProcessor : preProcessors) { final Set<IPostProcessor> postProcessors = configuration.getPostProcessors(context.getTemplateMode()); if (postProcessors != null && postProcessors.size() > 0) { for (final IPostProcessor postProcessor : postProcessors) {
private void decreaseModelLevel() { this.modelLevel--; this.skipBody = this.skipBodyByLevel[this.modelLevel]; if (this.context != null) { this.context.decreaseLevel(); } }
this.engineContext.setElementTag(null); this.engineContext.decreaseLevel(); this.engineContext.decreaseLevel();
AbstractGatheringModelProcessable( final IEngineConfiguration configuration, final ProcessorTemplateHandler processorTemplateHandler, final IEngineContext context, final TemplateModelController modelController, final TemplateFlowController flowController, final SkipBody buildTimeSkipBody, final boolean buildTimeSkipCloseTag, final ProcessorExecutionVars processorExecutionVars) { super(); this.processorTemplateHandler = processorTemplateHandler; this.context = context; this.modelController = modelController; this.flowController = flowController; this.buildTimeSkipBody = buildTimeSkipBody; this.buildTimeSkipCloseTag = buildTimeSkipCloseTag; if (this.context == null) { throw new TemplateProcessingException( "Neither iteration nor model gathering are supported because local variable support is DISABLED. " + "This is due to the use of an implementation of the " + ITemplateContext.class.getName() + " interface " + "that does not provide local-variable support. In order to have local-variable support, the context " + "implementation should also implement the " + IEngineContext.class.getName() + " interface"); } this.syntheticModel = new Model(configuration, context.getTemplateMode()); this.processorExecutionVars = processorExecutionVars.cloneVars(); this.gatheringFinished = false; this.modelLevel = 0; }
private static IContext applyDataDriverWrapper( final IContext context, final String dataDriverVariableName, final DataDrivenTemplateIterator dataDrivenTemplateIterator) { // This is an IEngineContext, a very internal, low-level context implementation, so let's simply modify it if (context instanceof IEngineContext) { ((IEngineContext)context).setVariable(dataDriverVariableName, dataDrivenTemplateIterator); return context; } // Not an IEngineContext, but might still be an ISpringWebFluxContext and we don't want to lose that info if (context instanceof ISpringWebFluxContext) { return new DataDrivenSpringWebFluxContextWrapper( (ISpringWebFluxContext)context, dataDriverVariableName, dataDrivenTemplateIterator); } // Not a recognized context interface: just use a default implementation return new DataDrivenContextWrapper(context, dataDriverVariableName, dataDrivenTemplateIterator); }
private static boolean isLocalVariableOverriding(final IExpressionContext context, final String expression) { if (!(context instanceof IEngineContext)) { // We don't even have support for local variables! return false; } // NOTE this IEngineContext interface is internal and should not be used in users' code final IEngineContext engineContext = (IEngineContext) context; final int dotPos = expression.indexOf('.'); if (dotPos == -1) { return false; } // Once we extract the first part of the expression, we check whether it is a local variable... final String expressionFirstComponent = expression.substring(0, dotPos); return engineContext.isVariableLocal(expressionFirstComponent); }
static void disposeEngineContext(final IEngineContext engineContext) { engineContext.decreaseLevel(); }
IteratedGatheringModelProcessable( final IEngineConfiguration configuration, ProcessorTemplateHandler processorTemplateHandler, final IEngineContext context, final TemplateModelController modelController, final TemplateFlowController flowController, final SkipBody gatheredSkipBody, final boolean gatheredSkipCloseTag, final ProcessorExecutionVars processorExecutionVars, final String iterVariableName, final String iterStatusVariableName, final Object iteratedObject, final Text precedingWhitespace) { super(configuration, processorTemplateHandler, context, modelController, flowController, gatheredSkipBody, gatheredSkipCloseTag, processorExecutionVars); this.context = context; this.templateMode = context.getTemplateMode(); this.iterator = computeIteratedObjectIterator(iteratedObject); this.iterVariableName = iterVariableName; if (StringUtils.isEmptyOrWhitespace(iterStatusVariableName)) { // If no name has been specified for the status variable, we will use the same as the iter var + "Stat" this.iterStatusVariableName = iterVariableName + DEFAULT_STATUS_VAR_SUFFIX; } else { this.iterStatusVariableName = iterStatusVariableName; } this.iterStatusVariable = new IterationStatusVar(); this.iterStatusVariable.index = 0; this.iterStatusVariable.size = computeIteratedObjectSize(iteratedObject); this.precedingWhitespace = precedingWhitespace; if (this.iterator != null && this.iterator instanceof DataDrivenTemplateIterator) { this.dataDrivenIterator = (DataDrivenTemplateIterator) iterator; } else { this.dataDrivenIterator = null; } this.iter = 0; this.iterOffset = 0; this.iterModel = null; }
((IEngineContext)context).setVariable( ThymeleafEvaluationContext.THYMELEAF_EVALUATION_CONTEXT_CONTEXT_VARIABLE_NAME, evaluationContext); ((IEngineContext)context).setVariable( ThymeleafEvaluationContext.THYMELEAF_EVALUATION_CONTEXT_CONTEXT_VARIABLE_NAME, evaluationContext);
private static boolean isLocalVariableOverriding(final IExpressionContext context, final String expression) { if (!(context instanceof IEngineContext)) { // We don't even have support for local variables! return false; } // NOTE this IEngineContext interface is internal and should not be used in users' code final IEngineContext engineContext = (IEngineContext) context; final int dotPos = expression.indexOf('.'); if (dotPos == -1) { return false; } // Once we extract the first part of the expression, we check whether it is a local variable... final String expressionFirstComponent = expression.substring(0, dotPos); return engineContext.isVariableLocal(expressionFirstComponent); }
public boolean process() { /* * First, check the stopProcess flag */ if (this.flowController.stopProcessing) { return false; } /* * Process the queue */ if (this.context != null) { this.context.decreaseLevel(); } return true; }
final ITemplateParser parser = getParserForTemplateMode(engineContext.getTemplateMode()); this.configuration, null, template, templateSelectors, templateData.getTemplateResource(), engineContext.getTemplateMode(), templateResolution.getUseDecoupledLogic(), builderHandler); this.configuration, null, template, templateSelectors, templateData.getTemplateResource(), engineContext.getTemplateMode(), templateResolution.getUseDecoupledLogic(), processingHandlerChain);
new Object[]{TemplateEngine.threadIndex(), Integer.valueOf(maxOutput), outputType, this.templateSpec, this.context.getLocale()}); new Object[]{TemplateEngine.threadIndex(), Integer.valueOf(maxOutput), outputType, Integer.valueOf(writtenCount), outputType, this.templateSpec, this.context.getLocale()}); new Object[]{ TemplateEngine.threadIndex(), LoggingUtils.loggifyTemplateName(this.templateSpec.getTemplate()), this.context.getLocale(), elapsed, elapsedMs, this.templateSpec, this.context.getLocale(), Integer.valueOf(maxOutput), outputType, Integer.valueOf(writtenCount), outputType, elapsed, elapsedMs});
((IEngineContext)context).setVariable( ThymeleafEvaluationContext.THYMELEAF_EVALUATION_CONTEXT_CONTEXT_VARIABLE_NAME, evaluationContext); ((IEngineContext)context).setVariable( ThymeleafEvaluationContext.THYMELEAF_EVALUATION_CONTEXT_CONTEXT_VARIABLE_NAME, evaluationContext);
private static boolean isLocalVariableOverriding(final IExpressionContext context, final String expression) { if (!(context instanceof IEngineContext)) { // We don't even have support for local variables! return false; } // NOTE this IEngineContext interface is internal and should not be used in users' code final IEngineContext engineContext = (IEngineContext) context; final int dotPos = expression.indexOf('.'); if (dotPos == -1) { return false; } // Once we extract the first part of the expression, we check whether it is a local variable... final String expressionFirstComponent = expression.substring(0, dotPos); return engineContext.isVariableLocal(expressionFirstComponent); }