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
ConstructorsConstructorDescriptionFirstMatchTemplateConfigurationFactory(TemplateConfigurationFactory... templateConfigurationFactories) -
Method Summary
Modifier and TypeMethodDescriptionallowNoMatch(boolean allow)Same assetAllowNoMatch(boolean), but return this object to support "fluent API" style.Returns (maybe creates) theTemplateConfigurationfor the given template source.booleanGetter 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.voidsetAllowNoMatch(boolean allowNoMatch)Use this to specify if having no matching choice is an error.protected voidCallsTemplateConfiguration.setParentConfiguration(Configuration)on each enclosedTemplateConfigurationandTemplateConfigurationFactory.setConfiguration(Configuration)on each enclosedTemplateConfigurationFactoryobjects.voidsetNoMatchErrorDetails(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:TemplateConfigurationFactoryReturns (maybe creates) theTemplateConfigurationfor the given template source.- Specified by:
getin 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
TemplateConfigurationto apply, ornullif the there's noTemplateConfigurationfor 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:TemplateConfigurationFactoryCallsTemplateConfiguration.setParentConfiguration(Configuration)on each enclosedTemplateConfigurationandTemplateConfigurationFactory.setConfiguration(Configuration)on each enclosedTemplateConfigurationFactoryobjects. It only supposed to call these on the direct "children" of this object, not on the children of the children.- Specified by:
setConfigurationOfChildrenin classTemplateConfigurationFactory
-