当前位置: 首页>>代码示例>>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;未经允许,请勿转载。