Package freemarker.cache
Class FirstMatchTemplateConfigurationFactory
- java.lang.Object
-
- freemarker.cache.TemplateConfigurationFactory
-
- freemarker.cache.FirstMatchTemplateConfigurationFactory
-
public class FirstMatchTemplateConfigurationFactory extends TemplateConfigurationFactory
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
Constructors Constructor Description FirstMatchTemplateConfigurationFactory(TemplateConfigurationFactory... templateConfigurationFactories)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FirstMatchTemplateConfigurationFactory
allowNoMatch(boolean allow)
Same assetAllowNoMatch(boolean)
, but return this object to support "fluent API" style.TemplateConfiguration
get(java.lang.String sourceName, java.lang.Object templateSource)
Returns (maybe creates) theTemplateConfiguration
for the given template source.boolean
getAllowNoMatch()
Getter pair ofsetAllowNoMatch(boolean)
.java.lang.String
getNoMatchErrorDetails()
Use this to specify the text added to the exception error message when there was no matching choice.FirstMatchTemplateConfigurationFactory
noMatchErrorDetails(java.lang.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
setConfigurationOfChildren(Configuration cfg)
CallsTemplateConfiguration.setParentConfiguration(Configuration)
on each enclosedTemplateConfiguration
andTemplateConfigurationFactory.setConfiguration(Configuration)
on each enclosedTemplateConfigurationFactory
objects.void
setNoMatchErrorDetails(java.lang.String noMatchErrorDetails)
-
Methods inherited from class freemarker.cache.TemplateConfigurationFactory
getConfiguration, setConfiguration
-
-
-
-
Constructor Detail
-
FirstMatchTemplateConfigurationFactory
public FirstMatchTemplateConfigurationFactory(TemplateConfigurationFactory... templateConfigurationFactories)
-
-
Method Detail
-
get
public TemplateConfiguration get(java.lang.String sourceName, java.lang.Object templateSource) throws java.io.IOException, TemplateConfigurationFactoryException
Description 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:
java.io.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
public java.lang.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
public void setNoMatchErrorDetails(java.lang.String noMatchErrorDetails)
-
allowNoMatch
public FirstMatchTemplateConfigurationFactory allowNoMatch(boolean allow)
Same assetAllowNoMatch(boolean)
, but return this object to support "fluent API" style.
-
noMatchErrorDetails
public FirstMatchTemplateConfigurationFactory noMatchErrorDetails(java.lang.String message)
Same assetNoMatchErrorDetails(String)
, but return this object to support "fluent API" style.
-
setConfigurationOfChildren
protected void setConfigurationOfChildren(Configuration cfg)
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
-
-