<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.commons.configuration.tree.xpath;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.commons.configuration.tree.ConfigurationNode;
import org.apache.commons.jxpath.ri.QName;
import org.apache.commons.jxpath.ri.model.NodePointer;

/**
 * A specialized node iterator implementation that deals with attribute nodes.
 *
 * @author <NAME>
 * @version $Id$
 */
class ConfigurationNodeIteratorAttribute extends
        ConfigurationNodeIteratorBase
{
    /** Constant for the wildcard node name.*/
    private static final String WILDCARD = "*";

    /**
     * Creates a new instance of <code>ConfigurationNodeIteratorAttribute</code>.
     * @param parent the parent node pointer
     * @param name the name of the selected attribute
     */
    public ConfigurationNodeIteratorAttribute(NodePointer parent, QName name)
    {
        super(parent, false);
        initSubNodeList(createSubNodeList((ConfigurationNode) parent.getNode(),
                name));
    }

    /**
     * Determines which attributes are selected based on the passed in node
     * name.
     * @param node the current node
     * @param name the name of the selected attribute
     * @return a list with the selected attributes
     */
    protected List createSubNodeList(ConfigurationNode node, QName name)
    {
        if (name.getPrefix() != null)
        {
            // namespace prefixes are not supported
            return Collections.EMPTY_LIST;
        }

        List result = new ArrayList();
        if (!WILDCARD.equals(name.getName()))
        {
            result.addAll(node.getAttributes(name.getName()));
        }
        else
        {
            result.addAll(node.getAttributes());
        }

        return result;
    }
}<commit_msg>Java 1.5 compatibility: Javadocs, raw types.<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.commons.configuration.tree.xpath;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.commons.configuration.tree.ConfigurationNode;
import org.apache.commons.jxpath.ri.QName;
import org.apache.commons.jxpath.ri.model.NodePointer;

/**
 * A specialized node iterator implementation that deals with attribute nodes.
 *
 * @author <a
 * href="http://commons.apache.org/configuration/team-list.html">Commons
 * Configuration team</a>
 * @version $Id$
 */
class ConfigurationNodeIteratorAttribute extends
        ConfigurationNodeIteratorBase
{
    /** Constant for the wildcard node name.*/
    private static final String WILDCARD = "*";

    /**
     * Creates a new instance of {@code ConfigurationNodeIteratorAttribute}.
     * @param parent the parent node pointer
     * @param name the name of the selected attribute
     */
    public ConfigurationNodeIteratorAttribute(NodePointer parent, QName name)
    {
        super(parent, false);
        initSubNodeList(createSubNodeList((ConfigurationNode) parent.getNode(),
                name));
    }

    /**
     * Determines which attributes are selected based on the passed in node
     * name.
     * @param node the current node
     * @param name the name of the selected attribute
     * @return a list with the selected attributes
     */
    protected List<ConfigurationNode> createSubNodeList(ConfigurationNode node, QName name)
    {
        if (name.getPrefix() != null)
        {
            // namespace prefixes are not supported
            return Collections.emptyList();
        }

        List<ConfigurationNode> result = new ArrayList<ConfigurationNode>();
        if (!WILDCARD.equals(name.getName()))
        {
            result.addAll(node.getAttributes(name.getName()));
        }
        else
        {
            result.addAll(node.getAttributes());
        }

        return result;
    }
}
{'fraction_non_alphanumeric': 0.0843329027495848, 'fraction_numerical': 0.0018453589223103894, 'mean_word_length': 3.020771513353116, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2898396', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1335, 'n_words': 499}