/** * <p> * Sets a new set of dialects for this template engine, referenced * by the prefixes they will be using. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> * * @param dialects the new map of {@link IDialect} objects to be used, referenced * by their prefixes. */ public void setDialectsByPrefix(final Map<String,IDialect> dialects) { this.configuration.setDialects(dialects); }
/** * <p> * Sets a new set of dialects for this template engine, all of them using * their default prefixes. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> * * @param dialects the new set of {@link IDialect} objects to be used. */ public void setDialects(final Set<IDialect> dialects) { Validate.notNull(dialects, "Dialect set cannot be null"); final Map<String,IDialect> dialectMap = new LinkedHashMap<String, IDialect>(dialects.size() + 2, 1.0f); for (final IDialect dialect : dialects) { dialectMap.put(dialect.getPrefix(), dialect); } this.configuration.setDialects(dialectMap); }
/** * <p> * Sets an additional set of dialects for this template engine, all of them using * their default prefixes. * </p> * <p> * This operation can only be executed before processing templates for the first * time. Once a template is processed, the template engine is considered to be * <i>initialized</i>, and from then on any attempt to change its configuration * will result in an exception. * </p> * * @param additionalDialects the new set of {@link IDialect} objects to be used. * * @since 2.0.9 * */ public void setAdditionalDialects(final Set<IDialect> additionalDialects) { Validate.notNull(additionalDialects, "Additional dialect set cannot be null"); final Map<String,IDialect> dialectMap = new LinkedHashMap<String, IDialect>(5, 1.0f); dialectMap.putAll(this.configuration.getDialects()); for (final IDialect dialect : additionalDialects) { dialectMap.put(dialect.getPrefix(), dialect); } this.configuration.setDialects(dialectMap); }