@@ -0,0 +1,2566 @@
+package com.wizzardo.http.template;%0A%0A%0Aimport java.io.IOException;%0Aimport java.io.OutputStream;%0Aimport java.nio.charset.Charset;%0Aimport java.nio.charset.StandardCharsets;%0Aimport java.util.ArrayList;%0A%0A/**%0A * @author: moxa%0A * Date: 11/24/12%0A */%0Apublic class RenderResult %7B%0A    protected byte%5B%5D bytes;%0A    protected ArrayList%3CRenderResult%3E renders;%0A%0A    public RenderResult() %7B%0A    %7D%0A%0A    public RenderResult(byte%5B%5D bytes) %7B%0A        this.bytes = bytes;%0A    %7D%0A%0A    public RenderResult(String s, Charset charset) %7B%0A        bytes = s.getBytes(charset);%0A    %7D%0A%0A    public RenderResult(String s) %7B%0A        this(s, Charset.defaultCharset());%0A    %7D%0A%0A    public void add(RenderResult r) %7B%0A        if (renders == null)%0A            renders = new ArrayList%3C%3E();%0A%0A        if (bytes != null) %7B%0A            renders.add(new RenderResult(bytes));%0A            bytes = null;%0A        %7D%0A%0A        renders.add(r);%0A    %7D%0A%0A    public RenderResult append(RenderResult r) %7B%0A        add(r);%0A        return this;%0A    %7D%0A%0A    public RenderResult append(String r) %7B%0A        add(new RenderResult(r));%0A        return this;%0A    %7D%0A%0A    public RenderResult append(byte%5B%5D r) %7B%0A        add(new RenderResult(r));%0A        return this;%0A    %7D%0A%0A    public byte%5B%5D bytes() %7B%0A        if (bytes == null)%0A            compact();%0A%0A        return bytes;%0A    %7D%0A%0A    public int size() %7B%0A        if (bytes != null) %7B%0A            return bytes.length;%0A        %7D%0A        int size = 0;%0A        for (RenderResult r : renders) %7B%0A            size += r.size();%0A        %7D%0A        return size;%0A    %7D%0A%0A    public void write(OutputStream out) throws IOException %7B%0A        if (bytes != null) %7B%0A            out.write(bytes);%0A        %7D else %7B%0A            for (RenderResult r : renders) %7B%0A                r.write(out);%0A            %7D%0A        %7D%0A    %7D%0A%0A    public RenderResult compact() %7B%0A        if (bytes != null)%0A            return this;%0A%0A        bytes = new byte%5Bsize()%5D;%0A        int offset = 0;%0A        for (RenderResult r : renders) %7B%0A            System.arraycopy(r.bytes(), 0, bytes, offset, r.size());%0A            offset += r.size();%0A        %7D%0A        renders = null;%0A        return this;%0A    %7D%0A%0A    public String toString() %7B%0A        return toString(StandardCharsets.UTF_8);%0A    %7D%0A%0A    public String toString(Charset charset) %7B%0A        StringBuilder sb = new StringBuilder(size());%0A        if (bytes != null) %7B%0A            sb.append(new String(bytes, charset));%0A        %7D else %7B%0A            for (RenderResult r : renders) %7B%0A                sb.append(r.toString(charset));%0A            %7D%0A        %7D%0A        return sb.toString();%0A    %7D%0A%7D%0A

add RenderResult