@Override public TemplateConfiguration get(String sourceName, Object templateSource) throws IOException, TemplateConfigurationFactoryException { if (matcher.matches(sourceName, templateSource)) { if (templateConfigurationFactory != null) { return templateConfigurationFactory.get(sourceName, templateSource); } else { return templateConfiguration; } } else { return null; } }
@Override protected void setConfigurationOfChildren(Configuration cfg) { for (TemplateConfigurationFactory templateConfigurationFactory : templateConfigurationFactories) { templateConfigurationFactory.setConfiguration(cfg); } }
/** * Binds this {@link TemplateConfigurationFactory} to a {@link Configuration}. Once it's bound, it can't be bound to * another {@link Configuration} any more. This is automatically called by * {@link Configuration#setTemplateConfigurations(TemplateConfigurationFactory)}. */ public final void setConfiguration(Configuration cfg) { if (this.cfg != null) { if (cfg != this.cfg) { throw new IllegalStateException( "The TemplateConfigurationFactory is already bound to another Configuration"); } return; } else { this.cfg = cfg; setConfigurationOfChildren(cfg); } }
@Override protected void setConfigurationOfChildren(Configuration cfg) { for (TemplateConfigurationFactory templateConfigurationFactory : templateConfigurationFactories) { templateConfigurationFactory.setConfiguration(cfg); } }
@Override public TemplateConfiguration get(String sourceName, Object templateSource) throws IOException, TemplateConfigurationFactoryException { for (TemplateConfigurationFactory tcf : templateConfigurationFactories) { TemplateConfiguration tc = tcf.get(sourceName, templateSource); if (tc != null) { return tc; } } if (!allowNoMatch) { throw new TemplateConfigurationFactoryException( FirstMatchTemplateConfigurationFactory.class.getSimpleName() + " has found no matching choice for source name " + StringUtil.jQuote(sourceName) + ". " + (noMatchErrorDetails != null ? "Error details: " + noMatchErrorDetails : "(Set the noMatchErrorDetails property of the factory bean to give a more specific error " + "message. Set allowNoMatch to true if this shouldn't be an error.)")); } return null; }
/** * Binds this {@link TemplateConfigurationFactory} to a {@link Configuration}. Once it's bound, it can't be bound to * another {@link Configuration} any more. This is automatically called by * {@link Configuration#setTemplateConfigurations(TemplateConfigurationFactory)}. */ public final void setConfiguration(Configuration cfg) { if (this.cfg != null) { if (cfg != this.cfg) { throw new IllegalStateException( "The TemplateConfigurationFactory is already bound to another Configuration"); } return; } else { this.cfg = cfg; setConfigurationOfChildren(cfg); } }
@Override protected void setConfigurationOfChildren(Configuration cfg) { if (templateConfiguration != null) { templateConfiguration.setParentConfiguration(cfg); } if (templateConfigurationFactory != null) { templateConfigurationFactory.setConfiguration(cfg); } }
@Override public TemplateConfiguration get(String sourceName, Object templateSource) throws IOException, TemplateConfigurationFactoryException { TemplateConfiguration mergedTC = null; TemplateConfiguration resultTC = null; for (TemplateConfigurationFactory tcf : templateConfigurationFactories) { TemplateConfiguration tc = tcf.get(sourceName, templateSource); if (tc != null) { if (resultTC == null) { resultTC = tc; } else { if (mergedTC == null) { Configuration cfg = getConfiguration(); if (cfg == null) { throw new IllegalStateException( "The TemplateConfigurationFactory wasn't associated to a Configuration yet."); } mergedTC = new TemplateConfiguration(); mergedTC.setParentConfiguration(cfg); mergedTC.merge(resultTC); resultTC = mergedTC; } mergedTC.merge(tc); } } } return resultTC; }
/** * Binds this {@link TemplateConfigurationFactory} to a {@link Configuration}. Once it's bound, it can't be bound to * another {@link Configuration} any more. This is automatically called by * {@link Configuration#setTemplateConfigurations(TemplateConfigurationFactory)}. */ public final void setConfiguration(Configuration cfg) { if (this.cfg != null) { if (cfg != this.cfg) { throw new IllegalStateException( "The TemplateConfigurationFactory is already bound to another Configuration"); } return; } else { this.cfg = cfg; setConfigurationOfChildren(cfg); } }
/** * Sets a {@link TemplateConfigurationFactory} that will configure individual templates where their settings differ * from those coming from the common {@link Configuration} object. A typical use case for that is specifying the * {@link TemplateConfiguration#setOutputFormat(OutputFormat) outputFormat} for templates based on their file * extension or parent directory. * * <p> * Note that the settings suggested by standard file extensions are stronger than that you set here. See * {@link #setRecognizeStandardFileExtensions(boolean)} for more information about standard file extensions. * * <p>See "Template configurations" in the FreeMarker Manual for examples. * * @since 2.3.24 */ public void setTemplateConfigurations(TemplateConfigurationFactory templateConfigurations) { if (cache.getTemplateConfigurations() != templateConfigurations) { if (templateConfigurations != null) { templateConfigurations.setConfiguration(this); } recreateTemplateCacheWith(cache.getTemplateLoader(), cache.getCacheStorage(), cache.getTemplateLookupStrategy(), cache.getTemplateNameFormat(), templateConfigurations); } }
final TemplateConfiguration tc; try { tc = templateConfigurations != null ? templateConfigurations.get(sourceName, source) : null; } catch (TemplateConfigurationFactoryException e) { throw newIOException("Error while getting TemplateConfiguration; see cause exception.", e);
@Override protected void setConfigurationOfChildren(Configuration cfg) { for (TemplateConfigurationFactory templateConfigurationFactory : templateConfigurationFactories) { templateConfigurationFactory.setConfiguration(cfg); } }
@Override public TemplateConfiguration get(String sourceName, Object templateSource) throws IOException, TemplateConfigurationFactoryException { if (matcher.matches(sourceName, templateSource)) { if (templateConfigurationFactory != null) { return templateConfigurationFactory.get(sourceName, templateSource); } else { return templateConfiguration; } } else { return null; } }
@Override protected void setConfigurationOfChildren(Configuration cfg) { for (TemplateConfigurationFactory templateConfigurationFactory : templateConfigurationFactories) { templateConfigurationFactory.setConfiguration(cfg); } }
@Override public TemplateConfiguration get(String sourceName, Object templateSource) throws IOException, TemplateConfigurationFactoryException { if (matcher.matches(sourceName, templateSource)) { if (templateConfigurationFactory != null) { return templateConfigurationFactory.get(sourceName, templateSource); } else { return templateConfiguration; } } else { return null; } }
@Override protected void setConfigurationOfChildren(Configuration cfg) { for (TemplateConfigurationFactory templateConfigurationFactory : templateConfigurationFactories) { templateConfigurationFactory.setConfiguration(cfg); } }
@Override public TemplateConfiguration get(String sourceName, Object templateSource) throws IOException, TemplateConfigurationFactoryException { for (TemplateConfigurationFactory tcf : templateConfigurationFactories) { TemplateConfiguration tc = tcf.get(sourceName, templateSource); if (tc != null) { return tc; } } if (!allowNoMatch) { throw new TemplateConfigurationFactoryException( FirstMatchTemplateConfigurationFactory.class.getSimpleName() + " has found no matching choice for source name " + StringUtil.jQuote(sourceName) + ". " + (noMatchErrorDetails != null ? "Error details: " + noMatchErrorDetails : "(Set the noMatchErrorDetails property of the factory bean to give a more specific error " + "message. Set allowNoMatch to true if this shouldn't be an error.)")); } return null; }
@Override protected void setConfigurationOfChildren(Configuration cfg) { for (TemplateConfigurationFactory templateConfigurationFactory : templateConfigurationFactories) { templateConfigurationFactory.setConfiguration(cfg); } }
@Override public TemplateConfiguration get(String sourceName, Object templateSource) throws IOException, TemplateConfigurationFactoryException { for (TemplateConfigurationFactory tcf : templateConfigurationFactories) { TemplateConfiguration tc = tcf.get(sourceName, templateSource); if (tc != null) { return tc; } } if (!allowNoMatch) { throw new TemplateConfigurationFactoryException( FirstMatchTemplateConfigurationFactory.class.getSimpleName() + " has found no matching choice for source name " + StringUtil.jQuote(sourceName) + ". " + (noMatchErrorDetails != null ? "Error details: " + noMatchErrorDetails : "(Set the noMatchErrorDetails property of the factory bean to give a more specific error " + "message. Set allowNoMatch to true if this shouldn't be an error.)")); } return null; }
@Override protected void setConfigurationOfChildren(Configuration cfg) { if (templateConfiguration != null) { templateConfiguration.setParentConfiguration(cfg); } if (templateConfigurationFactory != null) { templateConfigurationFactory.setConfiguration(cfg); } }