public abstract class TemplateLookupContext extends Object
TemplateLookupStrategy.lookup(TemplateLookupContext)
.
You can't create instances of this, only receive them from FreeMarker.Modifier and Type | Method and Description |
---|---|
TemplateLookupResult |
createNegativeLookupResult()
Creates a not-found lookup result that then can be used as the return value of
TemplateLookupStrategy.lookup(TemplateLookupContext) . |
Object |
getCustomLookupCondition()
Return the value of the
customLookupCondition parameter of
Configuration.getTemplate(String, Locale, Object, String, boolean, boolean) . |
Locale |
getTemplateLocale()
null if localized lookup is disabled (see Configuration.getLocalizedLookup() ), otherwise the
locale requested. |
String |
getTemplateName()
The normalized name (path) of the template (relatively to the
TemplateLoader ). |
abstract TemplateLookupResult |
lookupWithAcquisitionStrategy(String templateName)
Finds the template source based on its normalized name; handles
* steps (so called acquisition),
otherwise it just calls TemplateLoader.findTemplateSource(String) . |
abstract TemplateLookupResult |
lookupWithLocalizedThenAcquisitionStrategy(String templateName,
Locale templateLocale)
Finds the template source based on its normalized name; tries localized variations going from most
specific to less specific, and for each variation it delegates to
lookupWithAcquisitionStrategy(String) . |
public abstract TemplateLookupResult lookupWithAcquisitionStrategy(String templateName) throws IOException
*
steps (so called acquisition),
otherwise it just calls TemplateLoader.findTemplateSource(String)
.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 ..
paths steps, or it uses
backslash (\
) instead of /
. A normalized name might contains "*" steps.null
; check TemplateLookupResult.isPositive()
to see if the
lookup has found anything.IOException
public abstract TemplateLookupResult lookupWithLocalizedThenAcquisitionStrategy(String templateName, Locale templateLocale) throws IOException
lookupWithAcquisitionStrategy(String)
.
If templateLocale
is null
(typically, because Configuration.getLocalizedLookup()
is
false
)), then it's the same as calling lookupWithAcquisitionStrategy(String)
directly. This is
the default strategy of FreeMarker (at least in 2.3.x), so for more information, see
TemplateLookupStrategy.DEFAULT_2_3_0
.IOException
public String getTemplateName()
TemplateLoader
). Not null
.public Locale getTemplateLocale()
null
if localized lookup is disabled (see Configuration.getLocalizedLookup()
), otherwise the
locale requested.public Object getCustomLookupCondition()
customLookupCondition
parameter of
Configuration.getTemplate(String, Locale, Object, String, boolean, boolean)
. 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.public TemplateLookupResult createNegativeLookupResult()
TemplateLookupStrategy.lookup(TemplateLookupContext)
. (In the current implementation it just always
returns the same static singleton, but that might need to change in the future.)