<commit_before>/*
 * Copyright 2004-2005 The Apache Software Foundation or its licensors,
 *                     as applicable.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.jackrabbit.core.nodetype.xml;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.Vector;

import javax.jcr.NamespaceRegistry;
import javax.jcr.RepositoryException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

import org.apache.jackrabbit.core.Constants;
import org.apache.jackrabbit.core.NamespaceResolver;
import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 * TODO
 */
public class NodeTypeFormatter {

    /** Path of the node type definition template file. */
    private static final String TEMPLATE =
        "org/apache/jackrabbit/core/nodetype/xml/template.xml";

    /** Name of the node type definition root element. */
    private static final String NODETYPES_ELEMENT = "nodeTypes";

    /** Name of the node type definition element. */
    private static final String NODETYPE_ELEMENT = "nodeType";

    /** The transformer used to serialize and deserialise DOM objects. */
    private Transformer transformer;

    /**
     * Creates a node type formatter object.
     *
     * @throws RepositoryException if the formatter initialization fails
     */
    public NodeTypeFormatter() throws RepositoryException {<commit_msg>Cleanups in nodetype XML handling (JCR-54)  - Removed unused import statements  - Added class Javadocs to NodeTypeFormatter<commit_after>/*
 * Copyright 2004-2005 The Apache Software Foundation or its licensors,
 *                     as applicable.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.jackrabbit.core.nodetype.xml;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collection;
import java.util.Iterator;
import java.util.Vector;

import javax.jcr.NamespaceRegistry;
import javax.jcr.RepositoryException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

import org.apache.jackrabbit.core.Constants;
import org.apache.jackrabbit.core.NamespaceResolver;
import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 * Facade class for reading and writing node type definition files.
 * A NodeTypeFormatter instance uses a simple XML transformer instance
 * to convert XML between DOM and stream representations. The task
 * of actually interpreting the XML elements is delegated to the
 * package-local Format classes.
 * <p>
 * This class (and through it the entire .xml subpackage) is used only by the
 * {@link org.apache.jackrabbit.core.nodetype.NodeTypeDefStore NodeTypeDefStore}
 * class. 
 */
public class NodeTypeFormatter {

    /** Path of the node type definition template file. */
    private static final String TEMPLATE =
        "org/apache/jackrabbit/core/nodetype/xml/template.xml";

    /** Name of the node type definition root element. */
    private static final String NODETYPES_ELEMENT = "nodeTypes";

    /** Name of the node type definition element. */
    private static final String NODETYPE_ELEMENT = "nodeType";

    /** The transformer used to serialize and deserialise DOM objects. */
    private Transformer transformer;

    /**
     * Creates a node type formatter object.
     *
     * @throws RepositoryException if the formatter initialization fails
     */
    public NodeTypeFormatter() throws RepositoryException {
{'fraction_non_alphanumeric': 0.08411214953271028, 'fraction_numerical': 0.005995415270675366, 'mean_word_length': 4.147005444646098, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 25}, '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': '3634935', 'n_tokens_mistral': 1555, 'n_tokens_neox': 1482, 'n_words': 510}