<commit_before>/*
 * Copyright <NAME> 2009-2011, All rights reserved.
 *
 * This code is licensed under a standard 3-clause BSD license:
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 *  * Redistributions of source code must retain the above copyright notice, 
 *    this list of conditions and the following disclaimer.
 * 
 *  * Redistributions in binary form must reproduce the above copyright notice, 
 *    this list of conditions and the following disclaimer in the documentation 
 *    and/or other materials provided with the distribution.
 * 
 *  * The names of its contributors may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 * POSSIBILITY OF SUCH DAMAGE.
 */

package net.domesdaybook.matcher.sequence;

import java.io.IOException;
import net.domesdaybook.matcher.bytes.ByteMatcher;
import net.domesdaybook.reader.Reader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.domesdaybook.reader.Window;

/**
 * An immutable sequence matcher which matches sequences of other sequence matchers.
 * For example, we could have a sequence of bytes, followed by a case insensitive
 * sequence, followed by a fixed gap, followed by a byte set sequence.
 * 
 * @author <NAME>
 */
public final class SequenceMatcherArrayMatcher implements SequenceMatcher {

    private final SequenceMatcher[] matchers;
    private final int length;

    
    /**
     * Constructs a SequenceMatcherArrayMatcher from a list of {@link SequenceMatcher} objects.
     *
     * @param matchList A list of SequenceMatchers from which to construct this SequenceMatcherArrayMatcher.
     */
    public SequenceMatcherArrayMatcher(final Collection<SequenceMatcher> matchList) {
        this(matchList, 1);
    }


    /**
     * Constructs a SequenceMatcherArrayMatcher from a repeated list of {@link SequenceMatcher} objects.
     * 
     * @param matchList  A list of (repeated) SequenceMatchers from which to construct this SequenceMatcherArrayMatcher.
     * @param numberOfRepeats The number of times to repeat the list of SequenceMatchers.
     * @throws IllegalArgumentException if the list is null or empty, or the number to repeat is less than one.
     */
    public SequenceMatcherArrayMatcher(final Collection<SequenceMatcher> matchList, final int numberOfRepeats) {
        if (matchList == null || matchList.isEmpty()) {
            throw new IllegalArgumentException("Null or empty match list passed in to CombinedSequenceMatcher.");
        }
        if (numberOfRepeats < 1) {
            throw new IllegalArgumentException("CombinedSequenceMatcher requires a positive number of repeats.");
        }
        if (numberOfRepeats == 1) {
            matchers = matchList.toArray(new SequenceMatcher[matchList.size() * numberOfRepeats]);
            length = matchers.length;
        } else {
            length = matchList.size() * numberOfRepeats;
            final List<SequenceMatcher> allMatchers = new ArrayList<SequenceMatcher>(length);
            for (int count = 0; count < numberOfRepeats; count++) {
                allMatchers.addAll(matchList);
            }
            matchers = matchList.toArray(new SequenceMatcher[length]);
        }
    }
    
    
    public SequenceMatcherArrayMatcher(final SequenceMatcher[] matchArray) {<commit_msg>Added wildcard to collection constructor.<commit_after>/*
 * Copyright <NAME> 2009-2011, All rights reserved.
 *
 * This code is licensed under a standard 3-clause BSD license:
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 *  * Redistributions of source code must retain the above copyright notice, 
 *    this list of conditions and the following disclaimer.
 * 
 *  * Redistributions in binary form must reproduce the above copyright notice, 
 *    this list of conditions and the following disclaimer in the documentation 
 *    and/or other materials provided with the distribution.
 * 
 *  * The names of its contributors may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 * POSSIBILITY OF SUCH DAMAGE.
 */

package net.domesdaybook.matcher.sequence;

import java.io.IOException;
import net.domesdaybook.matcher.bytes.ByteMatcher;
import net.domesdaybook.reader.Reader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.domesdaybook.reader.Window;

/**
 * An immutable sequence matcher which matches sequences of other sequence matchers.
 * For example, we could have a sequence of bytes, followed by a case insensitive
 * sequence, followed by a fixed gap, followed by a byte set sequence.
 * 
 * @author <NAME>
 */
public final class SequenceMatcherArrayMatcher implements SequenceMatcher {

    private final SequenceMatcher[] matchers;
    private final int length;

    
    /**
     * Constructs a SequenceMatcherArrayMatcher from a list of {@link SequenceMatcher} objects.
     *
     * @param matchList A list of SequenceMatchers from which to construct this SequenceMatcherArrayMatcher.
     */
    public SequenceMatcherArrayMatcher(final Collection<? extends SequenceMatcher> matchList) {
        this(matchList, 1);
    }


    /**
     * Constructs a SequenceMatcherArrayMatcher from a repeated list of {@link SequenceMatcher} objects.
     * 
     * @param matchList  A list of (repeated) SequenceMatchers from which to construct this SequenceMatcherArrayMatcher.
     * @param numberOfRepeats The number of times to repeat the list of SequenceMatchers.
     * @throws IllegalArgumentException if the list is null or empty, or the number to repeat is less than one.
     */
    public SequenceMatcherArrayMatcher(final Collection<? extends SequenceMatcher> matchList, final int numberOfRepeats) {
        if (matchList == null || matchList.isEmpty()) {
            throw new IllegalArgumentException("Null or empty match list passed in to CombinedSequenceMatcher.");
        }
        if (numberOfRepeats < 1) {
            throw new IllegalArgumentException("CombinedSequenceMatcher requires a positive number of repeats.");
        }
        if (numberOfRepeats == 1) {
            matchers = matchList.toArray(new SequenceMatcher[matchList.size() * numberOfRepeats]);
            length = matchers.length;
        } else {
            length = matchList.size() * numberOfRepeats;
            final List<SequenceMatcher> allMatchers = new ArrayList<SequenceMatcher>(length);
            for (int count = 0; count < numberOfRepeats; count++) {
                allMatchers.addAll(matchList);
            }
            matchers = matchList.toArray(new SequenceMatcher[length]);
        }
    }
    
    
    public SequenceMatcherArrayMatcher(final SequenceMatcher[] matchArray) {
{'fraction_non_alphanumeric': 0.06526833841106164, 'fraction_numerical': 0.0030466369814858216, 'mean_word_length': 3.5302547770700636, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2893995', 'n_tokens_mistral': 2218, 'n_tokens_neox': 2013, 'n_words': 890}