本文整理汇总了Java中freemarker.template.Configuration.VERSION_2_3_23属性的典型用法代码示例。如果您正苦于以下问题:Java Configuration.VERSION_2_3_23属性的具体用法?Java Configuration.VERSION_2_3_23怎么用?Java Configuration.VERSION_2_3_23使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类freemarker.template.Configuration
的用法示例。
在下文中一共展示了Configuration.VERSION_2_3_23属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildToOutputStream
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);
}
示例2: main
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();
}
}
示例3: DaoGenerator
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 = new Configuration(Configuration.VERSION_2_3_23);
config.setClassForTemplateLoading(this.getClass(), "/");
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");
}
示例4: initializeConfiguration
/**
* Configures freemarker for usage.
* @return
* @throws URISyntaxException
* @throws TemplateNotFoundException
* @throws MalformedTemplateNameException
* @throws ParseException
* @throws IOException
* @throws TemplateException
*/
private Configuration initializeConfiguration() throws URISyntaxException, TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException{
Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
cfg.setClassForTemplateLoading(DwFeatureModelSVGGenerator.class, "templates");
cfg.setDefaultEncoding("UTF-8");
cfg.setLocale(Locale.US);
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
Bundle bundle = Platform.getBundle("de.darwinspl.feature.graphical.editor");
URL fileURL = bundle.getEntry("templates/");
File file = new File(FileLocator.resolve(fileURL).toURI());
cfg.setDirectoryForTemplateLoading(file);
Map<String, TemplateNumberFormatFactory> customNumberFormats = new HashMap<String, TemplateNumberFormatFactory>();
customNumberFormats.put("hex", DwHexTemplateNumberFormatFactory.INSTANCE);
cfg.setCustomNumberFormats(customNumberFormats);
return cfg;
}
示例5: initializeConfiguration
private Configuration initializeConfiguration() throws URISyntaxException, TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException{
Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
cfg.setClassForTemplateLoading(DwFeatureModelOverviewGenerator.class, "templates");
cfg.setDefaultEncoding("UTF-8");
cfg.setLocale(Locale.US);
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
Map<String, TemplateDateFormatFactory> customDateFormats = new HashMap<String, TemplateDateFormatFactory>();
customDateFormats.put("simple", DwSimpleTemplateDateFormatFactory.INSTANCE);
cfg.setCustomDateFormats(customDateFormats);
cfg.setDateTimeFormat("@simle");
Bundle bundle = Platform.getBundle("eu.hyvar.feature.graphical.editor");
URL fileURL = bundle.getEntry("templates/");
File file = new File(FileLocator.resolve(fileURL).toURI());
cfg.setDirectoryForTemplateLoading(file);
return cfg;
}
示例6: before
public void before() {
configuration = new Configuration(Configuration.VERSION_2_3_23);
// configuration.setObjectWrapper(new
// DefaultObjectWrapper(Configuration.VERSION_2_3_23));
try {
// File resource = ResourceUtils.getResourceAsFile("/");
// logger.debug("path:" + resource.getAbsolutePath());
StringTemplateLoader templateLoader = new StringTemplateLoader();
configuration.setTemplateLoader(templateLoader);
Resource[] resources = ResourceUtils.getResources("classpath*:/template/*.ftl");
for (Resource resource : resources) {
String fileName = resource.getFilename();
String value = IOUtils.toString(resource.getInputStream());
templateLoader.putTemplate(fileName, value);
}
// templateLoader.putTemplate();
// configuration.setDirectoryForTemplateLoading(resource);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
}
示例7: PluginStatusReportViewBuilder
private PluginStatusReportViewBuilder() throws IOException {
configuration = new Configuration(Configuration.VERSION_2_3_23);
configuration.setTemplateLoader(new ClassTemplateLoader(getClass(), "/"));
configuration.setDefaultEncoding("UTF-8");
configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
configuration.setLogTemplateExceptions(false);
configuration.setDateTimeFormat("iso");
}
示例8: renderString
public static String renderString(String templateString, Map<String, ?> model) {
try {
StringWriter result = new StringWriter();
Template t = new Template("name", new StringReader(templateString), new Configuration(Configuration.VERSION_2_3_23));
t.process(model, result);
return result.toString();
} catch (Exception e) {
throw Exceptions.unchecked(e);
}
}
示例9: FreemarkerAttachmentRenderer
public FreemarkerAttachmentRenderer(final String templateName) {
this.templateName = templateName;
this.configuration = new Configuration(Configuration.VERSION_2_3_23);
this.configuration.setLocalizedLookup(false);
this.configuration.setTemplateUpdateDelayMilliseconds(0);
this.configuration.setClassLoaderForTemplateLoading(getClass().getClassLoader(), "tpl");
}
示例10: IndexServlet
public IndexServlet(DACConfig config, ServerHealthMonitor serverHealthMonitor, OptionManager options, SupportService supportService) {
this.config = config;
this.templateCfg = new Configuration(Configuration.VERSION_2_3_23);
this.serverHealthMonitor = serverHealthMonitor;
this.options = options;
this.supportService = supportService;
}
示例11: SpGenerator
public SpGenerator() throws IOException {
Configuration config = new Configuration(Configuration.VERSION_2_3_23);
config.setClassForTemplateLoading(this.getClass(), "/");
mTemplateSp = config.getTemplate("sp.ftl");
mTemplateMaster = config.getTemplate("master.ftl");
}
示例12: createTemplateConfiguration
private static Configuration createTemplateConfiguration() {
// The templates rendered by this demo application are based on Apache Freemarker.
Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
cfg.setClassLoaderForTemplateLoading(TotpExample.class.getClassLoader(), ResourcesHome.class.getPackage().getName().replace(".", "/"));
cfg.setDefaultEncoding("UTF-8");
// SECURITY NOTE: You should use the TemplateExceptionHandler.RETHROW_HANDLER in production!
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
return cfg;
}
示例13: Template
public Template() {
configuration = new Configuration(Configuration.VERSION_2_3_23);
// configuration.setObjectWrapper(new
// DefaultObjectWrapper(Configuration.VERSION_2_3_23));
templateMapping = new HashMap<String, JavaModeGenerate>();
templateLoader = new StringTemplateLoader();
configuration.setTemplateLoader(templateLoader);
}
示例14: before
@Before
public void before() {
configuration = new Configuration(Configuration.VERSION_2_3_23);
// configuration.setObjectWrapper(new DefaultObjectWrapper(Configuration.VERSION_2_3_23));
try {
File resource = ResourceUtils.getResourceAsFile("/template");
logger.debug("path:" + resource.getAbsolutePath());
configuration.setDirectoryForTemplateLoading(resource);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
}
示例15: buildConfiguration
public static Configuration buildConfiguration(String directory) throws IOException {
Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
Resource path = new DefaultResourceLoader().getResource(directory);
cfg.setDirectoryForTemplateLoading(path.getFile());
return cfg;
}