@Override protected final ProcessorResult doProcess(final Arguments arguments, final ProcessorMatchingContext processorMatchingContext, final Node node) { if (this.logger.isTraceEnabled()) { this.logger.trace("[THYMELEAF][{}][{}] Processing Document node of type \"{}\".", new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName(), node.getClass().getName()}); } // Because of the type of applicability being used, this cast will not fail return processDocumentNode(arguments, (Document)node); }
@Override protected ProcessorResult processDocumentNode(final Arguments arguments, final Document documentNode) { if (this.logger.isDebugEnabled()) { this.logger.debug("[THYMELEAF][{}][{}] Setting both 'processTextNodes' and " + "'processCommentNodes' flags to true for this document. " + "Text (incl. CDATA) and Comment nodes will be considered processable.", new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName()}); } return ProcessorResult.setProcessTextAndCommentNodes(true, true); }
@Override protected ProcessorResult processDocumentNode(final Arguments arguments, final Document documentNode) { if (this.logger.isDebugEnabled()) { this.logger.debug("[THYMELEAF][{}][{}] Setting the " + "'processTextNodes' flags to true for this document. " + "Text nodes (Text + CDATA) will be considered processable.", new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName()}); } return ProcessorResult.setProcessTextNodes(true); }
@Override protected ProcessorResult processDocumentNode(final Arguments arguments, final Document documentNode) { if (this.logger.isDebugEnabled()) { this.logger.debug("[THYMELEAF][{}][{}] Setting the " + "'processCommentNodes' flags to true for this document. " + "Comment nodes will be considered processable.", new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName()}); } return ProcessorResult.setProcessCommentNodes(true); }
@Override protected final ProcessorResult doProcess(final Arguments arguments, final ProcessorMatchingContext processorMatchingContext, final Node node) { if (this.logger.isTraceEnabled()) { final String content = ((AbstractTextNode)node).getContent(); this.logger.trace("[THYMELEAF][{}][{}] Processing text node of type \"{}\" with content \"{}\"", new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName(), node.getClass().getSimpleName(), content}); } // Because of the type of applicability being used, this cast will not fail return processTextNode(arguments, (AbstractTextNode)node); }
@Override protected final ProcessorResult doProcess(final Arguments arguments, final ProcessorMatchingContext processorMatchingContext, final Node node) { if (this.logger.isTraceEnabled()) { final String content = ((Comment)node).getContent(); this.logger.trace("[THYMELEAF][{}][{}] Processing Comment node with content \"{}\"", new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName(), node.getClass().getSimpleName(), content}); } // Because of the type of applicability being used, this cast will not fail return processCommentNode(arguments, (Comment)node); }
@Override protected final ProcessorResult doProcess(final Arguments arguments, final ProcessorMatchingContext processorMatchingContext, final Node node) { // Because of the type of applicability being used, this cast will not fail if (this.logger.isTraceEnabled()) { final String elementName = ((Element)node).getNormalizedName(); this.logger.trace("[THYMELEAF][{}][{}] Processing element \"{}\"", new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName(), elementName}); } return processElement(arguments, (Element)node); }
@Override public ProcessorResult processTextNode(final Arguments arguments, final AbstractTextNode textNode) { if (!textNode.getProcessTextNodes()) { throw new TemplateProcessingException("Cannot execute text inlining processor: Text processors are not active"); } final Object inliner = arguments.getLocalVariable(StandardDialect.INLINER_LOCAL_VARIABLE); if (inliner == null) { if (this.logger.isTraceEnabled()) { this.logger.trace("[THYMELEAF][{}][{}] Will not process Text node as inline: no inliner has been set. " + "Please note that setting the 'processOnlyElementNodes' flag to false at a high level in the DOM " + "tree (like for example using " + ProcessAllNodesDocumentProcessor.class.getName() + ") can reduce " + "processing performance in templates with a big amount of Text nodes. Consider setting this flag " + "back to true at some point in your DOM tree to reduce this effect.", new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName()}); } return ProcessorResult.OK; } if (!(inliner instanceof IStandardTextInliner)) { throw new TemplateProcessingException("Cannot execute text inlining processor: Inliner set does not implement " + IStandardTextInliner.class.getName() + " (it is an object of class " + inliner.getClass().getName() + ")"); } ((IStandardTextInliner)inliner).inline(arguments, textNode); return ProcessorResult.OK; }
@Override protected final ProcessorResult doProcess(final Arguments arguments, final ProcessorMatchingContext processorMatchingContext, final Node node) { // Because of the type of applicability being used, casts to Element here will not fail final Element element = (Element) node; final String[] attributeNames = this.matcher.getAttributeNames(processorMatchingContext); String matchedAttributeName = null; for (final String attributeName : attributeNames) { if (element.hasNormalizedAttribute(attributeName)) { matchedAttributeName = attributeName; break; } } if (this.logger.isTraceEnabled()) { final String attributeValue = ((Element)node).getAttributeValueFromNormalizedName(matchedAttributeName); this.logger.trace("[THYMELEAF][{}][{}] Processing attribute \"{}\" with value \"{}\" in element \"{}\"", new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName(), matchedAttributeName, (attributeValue == null? "" : attributeValue), ((Element)node).getNormalizedName()}); } return processAttribute(arguments, element, matchedAttributeName); }
new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName(), attributeValue, attributeName, attributeValue, Boolean.TRUE}); new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName(), attributeValue, attributeName, attributeValue, Boolean.valueOf(visible)});
this.logger.trace("[THYMELEAF][{}][{}] Executing Tiles Model of class {}" + "for attribute \"{}\" with value \"{}\"", new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName(), this.model.getClass().getName(), attributeName, attributeValue}); this.logger.trace("[THYMELEAF][{}][{}] Correctly executed Tiles Model of class {}" + "for attribute \"{}\" with value \"{}\", result is:\n{}", new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName(), this.model.getClass().getName(), attributeName, attributeValue, templateResult});
this.logger.trace("[THYMELEAF][{}][{}] Executing Tiles Model of class {}" + "for attribute \"{}\" with value \"{}\"", new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName(), this.model.getClass().getName(), attributeName, attributeValue}); this.logger.trace("[THYMELEAF][{}][{}] Correctly executed Tiles Model of class {}" + "for attribute \"{}\" with value \"{}\", result is:\n{}", new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName(), this.model.getClass().getName(), attributeName, attributeValue, templateResult});
if (targetTemplateName == null) { if (context != null && context instanceof Arguments) { targetTemplateName = ((Arguments)context).getTemplateName(); } else { throw new TemplateProcessingException(
@Override protected final void checkAssertions(final Arguments arguments, final Element element, final String attributeName, final String attributeValue) { if (StringUtils.isEmptyOrWhitespace(attributeValue)) { return; } final Configuration configuration = arguments.getConfiguration(); final ExpressionSequence expressionSequence = ExpressionSequenceUtils.parseExpressionSequence(configuration, arguments, attributeValue); final List<IStandardExpression> expressions = expressionSequence.getExpressions(); for (final IStandardExpression expression : expressions) { final Object expressionResult = expression.execute(arguments.getConfiguration(), arguments); final boolean expressionBooleanResult = EvaluationUtil.evaluateAsBoolean(expressionResult); if (!expressionBooleanResult) { throw new TemplateAssertionException(expression.getStringRepresentation(), arguments.getTemplateName(), element.getLineNumber()); } } }