Class TemplateLookupContext

    • Method Detail

      • lookupWithAcquisitionStrategy

        public abstract TemplateLookupResult lookupWithAcquisitionStrategy​(java.lang.String templateName)
                                                                    throws java.io.IOException
        Finds the template source based on its normalized name; handles * steps (so called acquisition), otherwise it just calls TemplateLoader.findTemplateSource(String).
        Parameters:
        templateName - Must be a normalized name, like "foo/bar/baaz.ftl". A name is not normalized when, among others, it starts with /, or contains . or .. path steps, or it uses backslash (\) instead of /. A normalized name might contains "*" path steps (acquisition).
        Returns:
        The result of the lookup. Not null; check TemplateLookupResult.isPositive() to see if the lookup has found anything.
        Throws:
        java.io.IOException
      • getTemplateName

        public java.lang.String getTemplateName()
        The normalized name (path) of the template (relatively to the TemplateLoader). Not null.
      • getTemplateLocale

        public java.util.Locale getTemplateLocale()
        null if localized lookup is disabled (see Configuration.getLocalizedLookup()), otherwise the locale requested.
      • getCustomLookupCondition

        public java.lang.Object getCustomLookupCondition()
        Returns the value of the customLookupCondition parameter of Configuration.getTemplate(String, Locale, Object, String, boolean, boolean); see requirements there, such as having a proper Object.equals(Object) and Object.hashCode() method. The interpretation of this value is up to the custom TemplateLookupStrategy. Usually, it's used similarly to as the default lookup strategy uses getTemplateLocale(), that is, to look for a template variation that satisfies the condition, and then maybe fall back to more generic template if that's missing.