GuideDecoratedWriter.java 1.17 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.aemds.guide.utils;

import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;

class GuideDecoratedWriter
extends Writer {
    private final Writer delegatedJspWriter;
    private boolean writeToJsp;
    private final StringWriter writerForCache = new StringWriter();

    public Writer getdelegatedJspWriter() {
        return this.delegatedJspWriter;
    }

    public GuideDecoratedWriter(Writer delegatedJspWriter, boolean writeToJsp) {
        this.delegatedJspWriter = delegatedJspWriter;
        this.writeToJsp = writeToJsp;
    }

    public String getHTMLToCache() {
        return this.writerForCache.toString();
    }

    public void write(char[] cbuf, int off, int len) throws IOException {
        if (this.writeToJsp) {
            this.delegatedJspWriter.write(cbuf, off, len);
        }
        this.writerForCache.write(cbuf, off, len);
    }

    public void flush() throws IOException {
        this.delegatedJspWriter.flush();
        this.writerForCache.flush();
    }

    public void close() throws IOException {
        this.delegatedJspWriter.close();
        this.writerForCache.close();
    }
}