Class AbstractEngineContext

    • Field Detail

      • templateResolutionAttributes

        private final java.util.Map<java.lang.String,​java.lang.Object> templateResolutionAttributes
      • locale

        private final java.util.Locale locale
    • Constructor Detail

      • AbstractEngineContext

        protected AbstractEngineContext​(IEngineConfiguration configuration,
                                        java.util.Map<java.lang.String,​java.lang.Object> templateResolutionAttributes,
                                        java.util.Locale locale)
    • Method Detail

      • getTemplateResolutionAttributes

        public final java.util.Map<java.lang.String,​java.lang.Object> getTemplateResolutionAttributes()
        Description copied from interface: ITemplateContext

        Returns the map of configuration items that have been specified at the process(...) methods of ITemplateEngine, aimed at further configuring the template being used and its resolution by means of the ITemplateResolvers.

        Specified by:
        getTemplateResolutionAttributes in interface ITemplateContext
        Returns:
        the template resolution attributes map
      • getLocale

        public final java.util.Locale getLocale()
        Description copied from interface: IContext

        Returns the locale that should be used for processing the template.

        Specified by:
        getLocale in interface IContext
        Returns:
        the locale to be used.
      • getTemplateMode

        public final TemplateMode getTemplateMode()
        Description copied from interface: ITemplateContext

        Returns the template mode of the template currently being processed.

        Note that the TemplateMode returned here corresponds with origin of the elements or nodes being currently processed. This is, if a processor is being executed for an element inserted from an external template (via a th:insert, for example), then this method will return the template mode for the template in which the inserted fragment lives, not the one it was inserted into.

        Specified by:
        getTemplateMode in interface ITemplateContext
        Returns:
        the template mode of the elements or nodes being currently processed.
      • getMessage

        public final java.lang.String getMessage​(java.lang.Class<?> origin,
                                                 java.lang.String key,
                                                 java.lang.Object[] messageParameters,
                                                 boolean useAbsentMessageRepresentation)
        Description copied from interface: ITemplateContext

        Computes an externalized (internationalized, i18n) message to be used on a template.

        This method is meant to be called mainly by processors that need to output externalized messages.

        Specified by:
        getMessage in interface ITemplateContext
        Parameters:
        origin - the origin class to be used for message resolution. When calling from a processor, this is normally the processor class itself. See IMessageResolver.
        key - the key of the message to be retrieved.
        messageParameters - the parameters to be applied to the requested message.
        useAbsentMessageRepresentation - whether an absent message representation should be returned in the case that the message does not exist (see IMessageResolver).
        Returns:
        the requested message, correctly formatted. Or an absent message representation, or null if no absent message representations are allowed.
      • buildLink

        public final java.lang.String buildLink​(java.lang.String base,
                                                java.util.Map<java.lang.String,​java.lang.Object> parameters)
        Description copied from interface: ITemplateContext

        Computes link to be used on a template.

        This method is meant to be called mainly by processors or expressions that need to output links.

        Specified by:
        buildLink in interface ITemplateContext
        Parameters:
        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, or an exception if no link builders are able to build this link.