<commit_before>package org.citygml4j.xml.writer;

import org.citygml4j.model.CityGMLVersion;
import org.citygml4j.xml.module.Module;
import org.citygml4j.xml.module.ade.ADEModule;
import org.citygml4j.xml.module.citygml.CityGMLModule;
import org.citygml4j.xml.module.citygml.CityGMLModules;
import org.citygml4j.xml.module.citygml.CoreModule;
import org.citygml4j.xml.transform.TransformerPipeline;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.stream.XMLWriterFactory;
import org.xmlobjects.xml.Namespaces;

public abstract class AbstractCityGMLWriter<T extends AbstractCityGMLWriter<?>> implements AutoCloseable {
    final XMLWriter writer;
    final CityGMLVersion version;
    final XMLWriterFactory factory;
    final Namespaces namespaces;

    TransformerPipeline transformer;

    AbstractCityGMLWriter(XMLWriter writer, CityGMLVersion version, XMLWriterFactory factory) {
        this.writer = writer;
        this.version = version;
        this.factory = factory;
        
        namespaces = Namespaces.newInstance();
        for (Module module : CityGMLModules.of(version).getModules())
            namespaces.add(module.getNamespaceURI());
    }

    public String getPrefix(String namespaceURI) {
        return writer.getPrefix(namespaceURI);
    }

    @SuppressWarnings("unchecked")
    public T withPrefix(String prefix, String namespaceURI) {
        writer.withPrefix(prefix,namespaceURI);
        return (T) this;
    }

    @SuppressWarnings("unchecked")
    public T withDefaultPrefixes() {
        for (Module module : CityGMLModules.of(version).getModules())
            withPrefix(module.getNamespacePrefix(), module.getNamespaceURI());

        return (T) this;
    }

    public String getNamespaceURI(String prefix) {
        return writer.getNamespaceURI(prefix);
    }

    @SuppressWarnings("unchecked")
    public T withDefaultNamespace(String namespaceURI) {
        writer.withDefaultNamespace(namespaceURI);
        return (T) this;
    }<commit_msg>support writing of GML 3.3 elements provided by gml-objects<commit_after>package org.citygml4j.xml.writer;

import org.citygml4j.model.CityGMLVersion;
import org.citygml4j.xml.module.Module;
import org.citygml4j.xml.module.ade.ADEModule;
import org.citygml4j.xml.module.citygml.CityGMLModule;
import org.citygml4j.xml.module.citygml.CityGMLModules;
import org.citygml4j.xml.module.citygml.CoreModule;
import org.citygml4j.xml.module.gml.GMLCompactEncodingModule;
import org.citygml4j.xml.module.gml.GMLExtendedBaseTypesModule;
import org.citygml4j.xml.transform.TransformerPipeline;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.stream.XMLWriterFactory;
import org.xmlobjects.xml.Namespaces;

public abstract class AbstractCityGMLWriter<T extends AbstractCityGMLWriter<?>> implements AutoCloseable {
    final XMLWriter writer;
    final CityGMLVersion version;
    final XMLWriterFactory factory;
    final Namespaces namespaces;

    TransformerPipeline transformer;

    AbstractCityGMLWriter(XMLWriter writer, CityGMLVersion version, XMLWriterFactory factory) {
        this.writer = writer;
        this.version = version;
        this.factory = factory;

        namespaces = Namespaces.newInstance();
        for (Module module : CityGMLModules.of(version).getModules())
            namespaces.add(module.getNamespaceURI());

        if (version == CityGMLVersion.v3_0) {
            namespaces.add(GMLCompactEncodingModule.v3_3.getNamespaceURI())
                    .add(GMLExtendedBaseTypesModule.v3_3.getNamespaceURI());
        }
    }

    public String getPrefix(String namespaceURI) {
        return writer.getPrefix(namespaceURI);
    }

    @SuppressWarnings("unchecked")
    public T withPrefix(String prefix, String namespaceURI) {
        writer.withPrefix(prefix,namespaceURI);
        return (T) this;
    }

    @SuppressWarnings("unchecked")
    public T withDefaultPrefixes() {
        for (Module module : CityGMLModules.of(version).getModules())
            withPrefix(module.getNamespacePrefix(), module.getNamespaceURI());

        return (T) this;
    }

    public String getNamespaceURI(String prefix) {
        return writer.getNamespaceURI(prefix);
    }

    @SuppressWarnings("unchecked")
    public T withDefaultNamespace(String namespaceURI) {
        writer.withDefaultNamespace(namespaceURI);
        return (T) this;
    }
{'fraction_non_alphanumeric': 0.09241071428571429, 'fraction_numerical': 0.005803571428571429, 'mean_word_length': 3.8972677595628413, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 26}, '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': '7391660', 'n_tokens_mistral': 1307, 'n_tokens_neox': 1307, 'n_words': 237}