Package freemarker.cache
Class FirstMatchTemplateConfigurationFactory
java.lang.Object
freemarker.cache.TemplateConfigurationFactory
freemarker.cache.FirstMatchTemplateConfigurationFactory
Returns the first non-
null
result of the child factories, ignoring all further child factories. The child
factories are called in the order as they were added.-
Constructor Summary
ConstructorDescriptionFirstMatchTemplateConfigurationFactory(TemplateConfigurationFactory... templateConfigurationFactories)
-
Method Summary
Modifier and TypeMethodDescriptionallowNoMatch(boolean allow)
Same assetAllowNoMatch(boolean)
, but return this object to support "fluent API" style.Returns (maybe creates) theTemplateConfiguration
for the given template source.boolean
Getter pair ofsetAllowNoMatch(boolean)
.Use this to specify the text added to the exception error message when there was no matching choice.noMatchErrorDetails(String message)
Same assetNoMatchErrorDetails(String)
, but return this object to support "fluent API" style.void
setAllowNoMatch(boolean allowNoMatch)
Use this to specify if having no matching choice is an error.protected void
CallsTemplateConfiguration.setParentConfiguration(Configuration)
on each enclosedTemplateConfiguration
andTemplateConfigurationFactory.setConfiguration(Configuration)
on each enclosedTemplateConfigurationFactory
objects.void
setNoMatchErrorDetails(String noMatchErrorDetails)
Methods inherited from class freemarker.cache.TemplateConfigurationFactory
getConfiguration, setConfiguration
-
Constructor Details
-
FirstMatchTemplateConfigurationFactory
public FirstMatchTemplateConfigurationFactory(TemplateConfigurationFactory... templateConfigurationFactories)
-
-
Method Details
-
get
public TemplateConfiguration get(String sourceName, Object templateSource) throws IOException, TemplateConfigurationFactoryExceptionDescription copied from class:TemplateConfigurationFactory
Returns (maybe creates) theTemplateConfiguration
for the given template source.- Specified by:
get
in classTemplateConfigurationFactory
- Parameters:
sourceName
- The name (path) that was used forTemplateLoader.findTemplateSource(String)
. SeeTemplate.getSourceName()
for details.templateSource
- The object returned byTemplateLoader.findTemplateSource(String)
.- Returns:
- The
TemplateConfiguration
to apply, ornull
if the there's noTemplateConfiguration
for this template source. - Throws:
IOException
- Typically, if there factory needs further I/O to find out more about the template source, but that fails.TemplateConfigurationFactoryException
- If there's a problem that's specific to the factory logic.
-
getAllowNoMatch
public boolean getAllowNoMatch()Getter pair ofsetAllowNoMatch(boolean)
. -
setAllowNoMatch
public void setAllowNoMatch(boolean allowNoMatch)Use this to specify if having no matching choice is an error. The default isfalse
, that is, it's an error if there was no matching choice.- See Also:
setNoMatchErrorDetails(String)
-
getNoMatchErrorDetails
Use this to specify the text added to the exception error message when there was no matching choice. The default isnull
(no error details).- See Also:
setAllowNoMatch(boolean)
-
setNoMatchErrorDetails
-
allowNoMatch
Same assetAllowNoMatch(boolean)
, but return this object to support "fluent API" style. -
noMatchErrorDetails
Same assetNoMatchErrorDetails(String)
, but return this object to support "fluent API" style. -
setConfigurationOfChildren
Description copied from class:TemplateConfigurationFactory
CallsTemplateConfiguration.setParentConfiguration(Configuration)
on each enclosedTemplateConfiguration
andTemplateConfigurationFactory.setConfiguration(Configuration)
on each enclosedTemplateConfigurationFactory
objects. It only supposed to call these on the direct "children" of this object, not on the children of the children.- Specified by:
setConfigurationOfChildren
in classTemplateConfigurationFactory
-