本文整理了Java中org.thymeleaf.Arguments
类的一些代码示例,展示了Arguments
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Arguments
类的具体详情如下:
包路径:org.thymeleaf.Arguments
类名称:Arguments
[英]Objects of this class contain all the required arguments for template processing.
These objects are created internally by the Template Engine in order to provide processors with all the information they might need for performing their tasks.
Arguments include many attributes, among which some should be used internally only, and never by developers of attribute/element processors. Public attributes are:
The Template Engine configuration ( Configuration): #getConfiguration()
The template name: #getTemplateName()
The Context ( org.thymeleaf.context.IContext): #getContext()
The current map of ID Counts (used for adding a unique index to repeated id attributes): #getIdCounts()
The Expression roots:
For normal (non selected) evaluation (${...} in standard dialect): #getExpressionEvaluationRoot()
Information about whether processing non-element nodes is allowed at a specific point of a template execution or not (default is to process only elements).
[中]此类的对象包含模板处理所需的所有参数。
这些对象由模板引擎在内部创建,以便为处理者提供执行任务所需的所有信息。
参数包括许多属性,其中一些属性只能在内部使用,属性/元素处理器的开发人员永远不能使用。公共属性包括:
*模板引擎配置(配置):#getConfiguration()
*模板名称:#getTemplateName()
*上下文(org.thymeleaf.Context.IContext):#getContext()
*ID计数的当前映射(用于向重复的ID属性添加唯一索引):#getIdCounts()
*表达式根:
*对于正常(未选择)求值(${…}标准方言):#getExpressionEvaluationRoot()
对于所选评估({…}标准方言):#getExpressionSelectionEvaluationRoot()
*有关是否允许在模板执行的特定点处理非元素节点的信息(默认情况下仅处理元素)。
代码示例来源:origin: com.github.dandelion/dandelion-thymeleaf
/**
* @param arguments
* Thymeleaf arguments
* @return web context of arguments
*/
public static WebContext getWebContext(Arguments arguments) {
return (WebContext) arguments.getContext();
}
}
代码示例来源:origin: stackoverflow.com
void processNode(final Arguments arguments, final boolean processTextNodes, final boolean processCommentNodes) {
// some code
if (!isPrecomputed()) {
precomputeNode(arguments.getConfiguration());
}
if (!isSkippable()) {
// processing itself
...
// move processing to children, but does not happend if node is marked as skippable
doAdditionalProcess(executionArguments, executionArguments.getProcessTextNodes(), executionArguments.getProcessCommentNodes());
}
}
代码示例来源:origin: dandelion/dandelion-datatables
@Override
@SuppressWarnings("unchecked")
protected ProcessorResult processAttribute(Arguments arguments, Element element, String attributeName) {
Map<Option<?>, Object> stagingOptions = (Map<Option<?>, Object>) arguments
.getLocalVariable(DataTablesDialect.INTERNAL_BEAN_COLUMN_STAGING_OPTIONS);
Map<Option<?>, Extension> stagingExtensions = (Map<Option<?>, Extension>) arguments
.getLocalVariable(DataTablesDialect.INTERNAL_BEAN_COLUMN_STAGING_EXTENSIONS);
// Perform the actual attribute processing
doProcessAttribute(arguments, element, attributeName, stagingOptions, stagingExtensions);
// Housekeeping
element.removeAttribute(attributeName);
return ProcessorResult.ok();
}
代码示例来源:origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf
private static Properties loadMessagesForTemplate(
final Arguments arguments, final Properties defaultMessages) {
Validate.notNull(arguments, "Arguments cannot be null");
Validate.notNull(arguments.getContext().getLocale(), "Locale in context cannot be null");
final String resourceName = arguments.getTemplateResolution().getResourceName();
final IResourceResolver resourceResolver = arguments.getTemplateResolution().getResourceResolver();
final Locale locale = arguments.getContext().getLocale();
final String templateBaseName = getTemplateFileNameBase(resourceName);
return MessageResolutionUtils.loadCombinedMessagesFilesFromBaseName(
arguments, resourceResolver, templateBaseName, locale, defaultMessages);
}
代码示例来源:origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf
Validate.notNull(arguments.getContext().getLocale(), "Locale in context cannot be null");
return MessageResolutionUtils.resolveMessageForClass(
arguments.getConfiguration(), this.getClass(),
arguments.getContext().getLocale(), messageKey, messageParameters);
代码示例来源:origin: nz.net.ultraq.web.thymeleaf/thymeleaf-layout-dialect
arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName),
null, PROCESSOR_NAME_FRAGMENT_FULL, true);
List<Node> includefragments = fragmentandtarget.extractFragment(arguments.getConfiguration(),
arguments.getContext(), arguments.getTemplateRepository());
代码示例来源:origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf
Validate.notNull(arguments.getContext().getLocale(), "Locale in context cannot be null");
Validate.notNull(key, "Message key cannot be null");
final Locale locale = arguments.getContext().getLocale();
final String templateName = arguments.getTemplateResolution().getTemplateName();
final String cacheKey = TEMPLATE_CACHE_PREFIX + templateName + '_' + locale.toString();
ICache<String,Properties> messagesCache = null;
final ICacheManager cacheManager = arguments.getConfiguration().getCacheManager();
if (cacheManager != null) {
messagesCache = cacheManager.getMessageCache();
代码示例来源:origin: org.thymeleaf.extras/thymeleaf-extras-tiles2
final IContext context = arguments.getContext();
if (!(context instanceof IWebContext)) {
throw new ConfigurationException(
final TemplateEngine templateEngine = arguments.getTemplateEngine();
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});
代码示例来源:origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf
@Override
protected boolean isVisible(final Arguments arguments, final Element element, final String attributeName) {
if (!arguments.hasLocalVariable(AbstractStandardSwitchStructureAttrProcessor.SWITCH_VARIABLE_NAME)) {
throw new TemplateProcessingException(
"Cannot specify a \"" + attributeName + "\" attribute in an environment where no " +
(SwitchStructure) arguments.getLocalVariable(AbstractStandardSwitchStructureAttrProcessor.SWITCH_VARIABLE_NAME);
new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName(), attributeValue, attributeName, attributeValue, Boolean.TRUE});
final Configuration configuration = arguments.getConfiguration();
final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(configuration);
new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName(), attributeValue, attributeName, attributeValue, Boolean.valueOf(visible)});
代码示例来源:origin: org.thymeleaf.extras/thymeleaf-extras-tiles2
final IContext context = arguments.getContext();
if (!(context instanceof IWebContext)) {
throw new ConfigurationException(
final Attribute value = null;
final TemplateEngine templateEngine = arguments.getTemplateEngine();
final StringWriter writer = new StringWriter();
代码示例来源:origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf
precomputeNode(arguments.getConfiguration());
this.recomputeProcessorsImmediately = false;
precomputeNode(arguments.getConfiguration());
arguments.addLocalVariables(this.nodeLocalVariables) : arguments);
if (executionArguments.hasLocalVariables()) {
unsafeSetNodeLocalVariables(executionArguments.getLocalVariables());
precomputeNode(arguments.getConfiguration());
this.recomputeProcessorsImmediately = false;
代码示例来源:origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf
@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());
}
}
}
代码示例来源:origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf
final Configuration configuration = arguments.getConfiguration();
if (TemplateModeUtils.isHtml(arguments.getTemplateResolution().getTemplateMode()) &&
ArrayUtils.contains(Standards.HTML_CONDITIONAL_FIXED_VALUE_ATTR_NAMES, newAttributeName)) {
代码示例来源:origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf
arguments.getConfiguration(), arguments, attributeValue, dialectPrefix, fragmentSignatureAttributeName);
fragment.extractFragment(arguments.getConfiguration(), arguments, arguments.getTemplateRepository());
代码示例来源:origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf
final Configuration configuration = arguments.getConfiguration();
assignationExecutionArguments.addLocalVariables(Collections.singletonMap(newVariableName, rightValue));
代码示例来源:origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf
@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;
}
代码示例来源:origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf
@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);
}
代码示例来源:origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf
@Override
protected List<Node> getMarkupSubstitutes(final Arguments arguments, final Element element) {
final String text = getText(arguments, element);
try {
final TemplateRepository templateRepository = arguments.getTemplateRepository();
final List<Node> fragNodes = templateRepository.getFragment(arguments, text);
for (final Node node : fragNodes) {
node.setProcessable(false);
}
return fragNodes;
} catch (final TemplateEngineException e) {
throw e;
} catch (final Exception e) {
throw new TemplateProcessingException(
"An error happened during parsing of unescaped text: \"" + element.getOriginalName() + "\"", e);
}
}
代码示例来源:origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf
arguments.getConfiguration(), this.getClass(),
arguments.getContext().getLocale(), messageKey,
messageParameters, false);
messageKey, arguments.getContext().getLocale());
代码示例来源:origin: nz.net.ultraq.web.thymeleaf/thymeleaf-layout-dialect
arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName),
null, null, false);
Template decorator = arguments.getTemplateRepository().getTemplate(new TemplateProcessingParameters(
arguments.getConfiguration(), fragmentandtarget.getTemplateName(), arguments.getContext()));
Element decoratorhtmlelement = decorator.getDocument().getFirstElementChild();
if (decoratorhtmlelement == null || !decoratorhtmlelement.getOriginalName().equals(HTML_ELEMENT_HTML)) {
内容来源于网络,如有侵权,请联系作者删除!