TemplateConfigurationFactory (FreeMarker 2.3.35 API)
Description: declaration: package: freemarker.cache, class: TemplateConfigurationFactory

Package freemarker.cache

# Class TemplateConfigurationFactory

java.lang.Object
freemarker.cache.TemplateConfigurationFactory

Direct Known Subclasses:
  `ConditionalTemplateConfigurationFactory`, `FirstMatchTemplateConfigurationFactory`, `MergingTemplateConfigurationFactory`

public abstract class TemplateConfigurationFactory extends Object
Creates (or returns) `TemplateConfiguration`-s for template sources.

Since:
  2.3.24

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TemplateConfigurationFactory()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract TemplateConfiguration`
  `get​(String sourceName, Object templateSource)`
  Returns (maybe creates) the `TemplateConfiguration` for the given template source.
  `Configuration`
  `getConfiguration()`
  Returns the configuration this object belongs to, or `null` if it isn't yet bound to a `Configuration`.
  `void`
  `setConfiguration​(Configuration cfg)`
  Binds this `TemplateConfigurationFactory` to a `Configuration`.
  `protected abstract void`
  `setConfigurationOfChildren​(Configuration cfg)`
  Calls `TemplateConfiguration.setParentConfiguration(Configuration)` on each enclosed `TemplateConfiguration` and `setConfiguration(Configuration)` on each enclosed `TemplateConfigurationFactory` objects.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### TemplateConfigurationFactory

    public TemplateConfigurationFactory()

- ## Method Details

  - ### get

    public abstract TemplateConfiguration get​(String sourceName, Object templateSource) throws IOException, TemplateConfigurationFactoryException
    Returns (maybe creates) the `TemplateConfiguration` for the given template source.
    Parameters:
      `sourceName` - The name (path) that was used for `TemplateLoader.findTemplateSource(String)`. See `Template.getSourceName()` for details.
      `templateSource` - The object returned by `TemplateLoader.findTemplateSource(String)`.
    Returns:
      The `TemplateConfiguration` to apply, or `null` if the there's no `TemplateConfiguration` for this template source.
    Throws:
      `IOException` - Typically, if the 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.

  - ### setConfiguration

    public final void setConfiguration​(Configuration cfg)
    Binds this `TemplateConfigurationFactory` to a `Configuration`. Once it's bound, it can't be bound to another `Configuration` anymore. This is automatically called by `Configuration.setTemplateConfigurations(TemplateConfigurationFactory)`.

  - ### getConfiguration

    public Configuration getConfiguration()
    Returns the configuration this object belongs to, or `null` if it isn't yet bound to a `Configuration`.

  - ### setConfigurationOfChildren

    protected abstract void setConfigurationOfChildren​(Configuration cfg)
    Calls `TemplateConfiguration.setParentConfiguration(Configuration)` on each enclosed `TemplateConfiguration` and `setConfiguration(Configuration)` on each enclosed `TemplateConfigurationFactory` objects. It only supposed to call these on the direct "children" of this object, not on the children of the children.