當前位置: 首頁>>代碼示例>>Java>>正文


Java Configuration.VERSION_2_3_25屬性代碼示例

本文整理匯總了Java中freemarker.template.Configuration.VERSION_2_3_25屬性的典型用法代碼示例。如果您正苦於以下問題:Java Configuration.VERSION_2_3_25屬性的具體用法?Java Configuration.VERSION_2_3_25怎麽用?Java Configuration.VERSION_2_3_25使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在freemarker.template.Configuration的用法示例。


在下文中一共展示了Configuration.VERSION_2_3_25屬性的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generateResumeHTML

private String generateResumeHTML(String json, String theme) throws Exception {
    if (!isValidJSON(json)) {
        throw new InvalidJSONException();
    }

    Gson gson = new GsonBuilder().setPrettyPrinting().create();

    Configuration cfg = new Configuration(Configuration.VERSION_2_3_25);
    cfg.setDirectoryForTemplateLoading(new File("themes"));
    cfg.setDefaultEncoding("UTF-8");
    Template temp = cfg.getTemplate(theme + ".html");
    //System.out.println(json);
    Resume resume = gson.fromJson(json, Resume.class);
    resume.getRidOfArraysWithEmptyElements();
    resume.setConfig(config);
    StringWriter htmlStringWriter = new StringWriter();
    temp.process(resume, htmlStringWriter);
    String html = htmlStringWriter.toString();
    return html;
}
 
開發者ID:chenshuiluke,項目名稱:jresume,代碼行數:20,代碼來源:ResumeGenerator.java

示例2: writeToFile

private static void writeToFile(IssuesReport report, Path toFile) {
  try {
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_25);
    cfg.setClassForTemplateLoading(HtmlReport.class, "");

    Map<String, Object> root = new HashMap<>();
    root.put("report", report);

    Template template = cfg.getTemplate("sonarlintreport.ftl");

    try (FileOutputStream fos = new FileOutputStream(toFile.toFile());
      Writer writer = new OutputStreamWriter(fos, StandardCharsets.UTF_8)) {
      template.process(root, writer);
      writer.flush();
    }
  } catch (Exception e) {
    throw new IllegalStateException("Fail to generate HTML Issues Report to: " + toFile, e);
  }
}
 
開發者ID:SonarSource,項目名稱:sonarlint-cli,代碼行數:19,代碼來源:HtmlReport.java

示例3: init

public void init() throws IOException {
    ClassTemplateLoader ctl = new ClassTemplateLoader(Application.class, "/freemarker");
    MultiTemplateLoader mtl = new MultiTemplateLoader(new TemplateLoader[] {ctl});

    Configuration cfg = new Configuration(Configuration.VERSION_2_3_25);
    cfg.setTemplateLoader(mtl);
    cfg.setDefaultEncoding("UTF-8");
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    cfg.setLogTemplateExceptions(false);

    Pair<String, Template> clusterResourceQuota = new ImmutablePair<String, Template>("ClusterResourceQuota-ForUser", cfg.getTemplate("ClusterResourceQuota-ForUser.ftlh"));
    Pair<String, Template> bestEffortResourceLimits = new ImmutablePair<String, Template>("LimitRange-BestEffortResourceLimits", cfg.getTemplate("LimitRange-BestEffortResourceLimits.ftlh"));
    Pair<String, Template> burstableResourceLimits = new ImmutablePair<String, Template>("LimitRange-BurstableResourceLimits", cfg.getTemplate("LimitRange-BurstableResourceLimits.ftlh"));
    Pair<String, Template> maxImageCounts = new ImmutablePair<String, Template>("LimitRange-MaxImageCounts", cfg.getTemplate("LimitRange-MaxImageCounts.ftlh"));
    Pair<String, Template> bestEffort = new ImmutablePair<String, Template>("ResourceQuota-BestEffort", cfg.getTemplate("ResourceQuota-BestEffort.ftlh"));
    Pair<String, Template> notTerminatingAndNotBestEffort = new ImmutablePair<String, Template>("ResourceQuota-NotTerminating-And-NotBestEffort",
                                                                              cfg.getTemplate("ResourceQuota-NotTerminating-And-NotBestEffort.ftlh"));
    Pair<String, Template> terminating = new ImmutablePair<String, Template>("ResourceQuota-Terminating", cfg.getTemplate("ResourceQuota-Terminating.ftlh"));

    templates = Arrays.asList(clusterResourceQuota, bestEffortResourceLimits, burstableResourceLimits, maxImageCounts, bestEffort, notTerminatingAndNotBestEffort, terminating);
}
 
