Package freemarker.core

Examples of freemarker.core.Environment$NumberFormatKey


  public void render(String template, ValueStack stack, Writer writer, Component component)
      throws Exception {
    SimpleHash model = buildModel(stack, component);
    Object prevTag = model.get("tag");
    model.put("tag", component);
    Environment env = getEnvironment(template, stack, model, writer);
    env.process();
    if (null != prevTag) {
      model.put("tag", prevTag);
    }
  }
View Full Code Here


    Map<String, Environment> envs = (Map<String, Environment>) stack.getContext().get(UI_ENV_CACHE);
    if (null == envs) {
      envs = CollectUtils.newHashMap();
      stack.getContext().put(UI_ENV_CACHE, envs);
    }
    Environment env = envs.get(templateName);
    if (null == env) {
      try {
        Template template = loadTemplate(templateName);
        env = template.createProcessingEnvironment(model, writer);
        envs.put(templateName, env);
      } catch (ParseException pe) {
        throw pe;
      }
    } else {
      env.setOut(writer);
    }
    return env;
  }
View Full Code Here

            }
        }
    };

    static Template getTemplate(String systemId) throws IOException {
        Environment env = Environment.getCurrentEnvironment();
        String encoding = env.getTemplate().getEncoding();
        if (encoding == null) {
            encoding = env.getConfiguration().getEncoding(env.getLocale());
        }
        String templatePath = env.getTemplate().getName();
        int lastSlash = templatePath.lastIndexOf('/');
        templatePath = lastSlash == -1 ? "" : templatePath.substring(0, lastSlash + 1);
        systemId = TemplateCache.getFullTemplatePath(env, templatePath, systemId);
        Template raw = env.getConfiguration().getTemplate(systemId, env.getLocale(), encoding, false);
        return raw;
    }
View Full Code Here

   
    String getQualifiedName() {
        String nsURI = node.getNamespaceURI();
        if (nsURI == null || nsURI.equals(""))
            return node.getNodeName();
        Environment env = Environment.getCurrentEnvironment();
        String defaultNS = env.getDefaultNS();
        String prefix = null;
        if (nsURI.equals(defaultNS)) {
            prefix = "D";
        } else {
            prefix = env.getPrefixForNamespace(nsURI);
        }
        if (prefix == null) {
            return null;
        }
        return prefix + ":" + node.getLocalName();
View Full Code Here

        String nodeName = getNodeName();
        String nsURI = getNodeNamespace();
        if (nsURI == null || nsURI.length() == 0) {
            return nodeName;
        }
        Environment env = Environment.getCurrentEnvironment();
        String defaultNS = env.getDefaultNS();
        String prefix;
        if (defaultNS != null && defaultNS.equals(nsURI)) {
            prefix = Template.DEFAULT_NAMESPACE_PREFIX;
        } else {
            prefix = env.getPrefixForNamespace(nsURI);
           
        }
        if (prefix == null) {
            return null; // We have no qualified name, because there is no prefix mapping
        }
View Full Code Here

        NodeListModel result = new NodeListModel(contextNode);
        int size = size();
        if (size == 0) {
            return result;
        }
        Environment env = Environment.getCurrentEnvironment();
        for (int i = 0; i<size; i++) {
            NodeModel nm = (NodeModel) get(i);
            if (nm instanceof ElementModel) {
                if (((ElementModel) nm).matchesName(name, env)) {
                    result.add(nm);
View Full Code Here

abstract public class LocalizedString implements TemplateScalarModel {
 
 
  public String getAsString() throws TemplateModelException {
    Environment env = Environment.getCurrentEnvironment();
    Locale locale = env.getLocale();
    return getLocalizedString(locale);
  }
View Full Code Here

        if(varName == null) {
            throw new TemplateModelException("'var' or 'local' or 'global' parameter evaluates to null string");
        }

        final StringBuffer buf = new StringBuffer();
        final Environment env = Environment.getCurrentEnvironment();
        final boolean localVar = local;
        final boolean globalVar = global;

        return new Writer() {

            public void write(char cbuf[], int off, int len) {
                buf.append(cbuf, off, len);
            }

            public void flush() throws IOException {
                out.flush();
            }

            public void close() throws IOException {
                SimpleScalar result = new SimpleScalar(buf.toString());
                try {
                    if (localVar) {
                        env.setLocalVariable(varName, result);
                    } else if (globalVar) {
                        env.setGlobalVariable(varName, result);
                    }
                    else {
                        if (nsModel == null) {
                            env.setVariable(varName, result);
                        } else {
                            ((Environment.Namespace) nsModel).put(varName, result);
                        }
                    }
                } catch (java.lang.IllegalStateException ise) { // if somebody uses 'local' outside a macro
View Full Code Here

    public static Object premissiveUnwrap(TemplateModel model) throws TemplateModelException {
        return unwrap(model, true);
    }
   
    private static Object unwrap(TemplateModel model, boolean permissive) throws TemplateModelException {
        Environment env = Environment.getCurrentEnvironment();
        TemplateModel nullModel = null;
        if(env != null) {
            ObjectWrapper wrapper = env.getObjectWrapper();
            if(wrapper != null) {
                nullModel = wrapper.wrap(null);
            }
        }
        return unwrap(model, nullModel, permissive);
View Full Code Here

{
    public Writer getWriter(final Writer out,
                            final Map args)
    {
        final StringBuffer buf = new StringBuffer();
        final Environment env = Environment.getCurrentEnvironment();
        return new Writer() {
            public void write(char cbuf[], int off, int len) {
                buf.append(cbuf, off, len);
            }
View Full Code Here

TOP

Related Classes of freemarker.core.Environment$NumberFormatKey

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.