1 /* 2 * Copyright 2007 Kasper B. Graversen 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.supercsv.io; 17 18 import java.io.IOException; 19 import java.util.List; 20 21 import org.supercsv.cellprocessor.ift.CellProcessor; 22 import org.supercsv.exception.SuperCsvConstraintViolationException; 23 import org.supercsv.exception.SuperCsvException; 24 25 /** 26 * Interface for writers that write to a List. 27 * 28 * @author Kasper B. Graversen 29 * @author James Bassett 30 */ 31 public interface ICsvListWriter extends ICsvWriter { 32 33 /** 34 * Writes a List of Objects as columns of a CSV file. <tt>toString()</tt> will be called on each element prior to 35 * writing. 36 * 37 * @param columns 38 * the columns to write 39 * @throws IllegalArgumentException 40 * if columns.size == 0 41 * @throws IOException 42 * If an I/O error occurs 43 * @throws NullPointerException 44 * if columns is null 45 * @throws SuperCsvException 46 * if there was a general exception while writing 47 * @since 1.0 48 */ 49 void write(List<?> columns) throws IOException; 50 51 /** 52 * Writes a List of Objects as columns of a CSV file, performing any necessary processing beforehand. 53 * <tt>toString()</tt> will be called on each (processed) element prior to writing. 54 * 55 * @param columns 56 * the columns to write 57 * @param processors 58 * an array of CellProcessors used to further process data before it is written (each element in the 59 * processors array corresponds with a CSV column - the number of processors should match the number of 60 * columns). A <tt>null</tt> entry indicates no further processing is required (the value returned by 61 * toString() will be written as the column value). 62 * @throws IllegalArgumentException 63 * if columns.size == 0 64 * @throws IOException 65 * If an I/O error occurs 66 * @throws NullPointerException 67 * if columns or processors is null 68 * @throws SuperCsvConstraintViolationException 69 * if a CellProcessor constraint failed 70 * @throws SuperCsvException 71 * if there was a general exception while writing/processing 72 * @since 1.0 73 */ 74 void write(List<?> columns, CellProcessor[] processors) throws IOException; 75 76 /** 77 * Writes a array of Objects as columns of a CSV file. <tt>toString()</tt> will be called on each element prior to 78 * writing. 79 * 80 * @param columns 81 * the columns to write 82 * @throws IllegalArgumentException 83 * if columns.length == 0 84 * @throws IOException 85 * If an I/O error occurs 86 * @throws NullPointerException 87 * if columns is null 88 * @throws SuperCsvException 89 * if there was a general exception while writing 90 * @since 1.0 91 */ 92 void write(Object... columns) throws IOException; 93 94 /** 95 * Writes an array of strings as columns of a CSV file. 96 * 97 * @param columns 98 * the columns to write 99 * @throws IllegalArgumentException 100 * if columns.length == 0 101 * @throws IOException 102 * If an I/O error occurs 103 * @throws NullPointerException 104 * if columns is null 105 * @throws SuperCsvException 106 * if there was a general exception while writing 107 * @since 1.0 108 */ 109 void write(String... columns) throws IOException; 110 111 }