org.thymeleaf.standard.fragment
Class StandardFragment

Object
  extended by org.thymeleaf.standard.fragment.StandardFragment

public final class StandardFragment
extends Object

Object modelling the result of resolving a standard fragment specification, after all its expressions have been evaluated, its parameters parsed, etc.

Note that the specified template can be null, in which case the fragment will be considered to be executed on the current template (obtained from the IProcessingContext argument in extractFragment(org.thymeleaf.Configuration, org.thymeleaf.context.IProcessingContext, org.thymeleaf.TemplateRepository), which will therefore need to be an instance of Arguments).

Since:
2.1.0
Author:
Daniel Fernández

Constructor Summary
StandardFragment(String templateName, IFragmentSpec fragmentSpec, Map<String,Object> parameters)
           Create a new instance of this class.
StandardFragment(String templateName, IFragmentSpec fragmentSpec, Map<String,Object> parameters, String dialectPrefix, String fragmentSignatureAttributeName)
           Create a new instance of this class.
 
Method Summary
 List<Node> extractFragment(Configuration configuration, IProcessingContext context, TemplateRepository templateRepository)
           Read the specified template from TemplateRepository, and then apply the IFragmentSpec to the result of parsing it (the template).
 IFragmentSpec getFragmentSpec()
           Returns the IFragmentSpec that will be applied to the template.
 Map<String,Object> getParameters()
           Returns the parameters that will be applied to the fragment.
 String getTemplateName()
           Returns the name of the template that will be resolved and parsed.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardFragment

public StandardFragment(String templateName,
                        IFragmentSpec fragmentSpec,
                        Map<String,Object> parameters)

Create a new instance of this class.

Parameters:
templateName - the name of the template that will be resolved and parsed, null if fragment is to be executed on the current template.
fragmentSpec - the fragment spec that will be applied to the template, once parsed.
parameters - the parameters to be applied to the fragment, when processed.

StandardFragment

public StandardFragment(String templateName,
                        IFragmentSpec fragmentSpec,
                        Map<String,Object> parameters,
                        String dialectPrefix,
                        String fragmentSignatureAttributeName)

Create a new instance of this class.

This constructor allows the specification of the attribute in which a fragment signature could be found (if applicable, can be null) so that this signature is processed if found and the specified fragment parameters are processed and adapted accordingly (e.g. matching of synthetic --not named-- parameters).

Parameters:
templateName - the name of the template that will be resolved and parsed, null if fragment is to be executed on the current template.
fragmentSpec - the fragment spec that will be applied to the template, once parsed.
parameters - the parameters to be applied to the fragment, when processed.
dialectPrefix - the dialect prefix to be applied to the attribute name in which we could expect to find a fragment. Can be null.
fragmentSignatureAttributeName - the name of the attribute in which we could expect to find a fragment. Can be null.
Method Detail

getTemplateName

public String getTemplateName()

Returns the name of the template that will be resolved and parsed.

Returns:
the template name.

getFragmentSpec

public IFragmentSpec getFragmentSpec()

Returns the IFragmentSpec that will be applied to the template.

Returns:
the fragment spec.

getParameters

public Map<String,Object> getParameters()

Returns the parameters that will be applied to the fragment.

Returns:
the map of parameters. May return null if no parameters exist.

extractFragment

public List<Node> extractFragment(Configuration configuration,
                                  IProcessingContext context,
                                  TemplateRepository templateRepository)

Read the specified template from TemplateRepository, and then apply the IFragmentSpec to the result of parsing it (the template).

Fragment parameters will also be processed and applied as local variables of the returned nodes.

In order to execute on the current template (templateName == null), the context argument will need to be an Arguments object.

Parameters:
configuration - the configuration to be used for resolving the template and processing the fragment spec.
context - the processing context to be used for resolving and parsing the template.
templateRepository - the template repository to be asked for the template.
Returns:
the result of parsing + applying the fragment spec.


Copyright © 2013 The THYMELEAF team. All Rights Reserved.