org.supercsv.util.Util Maven / Gradle / Ivy
/*
 * Copyright 2007 Kasper B. Graversen
 * 
 * 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.supercsv.util;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.supercsv.cellprocessor.ift.CellProcessor;
import org.supercsv.exception.SuperCsvConstraintViolationException;
import org.supercsv.exception.SuperCsvException;
/**
 * Useful utility methods.
 * 
 * @author Kasper B. Graversen
 * @author James Bassett
 */
public final class Util {
	
	// no instantiation
	private Util() {
	}
	
	/**
	 * Processes each element in the source List (using the corresponding processor chain in the processors array) and
	 * adds it to the destination List. A null CellProcessor in the array indicates that no processing is
	 * required and the element should be added as-is.
	 * 
	 * @param destination
	 *            the List to add the processed elements to (which is cleared before it's populated)
	 * @param source
	 *            the List of source elements to be processed
	 * @param processors
	 *            the array of CellProcessors used to process each element. The number of elements in this array must
	 *            match the size of the source List. A null CellProcessor in this array indicates that no
	 *            processing is required and the element should be added as-is.
	 * @param lineNo
	 *            the current line number
	 * @param rowNo
	 *            the current row number
	 * @throws NullPointerException
	 *             if destination, source or processors is null
	 * @throws SuperCsvConstraintViolationException
	 *             if a CellProcessor constraint failed
	 * @throws SuperCsvException
	 *             if source.size() != processors.length, or CellProcessor execution failed
	 */
	public static void executeCellProcessors(final List    © 2015 - 2025 Weber Informatics LLC | Privacy Policy