Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*******************************************************************************
* Copyright 2015 uniVocity Software Pty Ltd
*
* 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 com.univocity.parsers.csv;
import com.univocity.parsers.common.input.*;
import java.util.*;
import java.util.Map.*;
/**
* An {@link InputAnalysisProcess} to detect column delimiters, quotes and quote escapes in a CSV input.
*
* @author uniVocity Software Pty Ltd - [email protected]
*
*/
abstract class CsvFormatDetector implements InputAnalysisProcess {
private final int MAX_ROW_SAMPLES;
private final char comment;
private final char suggestedDelimiter;
private final char normalizedNewLine;
/**
* Builds a new {@code CsvFormatDetector}
* @param maxRowSamples the number of row samples to collect before analyzing the statistics
* @param settings the configuration provided by the user with potential defaults in case the detection is unable to discover the proper column delimiter or quote character.
*/
CsvFormatDetector(int maxRowSamples, CsvParserSettings settings) {
this.MAX_ROW_SAMPLES = maxRowSamples;
suggestedDelimiter = settings.getFormat().getDelimiter();
normalizedNewLine = settings.getFormat().getNormalizedNewline();
comment = settings.getFormat().getComment();
}
@Override
public void execute(char[] characters, int length) {
Set allSymbols = new HashSet();
Map symbols = new HashMap();
Map escape = new HashMap();
List