Package freemarker.template

Examples of freemarker.template.TemplateHashModel


                return new Float("1.1");
            }
        });

        // TemplateHashModel
        params.put("property7", new TemplateHashModel() {
            public TemplateModel get(String arg0) throws TemplateModelException {
                return null;
            }

            public boolean isEmpty() throws TemplateModelException {
View Full Code Here


    }

    private Map<String, Object> _getContext() throws TemplateModelException {
        BeansWrapper wrapper = BeansWrapper.getDefaultInstance();

        TemplateHashModel staticModels = wrapper.getStaticModels();

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

        context.put("hbmFileName", _hbmFileName);
        context.put("ormFileName", _ormFileName);
        context.put("modelHintsFileName", _modelHintsFileName);
        context.put("springFileName", _springFileName);
        context.put("springBaseFileName", _springBaseFileName);
        context.put("springHibernateFileName", _springHibernateFileName);
        context.put(
                "springInfrastructureFileName", _springInfrastructureFileName);
        context.put("apiDir", _apiDir);
        context.put("implDir", _implDir);
        context.put("sqlDir", _sqlDir);
        context.put("sqlFileName", _sqlFileName);
        context.put("beanLocatorUtil", _beanLocatorUtil);
        context.put("beanLocatorUtilShortName", _beanLocatorUtilShortName);
        context.put("propsUtil", _propsUtil);
        context.put("portletName", _portletName);
        context.put("portletShortName", _portletShortName);
        context.put("portletPackageName", _portletPackageName);
        context.put("outputPath", _outputPath);
        context.put("serviceOutputPath", _serviceOutputPath);
        context.put("packagePath", _packagePath);
        context.put("pluginName", _pluginName);
        context.put("author", _author);
        context.put("serviceBuilder", this);

        context.put("arrayUtil", ArrayUtil_IW.getInstance());
        context.put("modelHintsUtil", _modelHints.getModelHints());
        context.put(
                "resourceActionsUtil", ResourceActionsUtil.getResourceActions());
        context.put("stringUtil", StringUtil_IW.getInstance());
        context.put("system", staticModels.get("java.lang.System"));
        context.put("tempMap", wrapper.wrap(new HashMap<String, Object>()));
        context.put(
                "textFormatter", staticModels.get(TextFormatter.class.getName()));
        context.put("validator", Validator_IW.getInstance());

        return context;
    }
View Full Code Here

                return new Float("1.1");
            }
        });

        // TemplateHashModel
        params.put("property7", new TemplateHashModel() {
            public TemplateModel get(String arg0) throws TemplateModelException {
                return null;
            }

            public boolean isEmpty() throws TemplateModelException {
View Full Code Here

                return new Float("1.1");
            }
        });

        // TemplateHashModel
        params.put("property7", new TemplateHashModel() {
            public TemplateModel get(String arg0) throws TemplateModelException {
                return null;
            }

            public boolean isEmpty() throws TemplateModelException {
View Full Code Here

  public void testWrapEnums() throws Exception {
    APTJellyObjectWrapper wrapper = new APTJellyObjectWrapper();
    TemplateModel wrapped = wrapper.wrap(KnownXmlType.STRING);
    assertTrue(wrapped instanceof TemplateHashModel);
    TemplateHashModel hash = ((TemplateHashModel) wrapped);
    assertNotNull(hash.get("anonymous"));

    wrapped = wrapper.wrap(ContentType.COMPLEX);
    assertTrue(wrapped instanceof TemplateHashModel);
    hash = ((TemplateHashModel) wrapped);
    TemplateModel complex = hash.get("complex");
    assertNotNull(complex);
    assertTrue(complex instanceof TemplateBooleanModel);
    assertTrue(((TemplateBooleanModel) complex).getAsBoolean());
  }
View Full Code Here

     * @throws TemplateModelException If something goes wrong.
     */
    @Test
    public void testCreateRequestContext() throws TemplateModelException {
        Template template = createMock(Template.class);
        TemplateHashModel model = createMock(TemplateHashModel.class);
        StringWriter writer = new StringWriter();
        expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
        TilesRequestContextFactory parentFactory = createMock(TilesRequestContextFactory.class);
        TilesApplicationContext applicationContext = createMock(TilesApplicationContext.class);
        HttpServletRequest request = createMock(HttpServletRequest.class);
        HttpServletResponse response = createMock(HttpServletResponse.class);
        ObjectWrapper wrapper = createMock(ObjectWrapper.class);
        HttpRequestHashModel requestModel = new HttpRequestHashModel(request, response, wrapper);
        expect(model.get("Request")).andReturn(requestModel);
        TilesRequestContext enclosedRequest = createMock(TilesRequestContext.class);
        expect(parentFactory.createRequestContext(applicationContext, request, response)).andReturn(enclosedRequest);
        replay(template, model, parentFactory, applicationContext, request, response, wrapper);
        Environment env = new Environment(template, model, writer);
        factory = new FreeMarkerTilesRequestContextFactory();
View Full Code Here

     * @throws java.lang.Exception If something goes wrong.
     */
    @Before
    public void setUp() throws Exception {
        Template template = createMock(Template.class);
        TemplateHashModel model = createMock(TemplateHashModel.class);
        writer = new StringWriter();
        expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
        replay(template, model);
        env = new Environment(template, model, writer);
        locale = Locale.ITALY;
View Full Code Here

    @Test
    public void testCreateRequest() throws IOException, TemplateModelException{
        @SuppressWarnings("unchecked")
        Map<String, TemplateModel> params = createMock(Map.class);
        Template template = createMock(Template.class);
        TemplateHashModel rootDataModel = createMock(TemplateHashModel.class);
        Writer out = createMock(Writer.class);
        TemplateDirectiveBody body = createMock(TemplateDirectiveBody.class);
        GenericServlet servlet = createMock(GenericServlet.class);
        ObjectWrapper wrapper = createMock(ObjectWrapper.class);
        ServletContext servletContext = createMock(ServletContext.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        HttpServletRequest httpServletRequest = createMock(HttpServletRequest.class);
        HttpServletResponse httpServletResponse = createMock(HttpServletResponse.class);

        expect(template.getMacros()).andReturn(new HashMap<String, Macro>());
        expect(servlet.getServletContext()).andReturn(servletContext)
                .anyTimes();
        expect(
                servletContext
                        .getAttribute(ApplicationAccess.APPLICATION_CONTEXT_ATTRIBUTE))
                .andReturn(applicationContext);

        replay(servlet, wrapper, servletContext, applicationContext,
                httpServletRequest, httpServletResponse);
        ServletContextHashModel servletContextHashModel = new ServletContextHashModel(
                servlet, wrapper);
        HttpRequestHashModel httpRequestHashModel = new HttpRequestHashModel(
                httpServletRequest, httpServletResponse, wrapper);

        expect(rootDataModel.get(FreemarkerServlet.KEY_APPLICATION)).andReturn(
                servletContextHashModel);
        expect(rootDataModel.get(FreemarkerServlet.KEY_REQUEST)).andReturn(
                httpRequestHashModel);

        replay(template, rootDataModel, out);
        Environment env = new Environment(template, rootDataModel, out);
View Full Code Here

    }

    @Test
    public void testCreateModelBody() {
        Template template = createMock(Template.class);
        TemplateHashModel rootDataModel = createMock(TemplateHashModel.class);
        Writer out = createMock(Writer.class);
        expect(template.getMacros()).andReturn(new HashMap<String, Macro>());
        replay(template, rootDataModel, out);
        Environment env = new Environment(template, rootDataModel, out);
        @SuppressWarnings("unchecked")
View Full Code Here

    }

    @Test
    public void testGetParameter() throws TemplateModelException {
        Template template = createMock(Template.class);
        TemplateHashModel rootDataModel = createMock(TemplateHashModel.class);
        Writer out = createMock(Writer.class);
        expect(template.getMacros()).andReturn(new HashMap<String, Macro>());
        replay(template, rootDataModel, out);
        Environment env = new Environment(template, rootDataModel, out);
        TemplateNumberModel model = createMock(TemplateNumberModel.class);
View Full Code Here

TOP

Related Classes of freemarker.template.TemplateHashModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.