Package freemarker.template

Examples of freemarker.template.SimpleHash$SynchronizedHash


    List<Object> args = new ArrayList<Object>();   
    CollectionModel cm = new CollectionModel(tags,new BeansWrapper());
    args.add(cm);
   
    ComputeTagCloudMethod method = new ComputeTagCloudMethod();
    SimpleHash map = (SimpleHash)method.exec(args);
    assertEquals(6,map.size());
  }
View Full Code Here


  @SuppressWarnings("unchecked")
  public Object exec(List args) throws TemplateModelException {
    if(args.size() < 1 || args.size() > 3){
      throw new TemplateModelException("Wrong number of arguments");
    }
    SimpleHash tagCloudHash = new SimpleHash(new HashMap<String,Integer>())
   
    List<TagLabel> tags = getTagLabelFromArg1(args.get(0));
    int numOfFontSize = 6;
    if(args.size() > 1){
      numOfFontSize = getNumOfFontSize(args.get(1));
    }
    /*
    if(args.size() > 2){
      String[] filter = getFilterPattern(args.get(2));
    }
    */
   
    int[] maxMin = getMaxMin(tags);
    int max = maxMin[0];
    int min = maxMin[1];
    double[] threshold = compThreshold(max, min, numOfFontSize);
    for(TagLabel aTag : tags){
      boolean fontSetFlag = false;
      for (int i = 0; i < numOfFontSize; i++) {
        if (fontSetFlag == false) {           
          if (aTag.getCount() <= threshold[i]) {
            tagCloudHash.put(aTag.getLabel(),i+1);
            fontSetFlag = true;
          }
        } else {
          break;
        }
View Full Code Here

  private static final String UI_ENV_CACHE = ".ui.envs";
  private static final String TEMPLATE_MODEL = ".beangle.TemplateModel";

  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

   */
  private SimpleHash buildModel(ValueStack stack, Component component) {
    Map<?, ?> context = stack.getContext();
    HttpServletRequest req = (HttpServletRequest) context.get(ServletActionContext.HTTP_REQUEST);
    // build hash
    SimpleHash model = (SimpleHash) req.getAttribute(TEMPLATE_MODEL);
    if (null == model) {
      model = freemarkerManager.buildTemplateModel(stack, null,
          (ServletContext) context.get(ServletActionContext.SERVLET_CONTEXT), req,
          (HttpServletResponse) context.get(ServletActionContext.HTTP_RESPONSE),
          config.getObjectWrapper());
View Full Code Here

    throws
    Exception
    {
        org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder();
        Document document = builder.build(System.in);
        SimpleHash model = new SimpleHash();
        model.put("document", new NodeListModel(document));
        FileReader fr = new FileReader(args[0]);
        Template template = new Template(args[0], fr);
        Writer w = new java.io.OutputStreamWriter(System.out);
        template.process(model, w);
        w.flush();
View Full Code Here

        Template template = config.getTemplate("PerformanceTest.fm");
        boolean toFile = args.length > 0 && args[0].equals("file");
        File f = File.createTempFile("fmPerfTest", ".txt");
        f.deleteOnExit();
        OutputStream nullStream = new NullStream();
        SimpleHash h = new SimpleHash();
        h.put("ii", new TestSequence());
        h.put("j", new TestHash());
        h.put("k", new TestMethod());
       
        for(;;)
        {
            OutputStream stream = toFile ? new BufferedOutputStream(new FileOutputStream(f)) : nullStream;
            Writer writer = new OutputStreamWriter(stream, "UTF-8");
View Full Code Here

  }
 
    public void init(File outputDirectory, String[] templatePaths) {
        this.outputDirectory = outputDirectory;
       
        context = new SimpleHash(ObjectWrapper.BEANS_WRAPPER);
      freeMarkerEngine = new Configuration();
       
        List loaders = new ArrayList();
       
        for (int i = 0; i < templatePaths.length; i++) {
View Full Code Here

        }

        ActionInvocation ai = ActionContext.getContext().getActionInvocation();

        Object action = (ai == null) ? null : ai.getAction();
        SimpleHash model = freemarkerManager.buildTemplateModel(stack, action, servletContext, req, res, config.getObjectWrapper());

        model.put("tag", templateContext.getTag());
        model.put("themeProperties", getThemeProps(templateContext.getTemplate()));

        // the BodyContent JSP writer doesn't like it when FM flushes automatically --
        // so let's just not do it (it will be flushed eventually anyway)
        Writer writer = templateContext.getWriter();
        final Writer wrapped = writer;
View Full Code Here

    protected SimpleHash getContext(RunData data)
    {
        // Attempt to get it from the TemplateInfo first.  If it
        // doesn't exist, create it and then stuff it into the
        // TemplateInfo.
        SimpleHash context = (SimpleHash)data.getTemplateInfo()
            .getTemplateContext(FreeMarkerService.CONTEXT);
        if (context == null)
        {
            FreeMarkerService fm = (FreeMarkerService)TurbineServices
                .getInstance().getService(FreeMarkerService.SERVICE_NAME);
View Full Code Here

     * @exception Exception, a generic exception.
     */
    public ConcreteElement buildTemplate(RunData data)
        throws Exception
    {
        SimpleHash context = getContext(data);
        String templateName = data.getTemplateInfo().getNavigationTemplate();
        FreeMarkerService fm = (FreeMarkerService)
            TurbineServices.getInstance()
                .getService(FreeMarkerService.SERVICE_NAME);

View Full Code Here

TOP

Related Classes of freemarker.template.SimpleHash$SynchronizedHash

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.