当前位置: 首页>>代码示例>>Java>>正文


Java DefaultObjectWrapper类代码示例

本文整理汇总了Java中freemarker.template.DefaultObjectWrapper的典型用法代码示例。如果您正苦于以下问题:Java DefaultObjectWrapper类的具体用法?Java DefaultObjectWrapper怎么用?Java DefaultObjectWrapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DefaultObjectWrapper类属于freemarker.template包,在下文中一共展示了DefaultObjectWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFreemarkerConfiguration

import freemarker.template.DefaultObjectWrapper; //导入依赖的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

示例2: initialValue

import freemarker.template.DefaultObjectWrapper; //导入依赖的package包/类
@Override
protected ObjectWrapper initialValue()
{
    return new DefaultObjectWrapper()
    {
        /* (non-Javadoc)
         * @see freemarker.template.DefaultObjectWrapper#wrap(java.lang.Object)
         */
        @Override
        public TemplateModel wrap(Object obj) throws TemplateModelException
        {
            if (obj instanceof QNameMap)
            {
                return new QNameHash((QNameMap)obj, this);
            }
            else
            {
                return super.wrap(obj);
            }
        }
    };
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:QNameAwareObjectWrapper.java

示例3: ValidatableFormAdapter

import freemarker.template.DefaultObjectWrapper; //导入依赖的package包/类
public ValidatableFormAdapter(Validatable form, DefaultObjectWrapper ow) {
    super(form, ow);
    this.hasErrors = arguments -> {
        if (arguments.size() == 0) {
            return Boolean.valueOf(form.hasErrors());
        } else if (arguments.size() == 1) {
            return Boolean.valueOf(form.hasErrors(arguments.get(0).toString()));
        } else {
            return null;
        }
    };

    this.getErrors = arguments -> {
        if (arguments.size() == 0) {
            return form.getErrors();
        } else if (arguments.size() == 1) {
            return form.getErrors(arguments.get(0).toString());
        } else {
            return null;
        }
    };
}
 
开发者ID:kawasima,项目名称:enkan,代码行数:23,代码来源:ValidatableFormAdapter.java

示例4: getConfigurationByClass

import freemarker.template.DefaultObjectWrapper; //导入依赖的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

示例5: getConfigurationByClassLoader

import freemarker.template.DefaultObjectWrapper; //导入依赖的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

示例6: getConfigurationByDirectory

import freemarker.template.DefaultObjectWrapper; //导入依赖的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

示例7: execute

import freemarker.template.DefaultObjectWrapper; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
    throws TemplateException, IOException {
    SimpleScalar pVar = (SimpleScalar) params.get("var");

    List<RetailStore> retailStoreList = retailStores.enabledRetailStores();

    if (pVar != null) {
        // Sets the result into the current template as if using <#assign
        // name=model>.
        env.setVariable(pVar.getAsString(), DefaultObjectWrapper.getDefaultInstance().wrap(retailStoreList));
    } else {
        // Sets the result into the current template as if using <#assign
        // name=model>.
        env.setVariable("retailStores", DefaultObjectWrapper.getDefaultInstance().wrap(retailStoreList));
    }
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:19,代码来源:FetchRetailStoresDirective.java

示例8: getTemplate

import freemarker.template.DefaultObjectWrapper; //导入依赖的package包/类
/**
 * 获取模板
 * 
 * @param templateName
 *            模板名称(含后缀名)
 * @return Template
 * @throws IOException
 */
public static Template getTemplate(String templateName) throws IOException {
	Configuration cfg = new Configuration();
	Template temp = null;
	File tmpRootFile = getResource(templateName).getFile().getParentFile();
	if (tmpRootFile == null) {
		throw new RuntimeException("无法取得模板根路径!");
	}
	try {
		cfg.setDefaultEncoding("utf-8");
		cfg.setOutputEncoding("utf-8");
		cfg.setDirectoryForTemplateLoading(tmpRootFile);
		/* cfg.setDirectoryForTemplateLoading(getResourceURL()); */
		cfg.setObjectWrapper(new DefaultObjectWrapper());
		temp = cfg.getTemplate(templateName);
	} catch (IOException e) {
		e.printStackTrace();
	}
	return temp;
}
 
开发者ID:bill1012,项目名称:AdminEAP,代码行数:28,代码来源:FreeMarkerUtil.java

示例9: buildUserFileUploadList

import freemarker.template.DefaultObjectWrapper; //导入依赖的package包/类
protected List<File> buildUserFileUploadList() throws Exception {
    List<File> fileUploadList = new ArrayList<File>();
    try {
        Properties props = loadProperties(PROPS_LOCATION, DEFAULT_PROPS_LOCATION);

        String usersArg = System.getProperty("xmlingester.user.list").replace(".", "").replace("-", "").toLowerCase();
        List<XmlIngesterUser> xmlIngesterUsers = new LinkedList<XmlIngesterUser>();
        StringTokenizer token = new StringTokenizer(usersArg, ",");
        while (token.hasMoreTokens()) {
            xmlIngesterUsers.add(new XmlIngesterUser(token.nextToken()));
        }

        props.put("xmlIngesterUsers", xmlIngesterUsers);

        cfg.setObjectWrapper(new DefaultObjectWrapper());

        // build files and add to array
        fileUploadList.add(
                writeTemplateToFile(newTempFile("userlist-users.xml"), cfg.getTemplate("UserListIngestion.ftl"), props));

    } catch( Exception e) {
        throw new Exception("Unable to generate files for upload " + e.getMessage(), e);
    }

    return fileUploadList;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:27,代码来源:XmlIngesterAftBase.java

示例10: init

import freemarker.template.DefaultObjectWrapper; //导入依赖的package包/类
public void init() {
	// 初始化FreeMarker配置
	// 创建一个Configuration实例
	cfg = new Configuration();
	// 设置FreeMarker的模版文件位置
	cfg.setServletContextForTemplateLoading(getServletContext(), "template");
	// 设置包装器,并将对象包装为数据模型
	cfg.setObjectWrapper(new DefaultObjectWrapper());
	try {
		fr = FisRewrite.getInstance();
	} catch (FisException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}
 
开发者ID:bignippleboy,项目名称:ipaas,代码行数:17,代码来源:FisFreemarkerServlet.java

示例11: getTemplate

import freemarker.template.DefaultObjectWrapper; //导入依赖的package包/类
/**
 * 获取模板
 * 
 * @param templatePath
 *            模板文件存放目录
 * @param templateName
 *            模板文件名称
 * @param templateEncoding
 *            模板文件的编码方式
 * @throws IOException
 */
public static Template getTemplate(String templatePath, String templateName, String templateEncoding)
		throws IOException {

	Configuration config = new Configuration();
	File file = new File(templatePath);
	// 设置要解析的模板所在的目录,并加载模板文件
	config.setDirectoryForTemplateLoading(file);
	// 设置包装器,并将对象包装为数据模型
	config.setObjectWrapper(new DefaultObjectWrapper());

	// 获取模板,并设置编码方式,这个编码必须要与页面中的编码格式一致
	Template template = config.getTemplate(templateName, templateEncoding);

	return template;
}
 
开发者ID:bignippleboy,项目名称:ipaas,代码行数:27,代码来源:FtlUtil.java

示例12: FacadeRouterCodeGenerator

import freemarker.template.DefaultObjectWrapper; //导入依赖的package包/类
/**
 * 
 * @param messager - the compiler message to print messages to
 * @param generateMockImplementation 
 * @param packageName - the package name of the generated class (and the interface to implement)
 * @param interfaceName - the (simple) name of the interface to implement
 */
public FacadeRouterCodeGenerator(Messager messager, 
		boolean generateMockImplementation,
		boolean generateTests)
{
	freemarkerConfig = new Configuration();
	
	freemarkerConfig.setTemplateLoader( new ClassLoaderTemplateLoader(this.getClass().getClassLoader(), messager) );
	freemarkerConfig.setObjectWrapper(new DefaultObjectWrapper());

	dataModel.put(METHODS, new ArrayList<Map<String, Object>>());
	dataModel.put(IMPORTS, new ArrayList<String>());
	
	this.messager = messager;
	this.generateMockImplementation = generateMockImplementation;
	this.generateTests = generateTests;
}
 
开发者ID:VHAINNOVATIONS,项目名称:Telepathology,代码行数:24,代码来源:FacadeRouterCodeGenerator.java

示例13: SourceReportGenerator

import freemarker.template.DefaultObjectWrapper; //导入依赖的package包/类
public SourceReportGenerator(GradeCategories grades, SourceLoader sourceLoader,
    File outputDirectory, CostModel costModel, Date currentTime,
    int worstCount, Configuration cfg) {
  this.grades = grades;
  this.sourceLoader = sourceLoader;
  this.directory = outputDirectory;
  this.costModel = costModel;
  this.cfg = cfg;
  cfg.setTemplateLoader(new ClassPathTemplateLoader(PREFIX));
  cfg.setObjectWrapper(new DefaultObjectWrapper());
  try {
    cfg.setSharedVariable("maxExcellentCost", grades.getMaxExcellentCost());
    cfg.setSharedVariable("maxAcceptableCost", grades.getMaxAcceptableCost());
    cfg.setSharedVariable("currentTime", currentTime);
    cfg.setSharedVariable("computeOverallCost", new OverallCostMethod());
    cfg.setSharedVariable("printCost", new PrintCostMethod());
  } catch (TemplateModelException e) {
    throw new RuntimeException(e);
  }
  projectByClassReport = new ProjectReport("index", grades,
      new WeightedAverage());
  projectByClassReport.setMaxUnitCosts(worstCount);
  projectByPackageReport = new ProjectReport("index", grades,
      new WeightedAverage());
}
 
开发者ID:mhevery,项目名称:testability-explorer,代码行数:26,代码来源:SourceReportGenerator.java

示例14: ExtraDaoGenerator

import freemarker.template.DefaultObjectWrapper; //导入依赖的package包/类
public ExtraDaoGenerator() throws IOException {
    System.out.println("greenDAO Generator");
    System.out.println("Copyright 2011-2014 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();
    config.setClassForTemplateLoading(this.getClass(), "/");
    config.setObjectWrapper(new DefaultObjectWrapper());

    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");
    templateDBService = config.getTemplate("db-service.ftl");
}
 
开发者ID:ourbeehive,项目名称:AndPlug,代码行数:22,代码来源:ExtraDaoGenerator.java

示例15: FreeMarkerRenderer

import freemarker.template.DefaultObjectWrapper; //导入依赖的package包/类
public FreeMarkerRenderer() {
	cfg = new Configuration();
	
	if(ApplicationState.isDevelopment()){
		try {
			cfg.setDirectoryForTemplateLoading(new File("src/main/resources/templates/"));
		} catch (IOException e) {
			l.error("Failed to access path", e);
		}
	}else{
		cfg.setClassForTemplateLoading(this.getClass(), "/templates/");
	}
	
	cfg.setObjectWrapper(new DefaultObjectWrapper());
       cfg.setDefaultEncoding("UTF-8");
       cfg.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
}
 
开发者ID:Eldelshell,项目名称:JobHunter,代码行数:18,代码来源:FreeMarkerRenderer.java


注:本文中的freemarker.template.DefaultObjectWrapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。