All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.thymeleaf.TemplateProcessingParameters Maven / Gradle / Ivy

Go to download

Modern server-side Java template engine for both web and standalone environments

There is a newer version: 3.1.3.RELEASE
Show newest version
/*
 * =============================================================================
 * 
 *   Copyright (c) 2011-2014, The THYMELEAF team (http://www.thymeleaf.org)
 * 
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 * 
 * =============================================================================
 */
package org.thymeleaf;

import java.util.Map;

import org.thymeleaf.context.DialectAwareProcessingContext;
import org.thymeleaf.context.IContext;
import org.thymeleaf.context.IProcessingContext;
import org.thymeleaf.util.Validate;

/**
 * 

* Objects of this class contain all the required arguments for template * resolution and parsing. *

*

* These objects are created internally by the Template Engine in order * to provide the Template Parser and the Template Resolvers with the info * they need to read and parse the template document. *

* * @author Daniel Fernández * * @since 2.0.0 * */ public final class TemplateProcessingParameters { private final Configuration configuration; private final String templateName; private final IProcessingContext processingContext; /** *

* Create a new TemplateProcessingParameters instance. *

*

* Mainly for internal use. Should not be called directly except * when processing a template (e.g. a fragment) using the {@link TemplateEngine} * from a element/attribute processor. *

* * @param configuration the configuration * @param templateName the template name * @param context the context */ public TemplateProcessingParameters( final Configuration configuration, final String templateName, final IContext context) { this(configuration, templateName, new DialectAwareProcessingContext(context, configuration.getDialectSet())); } /** *

* Create a new TemplateProcessingParameters instance. *

*

* Mainly for internal use. Should not be called directly except * when processing a template (e.g. a fragment) using the {@link TemplateEngine} * from a element/attribute processor. *

* * @param configuration the configuration * @param templateName the template name * @param context the processing context * @since 2.0.9 */ public TemplateProcessingParameters( final Configuration configuration, final String templateName, final IProcessingContext context) { super(); Validate.notNull(configuration, "Configuration cannot be null"); Validate.notNull(templateName, "Template name cannot be null"); Validate.notNull(context, "Context cannot be null"); this.configuration = configuration; this.templateName = templateName; this.processingContext = context; } /** *

* Returns the Template Engine configuration being used for * processing templates. *

* * @return the configuration */ public Configuration getConfiguration() { return this.configuration; } /** *

* Returns the name of the template currently being processed. *

* * @return the template name */ public String getTemplateName() { return this.templateName; } /** *

* Returns the current context specified for template processing. *

*

* Equivalent to getProcessingContext().getContext(). *

* * @return the current context */ public IContext getContext() { return this.processingContext.getContext(); } /** *

* Returns the processing context specified for template processing. *

* * @return the processing context * @since 2.0.9 */ public IProcessingContext getProcessingContext() { return this.processingContext; } /** *

* Returns the execution attributes. *

* * @return the current map of execution attributes */ public Map getExecutionAttributes() { return this.configuration.getExecutionAttributes(); } /** *

* Returns the execution attribute with the specified name. *

* * @param attributeName the name of the attribute to be retrieved * @return the value of the attribute */ public Object getExecutionAttribute(final String attributeName) { return this.configuration.getExecutionAttributes().get(attributeName); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy