<commit_before>/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.camel.model.dataformat;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlList;
import javax.xml.bind.annotation.XmlRootElement;

import org.apache.camel.CamelContext;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.DataFormat;

/**
 * Represents a <a href="http://camel.apache.org/xmljson.html">XML-JSON</a> {@link org.apache.camel.spi.DataFormat}.
 *
 * @version 
 */
@XmlRootElement(name = "xmljson")
@XmlAccessorType(XmlAccessType.FIELD)
public class XmlJsonDataFormat extends DataFormatDefinition {
    
    public static final String TYPE_HINTS = "typeHints";
    public static final String REMOVE_NAMESPACE_PREFIXES = "removeNamespacePrefixes";
    public static final String SKIP_NAMESPACES = "skipNamespaces";
    public static final String TRIM_SPACES = "trimSpaces";
    public static final String SKIP_WHITESPACE = "skipWhitespace";
    public static final String EXPANDABLE_PROPERTIES = "expandableProperties";
    public static final String ARRAY_NAME = "arrayName";
    public static final String ELEMENT_NAME = "elementName";
    public static final String ROOT_NAME = "rootName";
    public static final String NAMESPACE_LENIENT = "namespaceLenient";
    public static final String FORCE_TOP_LEVEL_OBJECT = "forceTopLevelObject";
    public static final String ENCODING = "encoding";
    
    @XmlAttribute
    private String encoding;
    @XmlAttribute
    private String elementName;
    @XmlAttribute
    private String arrayName;
    @XmlAttribute
    private Boolean forceTopLevelObject;
    @XmlAttribute
    private Boolean namespaceLenient;
    @XmlAttribute
    private String rootName;
    @XmlAttribute
    private Boolean skipWhitespace;
    @XmlAttribute
    private Boolean trimSpaces;
    @XmlAttribute
    private Boolean skipNamespaces;
    @XmlAttribute
    private Boolean removeNamespacePrefixes;
    @XmlAttribute @XmlList
    private List<String> expandableProperties;
    @XmlAttribute
    private String typeHints;

    public XmlJsonDataFormat() {
        super("xmljson");
    }

    public XmlJsonDataFormat(Map<String, String> options) {
        super("xmljson");
        if (options.containsKey(ENCODING)) {
            encoding = options.get(ENCODING);
        }
        if (options.containsKey(FORCE_TOP_LEVEL_OBJECT)) {
            forceTopLevelObject = Boolean.parseBoolean(options.get(FORCE_TOP_LEVEL_OBJECT));
        }
        if (options.containsKey(NAMESPACE_LENIENT)) {
            namespaceLenient = Boolean.parseBoolean(options.get(NAMESPACE_LENIENT));
        }
        if (options.containsKey(ROOT_NAME)) {
            rootName = options.get(ROOT_NAME);
        }
        if (options.containsKey(ELEMENT_NAME)) {
            encoding = options.get(ELEMENT_NAME);
        }
        if (options.containsKey(ARRAY_NAME)) {
            elementName = options.get(ARRAY_NAME);
        }
        if (options.containsKey(EXPANDABLE_PROPERTIES)) {
            expandableProperties = Arrays.asList(options.get(EXPANDABLE_PROPERTIES).split(" "));
        }
        if (options.containsKey(SKIP_WHITESPACE)) {
            skipWhitespace = Boolean.parseBoolean(options.get(SKIP_WHITESPACE));
        }
        if (options.containsKey(TRIM_SPACES)) {
            trimSpaces = Boolean.parseBoolean(options.get(TRIM_SPACES));
        }
        if (options.containsKey(SKIP_NAMESPACES)) {
            skipNamespaces = Boolean.parseBoolean(options.get(SKIP_NAMESPACES));
        }
        if (options.containsKey(REMOVE_NAMESPACE_PREFIXES)) {
            removeNamespacePrefixes = Boolean.parseBoolean(options.get(REMOVE_NAMESPACE_PREFIXES));
        }
        if (options.containsKey(TYPE_HINTS)) {
            typeHints = options.get(TYPE_HINTS);<commit_msg>CAMEL-7258 Fix camel-xmljson elementName and arrayName settings when using the xmljson() DSL. This closes #105.<commit_after>/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.camel.model.dataformat;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlList;
import javax.xml.bind.annotation.XmlRootElement;

import org.apache.camel.CamelContext;
import org.apache.camel.model.DataFormatDefinition;
import org.apache.camel.spi.DataFormat;

/**
 * Represents a <a href="http://camel.apache.org/xmljson.html">XML-JSON</a> {@link org.apache.camel.spi.DataFormat}.
 *
 * @version 
 */
@XmlRootElement(name = "xmljson")
@XmlAccessorType(XmlAccessType.FIELD)
public class XmlJsonDataFormat extends DataFormatDefinition {
    
    public static final String TYPE_HINTS = "typeHints";
    public static final String REMOVE_NAMESPACE_PREFIXES = "removeNamespacePrefixes";
    public static final String SKIP_NAMESPACES = "skipNamespaces";
    public static final String TRIM_SPACES = "trimSpaces";
    public static final String SKIP_WHITESPACE = "skipWhitespace";
    public static final String EXPANDABLE_PROPERTIES = "expandableProperties";
    public static final String ARRAY_NAME = "arrayName";
    public static final String ELEMENT_NAME = "elementName";
    public static final String ROOT_NAME = "rootName";
    public static final String NAMESPACE_LENIENT = "namespaceLenient";
    public static final String FORCE_TOP_LEVEL_OBJECT = "forceTopLevelObject";
    public static final String ENCODING = "encoding";
    
    @XmlAttribute
    private String encoding;
    @XmlAttribute
    private String elementName;
    @XmlAttribute
    private String arrayName;
    @XmlAttribute
    private Boolean forceTopLevelObject;
    @XmlAttribute
    private Boolean namespaceLenient;
    @XmlAttribute
    private String rootName;
    @XmlAttribute
    private Boolean skipWhitespace;
    @XmlAttribute
    private Boolean trimSpaces;
    @XmlAttribute
    private Boolean skipNamespaces;
    @XmlAttribute
    private Boolean removeNamespacePrefixes;
    @XmlAttribute @XmlList
    private List<String> expandableProperties;
    @XmlAttribute
    private String typeHints;

    public XmlJsonDataFormat() {
        super("xmljson");
    }

    public XmlJsonDataFormat(Map<String, String> options) {
        super("xmljson");
        if (options.containsKey(ENCODING)) {
            encoding = options.get(ENCODING);
        }
        if (options.containsKey(FORCE_TOP_LEVEL_OBJECT)) {
            forceTopLevelObject = Boolean.parseBoolean(options.get(FORCE_TOP_LEVEL_OBJECT));
        }
        if (options.containsKey(NAMESPACE_LENIENT)) {
            namespaceLenient = Boolean.parseBoolean(options.get(NAMESPACE_LENIENT));
        }
        if (options.containsKey(ROOT_NAME)) {
            rootName = options.get(ROOT_NAME);
        }
        if (options.containsKey(ELEMENT_NAME)) {
            elementName = options.get(ELEMENT_NAME);
        }
        if (options.containsKey(ARRAY_NAME)) {
            arrayName = options.get(ARRAY_NAME);
        }
        if (options.containsKey(EXPANDABLE_PROPERTIES)) {
            expandableProperties = Arrays.asList(options.get(EXPANDABLE_PROPERTIES).split(" "));
        }
        if (options.containsKey(SKIP_WHITESPACE)) {
            skipWhitespace = Boolean.parseBoolean(options.get(SKIP_WHITESPACE));
        }
        if (options.containsKey(TRIM_SPACES)) {
            trimSpaces = Boolean.parseBoolean(options.get(TRIM_SPACES));
        }
        if (options.containsKey(SKIP_NAMESPACES)) {
            skipNamespaces = Boolean.parseBoolean(options.get(SKIP_NAMESPACES));
        }
        if (options.containsKey(REMOVE_NAMESPACE_PREFIXES)) {
            removeNamespacePrefixes = Boolean.parseBoolean(options.get(REMOVE_NAMESPACE_PREFIXES));
        }
        if (options.containsKey(TYPE_HINTS)) {
            typeHints = options.get(TYPE_HINTS);
{'fraction_non_alphanumeric': 0.08591563892631361, 'fraction_numerical': 0.0015545652399212354, 'mean_word_length': 3.558337269721304, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 20}, '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': '5455078', 'n_tokens_mistral': 2691, 'n_tokens_neox': 2668, 'n_words': 671}