Interface ILinkBuilder

  • All Known Implementing Classes:
    AbstractLinkBuilder, StandardLinkBuilder

    public interface ILinkBuilder

    Common interface for all objects used for the building of links (URLs). This extension point provides a way to integrate Thymeleaf with different web execution environments, be these based on the Servlet API or not.

    A Template Engine can be set several link builders, which will be asked for link building in the order established by the getOrder() method.

    Note that a link builder will return null if a link cannot be built (because of it not falling under its responsibilities for whatever reason). In such case, the next builder will be asked. If the entire chain of link builders fail, an exception will be raised.

    Implementations of this interface should be thread-safe.

    Since:
    3.0.0
    Author:
    Daniel Fernández
    • Method Detail

      • getName

        String getName()

        Returns the name of the link builder.

        Returns:
        the name of the link builder
      • getOrder

        Integer getOrder()

        Return the order in which this link builder will be executed in the chain when several link builders are set for the same Template Engine.

        Returns:
        the order of this builder in the chain.
      • buildLink

        String buildLink​(IExpressionContext context,
                         String base,
                         Map<String,​Object> parameters)

        Build a link, returning null if not possible.

        Parameters:
        context - the IExpressionContext object being used for template processing. Cannot be null.
        base - the base of the link URL to be built, i.e. its path. Can be null.
        parameters - the (optional) URL parameters.
        Returns:
        the built URL.