開發者ID:garethahealy,項目名稱:quota-limits-generator,代碼行數:21,代碼來源:YamlTemplateProcessor.java

示例4: getConfigurationByClass

/**
 * 根據根路徑的類,獲取配置文件
 * @author nan.li
 * @param paramClass
 * @param prefix
 * @return
 */
public static Configuration getConfigurationByClass(Class<?> paramClass, String prefix)
{
    try
    {
        Configuration configuration = new Configuration(Configuration.VERSION_2_3_25);
        configuration.setClassForTemplateLoading(paramClass, prefix);
        //等價於下麵這種方法
        //            configuration.setTemplateLoader( new ClassTemplateLoader(paramClass,prefix));
        configuration.setObjectWrapper(new DefaultObjectWrapper(Configuration.VERSION_2_3_25));
        configuration.setDefaultEncoding(CharEncoding.UTF_8);
        configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
        configuration.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25).build());
        return configuration;
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:lnwazg,項目名稱:kit,代碼行數:27,代碼來源:FreeMkKit.java

示例5: getConfigurationByClassLoader

public static Configuration getConfigurationByClassLoader(ClassLoader classLoader, String prefix)
{
    try
    {
        Configuration configuration = new Configuration(Configuration.VERSION_2_3_25);
        configuration.setClassLoaderForTemplateLoading(classLoader, prefix);
        //等價於下麵這種方法
        //            configuration.setTemplateLoader( new ClassTemplateLoader(paramClass,prefix));
        configuration.setObjectWrapper(new DefaultObjectWrapper(Configuration.VERSION_2_3_25));
        configuration.setDefaultEncoding(CharEncoding.UTF_8);
        configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
        configuration.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25).build());
        return configuration;
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:lnwazg,項目名稱:kit,代碼行數:20,代碼來源:FreeMkKit.java

示例6: getConfigurationByDirectory

/**
 * 根據模板的路徑,獲取一個配置文件
 * @author [email protected]
 * @param templateLoadingPath
 * @return
 */
public static Configuration getConfigurationByDirectory(File templateLoadingPath)
{
    try
    {
        Configuration configuration = new Configuration(Configuration.VERSION_2_3_25);
        
        //以下這兩種設置方式是等價的
        //            configuration.setDirectoryForTemplateLoading(templateLoadingPath);
        configuration.setTemplateLoader(new FileTemplateLoader(templateLoadingPath));
        
        configuration.setObjectWrapper(new DefaultObjectWrapper(Configuration.VERSION_2_3_25));
        configuration.setDefaultEncoding(CharEncoding.UTF_8);
        configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
        configuration.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_25).build());
        return configuration;
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:lnwazg,項目名稱:kit,代碼行數:28,代碼來源:FreeMkKit.java

示例7: replace

private String replace(String variableString, Object data) {
    String result;

    // 1. process proxy
    StringWriter writer = new StringWriter();
    try {
        freemarker.template.Template t = new freemarker.template.Template(variableString, variableString, new Configuration(Configuration.VERSION_2_3_25));
        t.process(data, writer);
    } catch (TemplateException | IOException e) {
        log.error("Could not replace proxy pattern");
    }
    result = writer.toString();

    // 2. slugify
    Slugify slg = new Slugify();
    result = slg.slugify(result);

    return result;
}
 
開發者ID:marcobehler,項目名稱:saito,代碼行數:19,代碼來源:TemplateProcessor.java

示例8: configuration

@Singleton
@Provides
public static Configuration configuration(LinkHelper linkHelper, MultiTemplateLoader templateLoader) {
    try {
        freemarker.log.Logger.selectLoggerLibrary(Logger.LIBRARY_SLF4J);
        Configuration cfg = new freemarker.template.Configuration(Configuration.VERSION_2_3_25);
        cfg.setTagSyntax(freemarker.template.Configuration.SQUARE_BRACKET_TAG_SYNTAX);
        cfg.setLazyAutoImports(true);
        cfg.setLocale(Locale.GERMANY); // todo make configurable
        cfg.addAutoImport("saito", "saito.ftl");
        cfg.setSharedVariable("saitoLinkHelper", linkHelper);
        cfg.setDefaultEncoding("UTF-8");
        cfg.setLogTemplateExceptions(false);
        cfg.setTemplateLoader(templateLoader);
        return cfg;
    } catch (TemplateModelException | ClassNotFoundException e) {
        log.error("Error creating config", e);
        throw new IllegalStateException(e);
    }
}
 
