本文整理汇总了Java中freemarker.template.DefaultObjectWrapperBuilder类的典型用法代码示例。如果您正苦于以下问题:Java DefaultObjectWrapperBuilder类的具体用法?Java DefaultObjectWrapperBuilder怎么用?Java DefaultObjectWrapperBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultObjectWrapperBuilder类属于freemarker.template包,在下文中一共展示了DefaultObjectWrapperBuilder类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getConfigurationByClass
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的package包/类
/**
* 根据根路径的类,获取配置文件
* @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,代码行数:28,代码来源:FreeMkKit.java
示例2: getConfigurationByClassLoader
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的package包/类
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,代码行数:21,代码来源:FreeMkKit.java
示例3: getConfigurationByDirectory
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的package包/类
/**
* 根据模板的路径,获取一个配置文件
* @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,代码行数:29,代码来源:FreeMkKit.java
示例4: main
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Project project = new Project();
Configuration cfg = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
cfg.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS).build());
Template temp = cfg.getTemplate("src/assemblies/eclipse_classpath.ftl");
Map<String, Object> root = new HashMap<String, Object>();
root.put("project", project);
Writer out = new FileWriter(project.getOutputDirectory() + "/eclipse_classpath");
temp.process(root, out);
out.flush();
project = new Project();
cfg = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
cfg.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS).build());
temp = cfg.getTemplate("src/assemblies/netbeans_classpath.ftl");
root = new HashMap<String, Object>();
root.put("project", project);
out = new FileWriter(project.getOutputDirectory() + "/netbeans_classpath");
temp.process(root, out);
out.flush();
}
开发者ID:svn2github,项目名称:dynamicreports-jasper,代码行数:22,代码来源:GenerateClasspath.java
示例5: showRollupEmail
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的package包/类
@GET
@Timed
@Path("/rollup")
@Produces(MediaType.TEXT_HTML)
public Response showRollupEmail(@Auth Person user, @QueryParam("startDate") Long start,
@QueryParam("endDate") Long end,
@QueryParam("orgType") OrganizationType orgType,
@QueryParam("advisorOrganizationId") Integer advisorOrgId,
@QueryParam("principalOrganizationId") Integer principalOrgId,
@QueryParam("showText") @DefaultValue("false") Boolean showReportText) {
DailyRollupEmail action = new DailyRollupEmail();
action.setStartDate(new DateTime(start));
action.setEndDate(new DateTime(end));
action.setChartOrgType(orgType);
action.setAdvisorOrganizationId(advisorOrgId);
action.setPrincipalOrganizationId(principalOrgId);
Map<String,Object> context = action.execute();
context.put("serverUrl", config.getServerUrl());
context.put(AdminSettingKeys.SECURITY_BANNER_TEXT.name(), engine.getAdminSetting(AdminSettingKeys.SECURITY_BANNER_TEXT));
context.put(AdminSettingKeys.SECURITY_BANNER_COLOR.name(), engine.getAdminSetting(AdminSettingKeys.SECURITY_BANNER_COLOR));
context.put(DailyRollupEmail.SHOW_REPORT_TEXT_FLAG, showReportText);
try {
Configuration freemarkerConfig = new Configuration(Configuration.getVersion());
freemarkerConfig.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.getVersion()).build());
freemarkerConfig.loadBuiltInEncodingMap();
freemarkerConfig.setDefaultEncoding(StandardCharsets.UTF_8.name());
freemarkerConfig.setClassForTemplateLoading(this.getClass(), "/");
freemarkerConfig.setAPIBuiltinEnabled(true);
Template temp = freemarkerConfig.getTemplate(action.getTemplateName());
StringWriter writer = new StringWriter();
temp.process(context, writer);
return Response.ok(writer.toString(), MediaType.TEXT_HTML_TYPE).build();
} catch (Exception e) {
throw new WebApplicationException(e);
}
}
开发者ID:deptofdefense,项目名称:anet,代码行数:41,代码来源:ReportResource.java
示例6: AnetEmailWorker
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的package包/类
public AnetEmailWorker(Handle dbHandle, AnetConfiguration config, ScheduledExecutorService scheduler) {
this.handle = dbHandle;
this.scheduler = scheduler;
this.mapper = new ObjectMapper();
mapper.registerModule(new JodaModule());
//mapper.enableDefaultTyping();
this.emailMapper = new AnetEmailMapper();
this.fromAddr = config.getEmailFromAddr();
this.serverUrl = config.getServerUrl();
instance = this;
SmtpConfiguration smtpConfig = config.getSmtp();
props = new Properties();
props.put("mail.smtp.starttls.enable", smtpConfig.getStartTls().toString());
props.put("mail.smtp.host", smtpConfig.getHostname());
props.put("mail.smtp.port", smtpConfig.getPort().toString());
auth = null;
if (smtpConfig.getUsername() != null && smtpConfig.getUsername().trim().length() > 0) {
props.put("mail.smtp.auth", "true");
auth = new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(smtpConfig.getUsername(), smtpConfig.getPassword());
}
};
}
freemarkerConfig = new Configuration(Configuration.getVersion());
freemarkerConfig.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.getVersion()).build());
freemarkerConfig.loadBuiltInEncodingMap();
freemarkerConfig.setDefaultEncoding(StandardCharsets.UTF_8.name());
freemarkerConfig.setClassForTemplateLoading(this.getClass(), "/");
freemarkerConfig.setAPIBuiltinEnabled(true);
}
开发者ID:deptofdefense,项目名称:anet,代码行数:35,代码来源:AnetEmailWorker.java
示例7: createFreeMarkerConfiguration
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的package包/类
/**
* Creates a new FreeMarker configuration.
* By default, it is configured as follows:
* <ul>
* <li>compatibility level is set to 2.3.23
* <li>the object wrapper is configured to expose fields
* <li>API builtins are enabled
* <li>there are 2 template loaders - 1 for loading templates from /META-INF using a classloader and a second
* one to load templates from files.
* </ul>
* @return
*/
protected Configuration createFreeMarkerConfiguration() {
DefaultObjectWrapperBuilder bld = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_23);
bld.setExposeFields(true);
Configuration freeMarker = new Configuration(Configuration.VERSION_2_3_23);
freeMarker.setObjectWrapper(bld.build());
freeMarker.setAPIBuiltinEnabled(true);
freeMarker.setTemplateLoader(new MultiTemplateLoader(
new TemplateLoader[]{new ClassTemplateLoader(getClass(), "/META-INF"),
new NaiveFileTemplateLoader()}));
return freeMarker;
}
开发者ID:revapi,项目名称:revapi,代码行数:27,代码来源:TextReporter.java
示例8: Environment
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的package包/类
private Environment() {
Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
// Specify the data source where the template files come from.
cfg.setClassForTemplateLoading(getClass(), "/templates/");
DefaultObjectWrapperBuilder builder = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_23);
builder.setExposeFields(true);
cfg.setObjectWrapper(builder.build());
freemarkerConfig = cfg;
fmHelper = new FreeMarkerHelper();
templateCache = new ConcurrentHashMap<String, Template>();
symbols = new ConcurrentHashMap<String, String>();
textFormatter = new TextFormatter();
xmlFormatter = new XMLFormatter();
nsContext = new NamespaceContextImpl();
fillNamespaceContext();
xPathHelper = new XPathHelper();
jsonPathHelper = new JsonPathHelper();
jsonHelper = new JsonHelper();
htmlCleaner = new HtmlCleaner();
httpClient = new HttpClient();
programHelper = new ProgramHelper();
programHelper.setTimeoutHelper(timeoutHelper);
configDatesHelper();
driverManager = new DriverManager();
cookieConverter = new CookieConverter();
}
开发者ID:fhoeben,项目名称:hsac-fitnesse-fixtures,代码行数:36,代码来源:Environment.java
示例9: getDefaultFreemarkerConfiguration
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的package包/类
/**
* Gets the default configuration for Freemarker within Windup.
*/
public static Configuration getDefaultFreemarkerConfiguration()
{
freemarker.template.Configuration configuration = new freemarker.template.Configuration(Configuration.VERSION_2_3_26);
DefaultObjectWrapperBuilder objectWrapperBuilder = new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_26);
objectWrapperBuilder.setUseAdaptersForContainers(true);
objectWrapperBuilder.setIterableSupport(true);
configuration.setObjectWrapper(objectWrapperBuilder.build());
configuration.setAPIBuiltinEnabled(true);
configuration.setTemplateLoader(new FurnaceFreeMarkerTemplateLoader());
configuration.setTemplateUpdateDelayMilliseconds(3600);
return configuration;
}
开发者ID:windup,项目名称:windup,代码行数:17,代码来源:FreeMarkerUtil.java
示例10: FreemarkerTemplate
import freemarker.template.DefaultObjectWrapperBuilder; //导入依赖的package包/类
public FreemarkerTemplate() {
configuration = new Configuration(Configuration.VERSION_2_3_23);
configuration.setDefaultEncoding("UTF-8");
configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
configuration.setObjectWrapper(new DefaultObjectWrapperBuilder(Configuration.VERSION_2_3_23).build());
}
开发者ID:canmogol,项目名称:FatJar,代码行数:7,代码来源:FreemarkerTemplate.java
注:本文中的freemarker.template.DefaultObjectWrapperBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论