<commit_before>package org.ofbiz.webapp.renderer;

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

/**
 * SCIPIO: Special writers, mainly for targeted rendering.
 * <p>
 * WARN: these are NOT thread-safe, but they don't need to be in ofbiz rendering.
 */
public abstract class RenderWriter extends Writer {
    protected Writer origWriter;
    
    protected RenderWriter() {
        super();
        this.origWriter = null;
    }
    
    protected RenderWriter(Writer origWriter) {
        super();
        this.origWriter = origWriter;
    }

    public Writer getOrigWriter() {
        return origWriter;
    }

    public void setOrigWriter(Writer origWriter) {
        this.origWriter = origWriter;
    }

    /**
     * Delegates to another writer, while keeping a reference to an original writer.
     * For reuse.
     */
    public static abstract class DelegRenderWriter extends RenderWriter {
        protected Writer targetWriter; // effective writer, must be initialized by sub-class

        protected DelegRenderWriter(Writer origWriter) {
            super(origWriter);
        }

        @Override
        public void write(int c) throws IOException {
            targetWriter.write(c);
        }

        @Override
        public void write(char[] cbuf) throws IOException {
            targetWriter.write(cbuf);<commit_msg>Refs #1484/OFBIZ patch: renderer: targeted rendering: commit new RenderWriter classes, to try new solution to solve FTL boundary problems (WIP)<commit_after>package org.ofbiz.webapp.renderer;

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

/**
 * SCIPIO: Special writers, mainly for targeted rendering.
 * <p>
 * WARN: these are NOT thread-safe, but they don't need to be in ofbiz rendering.
 */
public abstract class RenderWriter extends Writer {
    protected Writer origWriter;
    
    protected RenderWriter() {
        super();
        this.origWriter = null;
    }
    
    protected RenderWriter(Writer origWriter) {
        super();
        this.origWriter = origWriter;
    }

    public Writer getOrigWriter() {
        return origWriter;
    }

    public void setOrigWriter(Writer origWriter) {
        this.origWriter = origWriter;
    }

    /**
     * Delegates to another writer, while keeping a reference to an original writer.
     * For reuse.
     */
    public static class DelegRenderWriter extends RenderWriter {
        protected Writer targetWriter; // effective writer, must be initialized by sub-class

        protected DelegRenderWriter(Writer origWriter) {
            super(origWriter);
        }
        
        protected DelegRenderWriter(Writer origWriter, Writer targetWriter) {
            super(origWriter);
            this.targetWriter = targetWriter;
        }
        
        public static DelegRenderWriter getInstance(Writer targetWriter, Writer origWriter) {
            return new DelegRenderWriter(origWriter, 
                    targetWriter != null ? targetWriter : origWriter);
        }
        
        public static DelegRenderWriter getInstance(Writer targetWriter) {
            return new DelegRenderWriter(null, targetWriter);
        }

        @Override
        public void write(int c) throws IOException {
            targetWriter.write(c);
        }

        @Override
        public void write(char[] cbuf) throws IOException {
            targetWriter.write(cbuf);
{'fraction_non_alphanumeric': 0.0750812887969258, 'fraction_numerical': 0.0011823825007389892, 'mean_word_length': 2.4320486815415823, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3019417', 'n_tokens_mistral': 870, 'n_tokens_neox': 853, 'n_words': 268}