public final TemplateResolution resolveTemplate( final IEngineConfiguration configuration, final String ownerTemplate, final String template, final Map<String, Object> templateResolutionAttributes) { Validate.notNull(configuration, "Engine Configuration cannot be null"); // ownerTemplate CAN be null Validate.notNull(template, "Template Name cannot be null"); // templateResolutionAttributes CAN be null if (!computeResolvable(configuration, ownerTemplate, template, templateResolutionAttributes)) { return null; } final ITemplateResource templateResource = computeTemplateResource(configuration, ownerTemplate, template, templateResolutionAttributes); if (templateResource == null) { return null; } if (this.checkExistence && !templateResource.exists()) { // will only check if flag set to true return null; } return new TemplateResolution( templateResource, this.checkExistence, computeTemplateMode(configuration, ownerTemplate, template, templateResolutionAttributes), this.useDecoupledLogic, computeValidity(configuration, ownerTemplate, template, templateResolutionAttributes)); }
public TemplateResolution resolveTemplate(final TemplateProcessingParameters templateProcessingParameters) { checkInitialized(); Validate.notNull(templateProcessingParameters, "Template Processing Parameters cannot be null"); if (!computeResolvable(templateProcessingParameters)) { return null; } return new TemplateResolution( templateProcessingParameters.getTemplateName(), computeResourceName(templateProcessingParameters), computeResourceResolver(templateProcessingParameters), computeCharacterEncoding(templateProcessingParameters), computeTemplateMode(templateProcessingParameters), computeValidity(templateProcessingParameters)); }
/** * <p> * Returns the name of the template resolver * </p> * * @return the name of the template resolver */ public String getName() { checkInitialized(); return this.name; }
if (!isInitialized()) { initializeSpecific();
/** * <p> * Sets a new name for the Template Resolver. * </p> * * @param name the new name */ public void setName(final String name) { checkNotInitialized(); this.name = name; }
/** * <p> * Returns the order in which this template resolver will be asked to resolve * templates as a part of the chain of resolvers configured into the template engine. * </p> * <p> * Order should start with 1. * </p> * * @return the order in which this template resolver will be called in the chain. */ public Integer getOrder() { checkInitialized(); return this.order; }
/** * <p> * Sets a new order for the template engine in the chain. Order should start with 1. * </p> * * @param order the new order. */ public void setOrder(final Integer order) { checkNotInitialized(); this.order = order; }
/** * <p> * Returns the <i>pattern spec</i> specified for establishing which * templates can be resolved by this template resolver. For those templates * which names do not match this patterns, the Template Resolver will return null. * </p> * <p> * This allows for a fast discard of those templates that the developer might * know for sure that will not be resolvable by the Resource Resolver used by * this Template Resolver, so that an execution of the resource resolver is not needed. * </p> * * @return the pattern spec */ public PatternSpec getResolvablePatternSpec() { checkInitialized(); return this.resolvablePatternSpec; }
/** * <p> * Sets the new <i>patterns</i> to be applied for establishing which * templates can be resolved by this template resolver. For those templates * which names do not match this patterns, the Template Resolver will return null. * </p> * <p> * This allows for a fast discard of those templates that the developer might * know for sure that will not be resolvable by the Resource Resolver used by * this Template Resolver, so that an execution of the resource resolver is not needed. * </p> * <p> * This is a convenience method equivalent to {@link #getResolvablePatternSpec()}.setPatterns(Set<String>) * </p> * * @param resolvablePatterns the new patterns */ public void setResolvablePatterns(final Set<String> resolvablePatterns) { checkNotInitialized(); this.resolvablePatternSpec.setPatterns(resolvablePatterns); }
/** * <p> * Returns the <i>patterns</i> (as String) specified for establishing which * templates can be resolved by this template resolver. For those templates * which names do not match this patterns, the Template Resolver will return null. * </p> * <p> * This allows for a fast discard of those templates that the developer might * know for sure that will not be resolvable by the Resource Resolver used by * this Template Resolver, so that an execution of the resource resolver is not needed. * </p> * <p> * This is a convenience method equivalent to {@link #getResolvablePatternSpec()}.getPatterns() * </p> * * @return the pattern spec */ public Set<String> getResolvablePatterns() { checkInitialized(); return this.resolvablePatternSpec.getPatterns(); }