開發者ID:marcobehler,項目名稱:saito,代碼行數:20,代碼來源:FreemarkerModule.java

示例9: init

private void init() {
	if (inited) {
		return;
	}
	lock.lock();
	try {
		if (!inited) {
			cfg = new Configuration(Configuration.VERSION_2_3_25);
			cfg.setDefaultEncoding(encode);
			cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
			cfg.setClassLoaderForTemplateLoading(ClassLoader.getSystemClassLoader(), tmplPath);
		}
	} finally {
		lock.unlock();
	}
}
 
開發者ID:kanven,項目名稱:schedule,代碼行數:16,代碼來源:TmplMarker.java

示例10: TemplateService

public TemplateService() {

		String templatePath = new File("").getAbsolutePath();
		System.out.println("Using template path '" + templatePath + "'.");
		
		try {
			config = new Configuration(Configuration.VERSION_2_3_25);
			config.setDirectoryForTemplateLoading(new File(templatePath));
			config.setDefaultEncoding("UTF-8");
			config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
			config.setLogTemplateExceptions(false);
		} catch (IOException e) {
			throw new FileLibraryException(e);
		}
		
	}
 
開發者ID:dvanherbergen,項目名稱:robotframework-filelibrary,代碼行數:16,代碼來源:TemplateService.java

示例11: processIndexPageTemplate

private void processIndexPageTemplate(ProjectDescriptor projectDescriptor, CustomData customData) throws IOException, URISyntaxException, TemplateException {
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_25);
    cfg.setClassLoaderForTemplateLoading(getClass().getClassLoader(), "template");
    cfg.setDefaultEncoding("UTF-8");
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    cfg.setLogTemplateExceptions(false);
    Map<String, Object> root = new HashMap<String, Object>();
    root.put("project", projectDescriptor);
    root.put("customData", customData);
    Template template = cfg.getTemplate("index.ftl");
    template.process(root, new FileWriter(new File(outputDir, "index.html")));
}
 
開發者ID:gradle-guides,項目名稱:gradle-site-plugin,代碼行數:12,代碼來源:FreemarkerSiteGenerator.java

示例12: createFreemarkerConfig

public Configuration createFreemarkerConfig() throws IOException {
    final Configuration cfg = new Configuration(Configuration.VERSION_2_3_25);
    final File templateDirectory = findTemplateDirectory();
    cfg.setDirectoryForTemplateLoading(templateDirectory);
    cfg.setDefaultEncoding("UTF-8");
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
    cfg.setLogTemplateExceptions(false);

    return cfg;
}
 
開發者ID:blackducksoftware,項目名稱:hub-email-extension,代碼行數:10,代碼來源:EmailEngine.java

示例13: createConfiguration

private static Configuration createConfiguration() {
  Configuration configuration = new Configuration(Configuration.VERSION_2_3_25);
  configuration.setClassForTemplateLoading(Templates.class, "/templates/appengine");
  configuration.setDefaultEncoding(StandardCharsets.UTF_8.name());
  configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
  configuration.setLogTemplateExceptions(false);
  return configuration;
}
 
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-eclipse,代碼行數:8,代碼來源:Templates.java

示例14: replacePattern

private String replacePattern(String variableString, Object data) {
    String result;

    // 1. process proxy
    StringWriter writer = new StringWriter();
    try {
        freemarker.template.Template t = new freemarker.template.Template(variableString, variableString, new Configuration(Configuration.VERSION_2_3_25));
        t.process(data, writer);
    } catch (TemplateException | IOException e) {
        e.printStackTrace();
    }
    return writer.toString();
}
 
開發者ID:marcobehler,項目名稱:saito,代碼行數:13,代碼來源:FrontMatter.java


注:本文中的freemarker.template.Configuration.VERSION_2_3_25屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。