Package groovy.lang

Examples of groovy.lang.Writable.writeTo()


   public void merge(Template template, BindingContext context) throws Exception
   {
      context.put("_ctx", context);
      context.setGroovyTemplateService(this);
      Writable writable = template.make(context);
      writable.writeTo(context.getWriter());
   }

   public void include(String name, BindingContext context) throws Exception
   {
      if (context == null)
View Full Code Here


        Bindings bindings = ctx.getBindings(ScriptContext.ENGINE_SCOPE);

        Writable result = template.make(bindings);

        try {
            result.writeTo(ctx.getWriter());
        } catch (IOException e) {
            throw new ScriptException("Unable to write result of script execution: " + e.getMessage());
        }

        return null;
View Full Code Here

        else {
            w = EncodingGroovyMethods.encodeBase64((Byte[])object);
        }

        try {
            w.writeTo(xml.getStream());
        }
        catch (IOException e) {
            throw new ConverterException(e);
        }
    }
View Full Code Here

        // don't ask me how it works, refer to John Wilson ;-)
        Writable w = (Writable)new GroovyShell(b).evaluate(
                "new groovy.xml.StreamingMarkupBuilder().bind {" +
                " mkp.declareNamespace(\"\":  \"http://java.sun.com/xml/ns/j2ee\");" +
                " mkp.yield node}");
        w.writeTo(output);
    }


}
View Full Code Here

    }
    try {
      final Template templateObject = templateEngine.createTemplate(template);
      final Writable writable = templateObject.make(variables);
      final StringWriter writer = new StringWriter();
      writable.writeTo(writer);
      writer.flush();
      if (log.isDebugEnabled() == true) {
        log.debug(writer.toString());
      }
      return writer.toString();
View Full Code Here

    @Override
    public void renderDocument(final Map<String, Object> model, final String templateName, final Writer writer) throws RenderingException {
        try {
            Template template = findTemplate(templateName);
            Writable writable = template.make(wrap(model));
            writable.writeTo(writer);
        } catch (Exception e) {
            throw new RenderingException(e);
        }
    }
View Full Code Here

  public static String template(TemplateEngine engine, String name, Map<String, ?> model)
      throws IOException, CompilationFailedException, ClassNotFoundException {
    Writable writable = getTemplate(engine, name).make(model);
    StringWriter result = new StringWriter();
    writable.writeTo(result);
    return result.toString();
  }

  private static Template getTemplate(TemplateEngine engine, String name)
      throws CompilationFailedException, ClassNotFoundException, IOException {
View Full Code Here

    @Deprecated
    public void merge(Template template, BindingContext context) throws Exception {
        context.put("_ctx", context);
        context.setGroovyTemplateService(this);
        Writable writable = template.make(context);
        writable.writeTo(context.getWriter());
    }

    public void include(String name, BindingContext context) throws Exception {
        if (context == null)
            throw new Exception("Binding cannot be null");
View Full Code Here

   public void merge(Template template, BindingContext context) throws Exception
   {
      context.put("_ctx", context);
      context.setGroovyTemplateService(this);
      Writable writable = template.make(context);
      writable.writeTo(context.getWriter());
   }

   public void include(String name, BindingContext context) throws Exception
   {
      if (context == null)
View Full Code Here

    @Deprecated
    public void merge(Template template, BindingContext context) throws Exception {
        context.put("_ctx", context);
        context.setGroovyTemplateService(this);
        Writable writable = template.make(context);
        writable.writeTo(context.getWriter());
    }

    public void include(String name, BindingContext context) throws Exception {
        if (context == null)
            throw new Exception("Binding cannot be null");
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.