Search in sources :

Example 1 with ByteWriter_Char

use of org.beetl.core.io.ByteWriter_Char in project beetl2.0 by javamonkey.

the class Template method renderTo.

/**
 * 获取模板输出的文本,输出到Writer里
 *
 * @param writer
 * @throws BeetlException
 */
public void renderTo(Writer writer) throws BeetlException {
    ByteWriter_Char byteWriter = new ByteWriter_Char(writer, cf.charset, ctx);
    this.renderTo(byteWriter);
}
Also used : ByteWriter_Char(org.beetl.core.io.ByteWriter_Char)

Example 2 with ByteWriter_Char

use of org.beetl.core.io.ByteWriter_Char in project beetl2.0 by javamonkey.

the class BeetlUtil method getWriterByByteWriter.

public static Writer getWriterByByteWriter(ByteWriter byteWriter) {
    ByteWriter temp = null;
    while ((temp = byteWriter.getParent()) != null) {
        byteWriter = temp;
    }
    Writer w = null;
    if (byteWriter instanceof ByteWriter_Char) {
        ByteWriter_Char bw = (ByteWriter_Char) byteWriter;
        w = bw.getW();
    } else {
        ByteWriter_Byte bw = (ByteWriter_Byte) byteWriter;
        try {
            w = new OutputStreamWriter(bw.getOs(), bw.getCs());
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
    return w;
}
Also used : ByteWriter_Char(org.beetl.core.io.ByteWriter_Char) ByteWriter_Byte(org.beetl.core.io.ByteWriter_Byte) ByteWriter(org.beetl.core.ByteWriter) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) ByteWriter(org.beetl.core.ByteWriter) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Aggregations

ByteWriter_Char (org.beetl.core.io.ByteWriter_Char)2 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 URISyntaxException (java.net.URISyntaxException)1 ByteWriter (org.beetl.core.ByteWriter)1 ByteWriter_Byte (org.beetl.core.io.ByteWriter_Byte)1