本文整理匯總了Java中freemarker.template.Version類的典型用法代碼示例。如果您正苦於以下問題:Java Version類的具體用法?Java Version怎麽用?Java Version使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Version類屬於freemarker.template包,在下文中一共展示了Version類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getFreemarkerConfiguration
import freemarker.template.Version; //導入依賴的package包/類
@Override
protected Configuration getFreemarkerConfiguration(RepoCtx ctx)
{
if (useRemoteCallbacks)
{
// as per 3.0, 3.1
return super.getFreemarkerConfiguration(ctx);
}
else
{
Configuration cfg = new Configuration();
cfg.setObjectWrapper(new DefaultObjectWrapper());
cfg.setTemplateLoader(new ClassPathRepoTemplateLoader(nodeService, contentService, defaultEncoding));
// TODO review i18n
cfg.setLocalizedLookup(false);
cfg.setIncompatibleImprovements(new Version(2, 3, 20));
cfg.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
return cfg;
}
}
示例2: buildFreemarkerHelper
import freemarker.template.Version; //導入依賴的package包/類
private FreemarkerHelper buildFreemarkerHelper(File templateBaseDir) {
Configuration configuration = new Configuration(new Version(2, 3, 0));
try {
TemplateLoader templateLoader = new FileTemplateLoader(templateBaseDir);
configuration.setTemplateLoader(templateLoader);
} catch (IOException e) {
throw new GeneratorException("構建模板助手出錯:" + e.getMessage());
}
configuration.setNumberFormat("###############");
configuration.setBooleanFormat("true,false");
configuration.setDefaultEncoding("UTF-8");
// 自動導入公共文件,用於支持靈活變量
if (autoIncludeFile.exists()) {
List<String> autoIncludeList = new ArrayList<>();
autoIncludeList.add(FREEMARKER_AUTO_INCLUDE_SUFFIX);
configuration.setAutoIncludes(autoIncludeList);
}
return new FreemarkerHelper(configuration);
}
示例3: SchemaMaker
import freemarker.template.Version; //導入依賴的package包/類
/**
* @param onTable
*/
public SchemaMaker(String tenant, String module, TenantOperation mode, String previousVersion, String rmbVersion){
if(SchemaMaker.cfg == null){
//do this ONLY ONCE
SchemaMaker.cfg = new Configuration(new Version(2, 3, 26));
// Where do we load the templates from:
cfg.setClassForTemplateLoading(SchemaMaker.class, "/templates/db_scripts");
cfg.setDefaultEncoding("UTF-8");
cfg.setLocale(Locale.US);
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
}
this.tenant = tenant;
this.module = module;
this.mode = mode;
this.previousVersion = previousVersion;
this.rmbVersion = rmbVersion;
}
示例4: EmailTemplate
import freemarker.template.Version; //導入依賴的package包/類
public EmailTemplate() {
ftlCfg = new Configuration(new Version(FREEMARKER_VERSION));
try {
// Check if templates are located from disk or if we are loading default ones.
String templatesDir = System.getenv(EmailPlugin.HAWKULAR_ALERTS_TEMPLATES);
templatesDir = templatesDir == null ? System.getProperty(EmailPlugin.HAWKULAR_ALERTS_TEMPLATES_PROPERY)
: templatesDir;
boolean templatesFromDir = false;
if (templatesDir != null) {
File fileDir = new File(templatesDir);
if (fileDir.exists()) {
ftlCfg.setDirectoryForTemplateLoading(fileDir);
templatesFromDir = true;
}
}
if (!templatesFromDir) {
ftlCfg.setClassForTemplateLoading(this.getClass(), "/");
}
ftlTemplatePlain = ftlCfg.getTemplate(DEFAULT_TEMPLATE_PLAIN, DEFAULT_LOCALE);
ftlTemplateHtml = ftlCfg.getTemplate(DEFAULT_TEMPLATE_HTML, DEFAULT_LOCALE);
} catch (IOException e) {
log.debug(e.getMessage(), e);
throw new RuntimeException("Cannot initialize templates on email plugin: " + e.getMessage());
}
}
示例5: save
import freemarker.template.Version; //導入依賴的package包/類
public void save() throws Exception {
genTime = new Date().getTime();
deploymentXmlFile.getParentFile().mkdirs();
Configuration cfg = new Configuration(new Version(2, 3, 22));
cfg.setClassLoaderForTemplateLoading(this.getClass().getClassLoader(), "templates");
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
Template template = cfg.getTemplate("parent_last.ftl");
FileOutputStream outputStream = new FileOutputStream(deploymentXmlFile);
Writer out = new OutputStreamWriter(outputStream);
template.process(this, out);
outputStream.flush();
outputStream.close();
}
示例6: getTemplate
import freemarker.template.Version; //導入依賴的package包/類
public static Template getTemplate(String name) {
Template template = null;
try {
Version version = new Version("2.3.0");
Configuration cfg = new Configuration(version);
// 讀取ftl模板
cfg.setClassForTemplateLoading(FreemarkerConfiguration.class, "/ftl");
cfg.setClassicCompatible(true);
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
cfg.setObjectWrapper(new SaicObjectWrapper(cfg.getIncompatibleImprovements()));
template = cfg.getTemplate(name);
} catch (IOException e) {
e.printStackTrace();
}
return template;
}
示例7: AbstractPrintGeneratingTest
import freemarker.template.Version; //導入依賴的package包/類
AbstractPrintGeneratingTest() {
targetDirectory.mkdirs();
try {
freeMarkerConfiguration = new Configuration();
freeMarkerConfiguration.setTemplateLoader(new ClassTemplateLoader(Class.class, "/"));
//freeMarkerConfiguration.setDirectoryForTemplateLoading(new File(templateDirectory).getAbsoluteFile());
freeMarkerConfiguration.setObjectWrapper(new DefaultObjectWrapper());
freeMarkerConfiguration.setDefaultEncoding("UTF-8");
freeMarkerConfiguration.setTemplateExceptionHandler(HTML_DEBUG_HANDLER);
freeMarkerConfiguration.setIncompatibleImprovements(new Version(2, 3, 20));
printsRendererService.setFreeMarkerConfiguration(freeMarkerConfiguration);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例8: freemarkerConfig
import freemarker.template.Version; //導入依賴的package包/類
/**
* FreeMarker (ftl) configuration
*/
@Bean
public FreeMarkerConfigurer freemarkerConfig() throws IOException, TemplateException {
final FreeMarkerConfigurer result = new FreeMarkerConfigurer();
// template path
result.setTemplateLoaderPath("/WEB-INF/ftl/");
result.setDefaultEncoding("UTF-8");
// static access
final Version version = freemarker.template.Configuration.getVersion();
final BeansWrapper wrapper = new BeansWrapper(version);
final TemplateHashModel statics = wrapper.getStaticModels();
final Map<String, Object> shared = new HashMap<>();
for (final Class<?> clazz : ElFunctions.staticClasses) {
shared.put(clazz.getSimpleName(), statics.get(clazz.getName()));
}
result.setFreemarkerVariables(shared);
return result;
}
示例9: applyTemplate
import freemarker.template.Version; //導入依賴的package包/類
public static boolean applyTemplate(File sourceTemplate, File destinationFile, Map<?, ?> data) throws IOException, TemplateException{
boolean success = true;
// Process the template file using the data in the "data" Map
final Configuration cfg = new Configuration( new Version("2.3.23"));
cfg.setDirectoryForTemplateLoading(sourceTemplate.getParentFile());
// Load template from source folder
final Template template = cfg.getTemplate(sourceTemplate.getName());
// Console output
BufferedWriter fw = null;
try {
fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(destinationFile), Charset.forName("UTF-8")));
template.process(data, fw);
}finally {
if (fw != null) {
fw.close();
}
}
return success;
}
示例10: getFreemarkerConfiguration
import freemarker.template.Version; //導入依賴的package包/類
protected Configuration getFreemarkerConfiguration(RepoCtx ctx)
{
Configuration cfg = new Configuration();
cfg.setObjectWrapper(new DefaultObjectWrapper());
// custom template loader
cfg.setTemplateLoader(new TemplateWebScriptLoader(ctx.getRepoEndPoint(), ctx.getTicket()));
// TODO review i18n
cfg.setLocalizedLookup(false);
cfg.setIncompatibleImprovements(new Version(2, 3, 20));
cfg.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
return cfg;
}
示例11: getStringConfig
import freemarker.template.Version; //導入依賴的package包/類
/**
* FreeMarker configuration for loading the specified template directly from a String
*
* @param path Pseudo Path to the template
* @param template Template content
*
* @return FreeMarker configuration
*/
protected Configuration getStringConfig(String path, String template)
{
Configuration config = new Configuration();
// setup template cache
config.setCacheStorage(new MruCacheStorage(2, 0));
// use our custom loader to load a template directly from a String
StringTemplateLoader stringTemplateLoader = new StringTemplateLoader();
stringTemplateLoader.putTemplate(path, template);
config.setTemplateLoader(stringTemplateLoader);
// use our custom object wrapper that can deal with QNameMap objects directly
config.setObjectWrapper(qnameObjectWrapper);
// rethrow any exception so we can deal with them
config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
// set default template encoding
if (defaultEncoding != null)
{
config.setDefaultEncoding(defaultEncoding);
}
config.setIncompatibleImprovements(new Version(2, 3, 20));
config.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
return config;
}
示例12: handle
import freemarker.template.Version; //導入依賴的package包/類
@Override
public HttpResponse handle(HttpRequest request, MiddlewareChain chain) {
ContentNegotiable negotiable = ContentNegotiable.class.cast(MixinUtils.mixin(request, ContentNegotiable.class));
HttpResponse response = castToHttpResponse(chain.next(request));
if (TemplatedHttpResponse.class.isInstance(response)) {
TemplatedHttpResponse tres = TemplatedHttpResponse.class.cast(response);
ResourceBundle bundle = config.getMessageResource().getBundle(negotiable.getLocale());
tres.getContext().put("t", new ResourceBundleModel(bundle,
new BeansWrapperBuilder(new Version(2,3,23)).build()));
}
return response;
}
示例13: create
import freemarker.template.Version; //導入依賴的package包/類
public static ScipioBasicBeansWrapperImpl create(Version incompatibleImprovements, Boolean simpleMapWrapper) {
ScipioBasicBeansWrapperImpl wrapper = new ScipioBasicBeansWrapperImpl(incompatibleImprovements, systemWrapperFactories);
if (simpleMapWrapper != null) {
wrapper.setSimpleMapWrapper(simpleMapWrapper);
}
return wrapper;
}
示例14: getTemplateEngine
import freemarker.template.Version; //導入依賴的package包/類
@Bean
public TemplateEngine getTemplateEngine() {
Version version = new Version(2, 3, 25);
freemarker.template.Configuration cfg = new freemarker.template.Configuration(version);
cfg.setClassForTemplateLoading(RallyServiceApp.class, "/");
cfg.setIncompatibleImprovements(version);
cfg.setDefaultEncoding(Charsets.UTF_8.toString());
cfg.setLocale(Locale.US);
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
return new FreemarkerTemplateEngine(cfg);
}
示例15: FacetManager
import freemarker.template.Version; //導入依賴的package包/類
/**
* indicate the table name to query + facet on
* @param onTable
*/
public FacetManager(String onTable){
this.table = onTable;
if(FacetManager.cfg == null){
//do this ONLY ONCE
FacetManager.cfg = new Configuration(new Version(2, 3, 26));
// Where do we load the templates from:
cfg.setClassForTemplateLoading(FacetManager.class, "/templates/facets");
cfg.setDefaultEncoding("UTF-8");
cfg.setLocale(Locale.US);
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
}
}