<commit_before>/*
 * Copyright 2011-2013 <NAME>
 * 
 * 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.beanio.internal.compiler.flat;

import java.util.*;

import org.beanio.BeanIOConfigurationException;
import org.beanio.internal.compiler.Preprocessor;
import org.beanio.internal.config.*;

/**
 * Base class for {@link Preprocessor} implementations for flat stream formats 
 * (i.e. CSV, delimited, and fixed length).
 * 
 * @author <NAME>
 * @since 2.0
 */
public class FlatPreprocessor extends Preprocessor {

    // the current default field position
    private int defaultPosition = 0;
    // position must be set for all fields or for no fields, this attribute
    // is set when the first field is processed and all other fields must adhere to it
    private Boolean positionRequired;
    
    // the field or segment that requires a maximum position set on it to test for more occurrences
    // of an indefinitely repeating field or segment
    private PropertyConfig unboundedComponent = null;
    // the component that immediately follows the unbounded component
    private PropertyConfig unboundedComponentFollower = null;
    // the list of components at the end of the record following the unbounded component
    private List<PropertyConfig> endComponents = new ArrayList<PropertyConfig>();
    
    /**
     * Constructs a new <tt>FlatPreprocessor</tt>.
     * @param stream
     */
    public FlatPreprocessor(StreamConfig stream) {
        super(stream);
    }
    
    @Override
    protected void initializeRecord(RecordConfig record) {
        super.initializeRecord(record);
        
        defaultPosition = 0;
        positionRequired = null;
    }
    
    @Override
    protected void finalizeRecord(RecordConfig record) {
        super.finalizeRecord(record);
        
        boolean minSet = record.getMinLength() != null;
        if (stream.isStrict()) {
            if (record.getMinLength() == null) {
                record.setMinLength(record.getMinSize());
            }<commit_msg>[2.0.4] Fixed initialization of repeating fields state variables (gc0057)<commit_after>/*
 * Copyright 2011-2013 <NAME>
 * 
 * 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.beanio.internal.compiler.flat;

import java.util.*;

import org.beanio.BeanIOConfigurationException;
import org.beanio.internal.compiler.Preprocessor;
import org.beanio.internal.config.*;

/**
 * Base class for {@link Preprocessor} implementations for flat stream formats 
 * (i.e. CSV, delimited, and fixed length).
 * 
 * @author <NAME>
 * @since 2.0
 */
public class FlatPreprocessor extends Preprocessor {

    // the current default field position
    private int defaultPosition = 0;
    // position must be set for all fields or for no fields, this attribute
    // is set when the first field is processed and all other fields must adhere to it
    private Boolean positionRequired;
    
    // the field or segment that requires a maximum position set on it to test for more occurrences
    // of an indefinitely repeating field or segment
    private PropertyConfig unboundedComponent = null;
    // the component that immediately follows the unbounded component
    private PropertyConfig unboundedComponentFollower = null;
    // the list of components at the end of the record following the unbounded component
    private List<PropertyConfig> endComponents = new ArrayList<PropertyConfig>();
    
    /**
     * Constructs a new <tt>FlatPreprocessor</tt>.
     * @param stream
     */
    public FlatPreprocessor(StreamConfig stream) {
        super(stream);
    }
    
    @Override
    protected void initializeRecord(RecordConfig record) {
        super.initializeRecord(record);
        
        defaultPosition = 0;
        positionRequired = null;
        unboundedComponent = null;
        unboundedComponentFollower = null;
        endComponents.clear();
    }
    
    @Override
    protected void finalizeRecord(RecordConfig record) {
        super.finalizeRecord(record);
        
        boolean minSet = record.getMinLength() != null;
        if (stream.isStrict()) {
            if (record.getMinLength() == null) {
                record.setMinLength(record.getMinSize());
            }
{'fraction_non_alphanumeric': 0.07778836987607245, 'fraction_numerical': 0.007435653002859866, 'mean_word_length': 3.082490272373541, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '6270095', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1270, 'n_words': 519}