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


Java Configuration類代碼示例

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


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

示例1: buildToOutputStream

import freemarker.template.Configuration; //導入依賴的package包/類
public void buildToOutputStream(Class<?> commonServiceClass, OutputStream os) throws Exception {
	Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
	cfg.setClassForTemplateLoading(ThriftFileBuilder.class, "/");
	Template template = cfg.getTemplate("templates/thrift/thrift.ftl");
	Writer out = new OutputStreamWriter(os);

	ThriftServiceBuilder serviceBuilder = new ThriftServiceBuilder(commonServiceClass);
	ThriftService service = serviceBuilder.buildThriftService();

	Map<String, Object> rootMap = new HashMap<String, Object>();
	rootMap.put("thriftServicePackage", this.getPackageName(commonServiceClass));
	List<ThriftStruct> structs = serviceBuilder.getStructs();
	List<ThriftEnum> enums = serviceBuilder.getEnums();
	CommonUtils.removeRepeat(structs);
	rootMap.put("structList", structs);
	rootMap.put("enumList", enums);
	CommonUtils.removeRepeat(enums);
	rootMap.put("serviceList", Arrays.asList(service));

	template.process(rootMap, out);
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:22,代碼來源:ThriftFileBuilder.java

示例2: getFreemarkerConfiguration

import freemarker.template.Configuration; //導入依賴的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;
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:24,代碼來源:LocalFeedTaskProcessor.java

示例3: main

import freemarker.template.Configuration; //導入依賴的package包/類
public static void main(String[] args) {
    Map<String,Object> tmp = new HashMap<>();
    tmp.put("user","邢天宇");
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
    StringTemplateLoader loader = new StringTemplateLoader();
    loader.putTemplate(NAME,"hello ${user}");
    cfg.setTemplateLoader(loader);
    cfg.setDefaultEncoding("UTF-8");
    try {
        Template template = cfg.getTemplate(NAME);
        StringWriter writer = new StringWriter();
        template.process(tmp,writer);
        System.out.println(writer.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
開發者ID:rpgmakervx,項目名稱:slardar,代碼行數:19,代碼來源:TemplateParser.java

示例4: render

import freemarker.template.Configuration; //導入依賴的package包/類
public void render(String modelType) throws IOException {
    Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
    cfg.setDefaultEncoding("UTF-8");
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    cfg.setClassLoaderForTemplateLoading(SimpleModel.class.getClassLoader(), "/");
    if (!outDir.getParentFile().exists())
        outDir.getParentFile().mkdirs();
    String modelTypeName = modelType.substring(0, 1).toUpperCase() + modelType.substring(1);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("packageName", packageName);
    params.put("models", models);
    writeFile(packageName, modelTypeName, getTemplate(cfg, modelType), params);

    for (SimpleModel model : models) {
        if (model.isRender()) {
            params = new HashMap<>();
            params.put("model", model);
            writeFile(model.getPackageName(), model.getName(), getModelTemplate(cfg), params);
        }
    }
}
 
開發者ID:lifechurch,項目名稱:nuclei-android,代碼行數:22,代碼來源:Context.java

示例5: DaoGenerator

import freemarker.template.Configuration; //導入依賴的package包/類
public DaoGenerator() throws IOException {
    System.out.println("greenDAO Generator");
    System.out.println("Copyright 2011-2016 Markus Junginger, greenrobot.de. Licensed under GPL V3.");
    System.out.println("This program comes with ABSOLUTELY NO WARRANTY");

    patternKeepIncludes = compilePattern("INCLUDES");
    patternKeepFields = compilePattern("FIELDS");
    patternKeepMethods = compilePattern("METHODS");

    Configuration config = getConfiguration("dao.ftl");
    templateDao = config.getTemplate("dao.ftl");
    templateDaoMaster = config.getTemplate("dao-master.ftl");
    templateDaoSession = config.getTemplate("dao-session.ftl");
    templateEntity = config.getTemplate("entity.ftl");
    templateDaoUnitTest = config.getTemplate("dao-unit-test.ftl");
    templateContentProvider = config.getTemplate("content-provider.ftl");
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:DaoGenerator.java

示例6: initConfig

import freemarker.template.Configuration; //導入依賴的package包/類
@PostConstruct
public void initConfig() throws Exception {
    Configuration configuration = new Configuration();
    File file = new File(servletContext.getRealPath("/WEB-INF/layouts"));
    configuration.setDirectoryForTemplateLoading(file);
    configuration.setDefaultEncoding("UTF-8");
    this.template = configuration.getTemplate("email.template");
}
 
開發者ID:wolfboys,項目名稱:opencron,代碼行數:9,代碼來源:NoticeService.java

示例7: buildFreemarkerHelper

import freemarker.template.Configuration; //導入依賴的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);
}
 
開發者ID:sgota,項目名稱:tkcg,代碼行數:21,代碼來源:Generator.java

示例8: writeCommandCards

import freemarker.template.Configuration; //導入依賴的package包/類
private IStatus writeCommandCards(boolean obsRefreshFlag, String templateInputDirectory, String templateOutputDirectory) {
	Writer playerArmyFile = null;
	try {
		Configuration config = us.nineworlds.xstreamer.core.Activator.getDefault().getFreemarkerConfig();
		config.setDirectoryForTemplateLoading(new File(templateInputDirectory));
		
		java.nio.file.Path jpath = java.nio.file.Paths.get(templateFilename);
		Template armyTemplate = config.getTemplate(jpath.getFileName().toString());
		playerArmyFile = new FileWriter(new File(templateOutputDirectory + File.separator + commandFilename));

		Map<String, Object> input = new HashMap<>();

		input.put("iaspec", iaspec);
		input.put("allDeployments", Activator.getDefault().getDeploymentsLookup().getDeployments());
		input.put("allCommandCards", Activator.getDefault().getCommandCardLookup().getCommandCards());
		input.put("obs_refresh", obsRefreshFlag);

		armyTemplate.process(input, playerArmyFile);
	} catch (Exception e) {
		e.printStackTrace();
		return Status.CANCEL_STATUS;
	} finally {
		IOUtils.closeQuietly(playerArmyFile);			
	}
	return Status.OK_STATUS;
}
 
開發者ID:NineWorlds,項目名稱:xstreamer,代碼行數:27,代碼來源:GenerateCommandJob.java

示例9: templateConfiguration

import freemarker.template.Configuration; //導入依賴的package包/類
private static Configuration templateConfiguration() {
  Configuration configuration = new Configuration(Configuration.VERSION_2_3_26);
  configuration.setDefaultEncoding("UTF-8");
  configuration.setLogTemplateExceptions(false);
  try {
    configuration.setSetting("object_wrapper",
        "DefaultObjectWrapper(2.3.26, forceLegacyNonListCollections=false, "
            + "iterableSupport=true, exposeFields=true)");
  } catch (TemplateException e) {
    e.printStackTrace();
  }
  configuration.setAPIBuiltinEnabled(true);
  configuration.setClassLoaderForTemplateLoading(ClassLoader.getSystemClassLoader(),
      "templates/ccda");
  return configuration;
}
 
開發者ID:synthetichealth,項目名稱:synthea_java,代碼行數:17,代碼來源:CCDAExporter.java

示例10: runReport

import freemarker.template.Configuration; //導入依賴的package包/類
private static void runReport(Parameters params) {
    Map<String, TestCasesData> tests = loadTestCases( params );
    Map<String, Vendor> results = loadTestResults( params, tests );
    Map<String, List<TestCasesData>> labels = sortTestsByLabel( tests );

    ReportHeader header = createReportHeader( tests, labels, results );
    Map<String, ReportTable> tableByLabels = createTableByLabels( labels, results );
    Map<String, ReportChart> chartByLabels = createChartByLabels( labels, results);
    Map<String, ReportChart> chartByLabelsPercent = createChartByLabelsPercent( labels, results);
    ReportTable tableAllTests = createTableAllTests( params, tests.values() );
    Map<String, ReportTable> tableAllTestsByVendor = createTableAllTestsByVendor( params, tests.values(), results );
    Map<String, List<ReportTable>> tableIndividualLabels = createTableByIndividualLabels( params, labels, results );

    logger.info( "Generating report" );
    Configuration cfg = createFreemarkerConfiguration();

    IndexGenerator.generatePage( params, cfg, header, results );
    for( Vendor vendor : results.values() ) {
        OverviewGenerator.generatePage( params, cfg, vendor, header, tableByLabels.get( vendor.getFileNameId() ),
                                        chartByLabels.get( vendor.getFileNameId() ), chartByLabelsPercent.get( vendor.getFileNameId() ) );
        DetailGenerator.generatePage( params, cfg, vendor, header, tableAllTestsByVendor.get( vendor.getFileNameId() ), tableIndividualLabels.get( vendor.getFileNameId() ) );
    }
    TestsGenerator.generatePage( params, cfg, header, tableAllTests );
    GlossaryGenerator.generatePage( params, cfg, header );
}
 
開發者ID:dmn-tck,項目名稱:tck,代碼行數:26,代碼來源:Reporter.java

示例11: prepareConfiguration

import freemarker.template.Configuration; //導入依賴的package包/類
private static Configuration prepareConfiguration() {
  Configuration result = new Configuration(Configuration.VERSION_2_3_26);

  result.setNumberFormat("computer");
  result.setDefaultEncoding(StandardCharsets.UTF_8.name());
  result.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
  result.setLogTemplateExceptions(false);

  return result;
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:11,代碼來源:TemplateProcessor.java

示例12: generateResumeHTML

import freemarker.template.Configuration; //導入依賴的package包/類
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,代碼行數:21,代碼來源:ResumeGenerator.java

示例13: allSignatures

import freemarker.template.Configuration; //導入依賴的package包/類
public void allSignatures(String inputFile) throws IOException, TemplateException {
    Configuration cfg = new Configuration();
    Template template = cfg.getTemplate(inputFile);
    Map<String, Object> data = new HashMap<String, Object>();

    template.process(data, new OutputStreamWriter(System.out)); //TP
    template.process(data, new OutputStreamWriter(System.out), null); //TP
    template.process(data, new OutputStreamWriter(System.out), null, null); //TP
}
 
開發者ID:blackarbiter,項目名稱:Android_Code_Arbiter,代碼行數:10,代碼來源:FreemarkerUsage.java

示例14: writeToFile

import freemarker.template.Configuration; //導入依賴的package包/類
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,代碼行數:20,代碼來源:HtmlReport.java

示例15: SchemaMaker

import freemarker.template.Configuration; //導入依賴的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;
}
 
開發者ID:folio-org,項目名稱:raml-module-builder,代碼行數:20,代碼來源:SchemaMaker.java


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