<commit_before>package org.typemeta.funcj.codec.xml;

import org.typemeta.funcj.codec.CodecCoreInternal;
import org.typemeta.funcj.codec.xml.io.XmlIO;
import org.typemeta.funcj.codec.xml.io.XmlIO.*;

import java.io.*;

/**
 * Interface for classes which implement an encoding via XML.
 */
public interface XmlCodecCore extends CodecCoreInternal<Input, Output> {
    /**
     * Encode the supplied value into XML and write the results to the {@link Writer} object.
     * The static type determines whether type information is written to recover the value's
     * dynamic type.
     * @param type      the static type of the value
     * @param value     the value to be encoded
     * @param writer    the output stream to which the XML is written
     * @param rootElemName the name of the root element under which the output data is written
     * @param <T>       the static type of the value
     * @return          the output stream
     */
    default <T> Output encode(Class<? super T> type, T value, Writer writer, String rootElemName) {
        final Output out = encode(type, value, XmlIO.outputOf(writer, rootElemName));
        return out.close();
    }

    /**
     * Encode the supplied value into XML and write the results to the {@link Writer} object.
     * @param value     the value to be encoded
     * @param writer    the output stream to which the XML is written
     * @param rootElemName the name of the root element under which the output data is written
     * @param <T>       the static type of the value
     */
    default <T> Output encode(T value, Writer writer, String rootElemName) {
        return encode(Object.class, value, writer, rootElemName);
    }

    /**
     * Decode a value by reading JSON from the supplied {@link Reader} object.
     * @param type      the static type of the value to be decoded.
     * @param reader    the input stream from which JSON is read
     * @param rootElemName the name of the root element under which the output data is written
     * @param <T>       the static type of the value
     * @return          the decoded value
     */
    default <T> T decode(Class<? super T> type, Reader reader, String rootElemName) {
        return decode(type, XmlIO.inputOf(reader, rootElemName));
    }

    /**
     * Decode a value by reading JSON from the supplied {@link Reader} object.
     * @param reader    the input stream from which JSON is read
     * @param rootElemName the name of the root element under which the output data is written
     * @param <T>       the static type of the value
     * @return          the decoded value
     */
    default <T> T decode(Reader reader, String rootElemName) {
        return decode(Object.class, reader, rootElemName);
    }
}<commit_msg>javadocs<commit_after>package org.typemeta.funcj.codec.xml;

import org.typemeta.funcj.codec.CodecCoreInternal;
import org.typemeta.funcj.codec.xml.io.XmlIO;
import org.typemeta.funcj.codec.xml.io.XmlIO.*;

import java.io.*;

/**
 * Interface for classes which implement an encoding via XML.
 */
public interface XmlCodecCore extends CodecCoreInternal<Input, Output> {
    /**
     * Encode the supplied value into XML and write the results to the {@link Writer} object.
     * The static type determines whether type information is written to recover the value's
     * dynamic type.
     * @param type      the static type of the value
     * @param value     the value to be encoded
     * @param writer    the output stream to which the XML is written
     * @param rootElemName the name of the root element under which the output data is written
     * @param <T>       the static type of the value
     * @return          the output stream
     */
    default <T> Output encode(Class<? super T> type, T value, Writer writer, String rootElemName) {
        final Output out = encode(type, value, XmlIO.outputOf(writer, rootElemName));
        return out.close();
    }

    /**
     * Encode the supplied value into XML and write the results to the {@link Writer} object.
     * @param value     the value to be encoded
     * @param writer    the output stream to which the XML is written
     * @param rootElemName the name of the root element under which the output data is written
     * @param <T>       the static type of the value
     * @return          the output stream
     */
    default <T> Output encode(T value, Writer writer, String rootElemName) {
        return encode(Object.class, value, writer, rootElemName);
    }

    /**
     * Decode a value by reading JSON from the supplied {@link Reader} object.
     * @param type      the static type of the value to be decoded.
     * @param reader    the input stream from which JSON is read
     * @param rootElemName the name of the root element under which the output data is written
     * @param <T>       the static type of the value
     * @return          the decoded value
     */
    default <T> T decode(Class<? super T> type, Reader reader, String rootElemName) {
        return decode(type, XmlIO.inputOf(reader, rootElemName));
    }

    /**
     * Decode a value by reading JSON from the supplied {@link Reader} object.
     * @param reader    the input stream from which JSON is read
     * @param rootElemName the name of the root element under which the output data is written
     * @param <T>       the static type of the value
     * @return          the decoded value
     */
    default <T> T decode(Reader reader, String rootElemName) {
        return decode(Object.class, reader, rootElemName);
    }
}
{'fraction_non_alphanumeric': 0.07552598453515555, 'fraction_numerical': 0.0, 'mean_word_length': 2.6688654353562007, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '4153959', 'n_tokens_mistral': 1491, 'n_tokens_neox': 1464, 'n_words': 674}