Examples of TemplateScalarModel


Examples of freemarker.template.TemplateScalarModel

                return false;
            }
        });

        // TemplateScalarModel
        params.put("property3", new TemplateScalarModel() {
            public String getAsString() throws TemplateModelException {
                return "toby";
            }
        });
        params.put("property4", new TemplateScalarModel() {
            public String getAsString() throws TemplateModelException {
                return "phil";
            }
        });
View Full Code Here

Examples of freemarker.template.TemplateScalarModel

        String  result = "";
        Object o = args.get(key);
        if (o != null) {
            if (Debug.verboseOn()) Debug.logVerbose("Arg Object : " + o.getClass().getName(), module);
            if (o instanceof TemplateScalarModel) {
                TemplateScalarModel s = (TemplateScalarModel) o;
                try {
                    result = s.getAsString();
                } catch (TemplateModelException e) {
                    Debug.logError(e, "Template Exception", module);
                }
            } else {
              result = o.toString();
View Full Code Here

Examples of freemarker.template.TemplateScalarModel

                        // make the link
                        RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
                        out.write(rh.makeLink(request, response, buf.toString(), fullPath, secure, encode));
                    } else if (prefix != null) {
                        if (prefix instanceof TemplateScalarModel) {
                            TemplateScalarModel s = (TemplateScalarModel) prefix;
                            String prefixString = s.getAsString();
                            String bufString = buf.toString();
                            boolean prefixSlash = prefixString.endsWith("/");
                            boolean bufSlash = bufString.startsWith("/");
                            if (prefixSlash && bufSlash) {
                                bufString = bufString.substring(1);
View Full Code Here

Examples of freemarker.template.TemplateScalarModel

        String  result = "";
        Object o = args.get(key);
        if (o != null) {
            if (Debug.verboseOn()) Debug.logVerbose("Arg Object : " + o.getClass().getName(), module);
            if (o instanceof TemplateScalarModel) {
                TemplateScalarModel s = (TemplateScalarModel) o;
                try {
                    result = s.getAsString();
                } catch (TemplateModelException e) {
                    Debug.logError(e, "Template Exception", module);
                }
            } else {
              result = o.toString();
View Full Code Here

Examples of freemarker.template.TemplateScalarModel

            || key.equals("@@text")))
        {
            StringBuffer result = new StringBuffer();
            for (int i=0; i<size(); i++) {
                NodeModel nm = (NodeModel) get(i);
                TemplateScalarModel textModel = (TemplateScalarModel) nm.get(key);
                result.append(textModel.getAsString());
            }
            return new SimpleScalar(result.toString());
        }
        if (StringUtil.isXMLID(key)
            || ((key.startsWith("@") && StringUtil.isXMLID(key.substring(1))))
View Full Code Here

Examples of freemarker.template.TemplateScalarModel

    public TemplateModel get(int index) {
        if (array == null) {
            array = new TemplateScalarModel[stringArray.length];
        }
        TemplateScalarModel result = array[index];
        if (result == null) {
            result = new SimpleScalar(stringArray[index]);
            array[index] = result;
        }
        return result;
View Full Code Here

Examples of freemarker.template.TemplateScalarModel

        return bw.wrap(new HashMap()) instanceof SimpleMapModel;
    }
   
    private boolean exposesFields(BeansWrapper bw) throws TemplateModelException {
        TemplateHashModel thm = (TemplateHashModel) bw.wrap(new C());
        TemplateScalarModel r = (TemplateScalarModel) thm.get("foo");
        if (r == null) return false;
        assertEquals("FOO", r.getAsString());
        return true;
    }
View Full Code Here

Examples of freemarker.template.TemplateScalarModel

        return true;
    }

    private boolean exposesProperties(BeansWrapper bw) throws TemplateModelException {
        TemplateHashModel thm = (TemplateHashModel) bw.wrap(new C());
        TemplateScalarModel r = (TemplateScalarModel) thm.get("bar");
        if (r == null) return false;
        assertEquals("BAR", r.getAsString());
        return true;
    }
View Full Code Here

Examples of freemarker.template.TemplateScalarModel

        private static void addKeys(Set set, SimpleSequence keySeq, TemplateHashModelEx hash)
        throws TemplateModelException
        {
            TemplateModelIterator it = hash.keys().iterator();
            while (it.hasNext()) {
                TemplateScalarModel tsm = (TemplateScalarModel)it.next();
                if (set.add(tsm.getAsString())) {
                    // The first occurence of the key decides the index;
                    // this is consisten with stuff like java.util.LinkedHashSet.
                    keySeq.add(tsm);
                }
            }
View Full Code Here

Examples of freemarker.template.TemplateScalarModel

                return false;
            }
        });

        // TemplateScalarModel
        params.put("property3", new TemplateScalarModel() {
            public String getAsString() throws TemplateModelException {
                return "toby";
            }
        });
        params.put("property4", new TemplateScalarModel() {
            public String getAsString() throws TemplateModelException {
                return "phil";
            }
        });
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.