All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nerd4j.csv.writer.CSVWriterFactory Maven / Gradle / Ivy

The newest version!
/*
 * #%L
 * Nerd4j CSV
 * %%
 * Copyright (C) 2013 Nerd4j
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public 
 * License along with this program.  If not, see
 * .
 * #L%
 */
package org.nerd4j.csv.writer;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;

import org.nerd4j.csv.exception.CSVInvalidHeaderException;
import org.nerd4j.csv.exception.ModelToCSVBindingException;


/**
 * Represents a {@code Factory} able to build and configure {@link CSVWriter}s.
 * 
 * @param  type of the data model accepted by the writer.
 * 
 * @author Nerd4j Team
 */
public interface CSVWriterFactory
{
    
    /**
     * Creates the {@link CSVWriter} able to write the given
     * data model into the provided CSV destination file.
     * 
     * @param file the CSV destination file.
     * @return a related {@link CSVWriter}.
     * @throws FileNotFoundException if fails to find the destination file.
     * @throws IOException if fails to write the destination file.
     * @throws ModelToCSVBindingException if binding configuration is inconsistent.
     */
    public CSVWriter getCSVWriter( File file )
    throws FileNotFoundException, IOException, ModelToCSVBindingException;
    
    /**
     * Creates the {@link CSVWriter} able to write the given
     * data model into the provided CSV destination file.
     * 

* The given header determine which columns have to be written * and in which order. Each column identifier in the given * header must match a related column identifier in the * configuration. * * @param file the CSV destination file. * @param header defines the columns to use. * @return a related {@link CSVWriter}. * @throws FileNotFoundException if fails to find the destination file. * @throws IOException if fails to write the destination file. * @throws ModelToCSVBindingException if binding configuration is inconsistent. * @throws CSVInvalidHeaderException if the header is not valid. */ public CSVWriter getCSVWriter( File file, String[] header ) throws FileNotFoundException, IOException, ModelToCSVBindingException, CSVInvalidHeaderException; /** * Creates the {@link CSVWriter} able to write the given * data model into the provided CSV destination output stream. * * @param os the CSV destination output stream. * @return a related {@link CSVWriter}. * @throws IOException if fails to write the destination. * @throws ModelToCSVBindingException if binding configuration is inconsistent. */ public CSVWriter getCSVWriter( OutputStream os ) throws IOException, ModelToCSVBindingException; /** * Creates the {@link CSVWriter} able to write the given * data model into the provided CSV destination output stream. *

* The given header determine which columns have to be written * and in which order. Each column identifier in the given * header must match a related column identifier in the * configuration. * * @param os the CSV destination output stream. * @param header defines the columns to use. * @return a related {@link CSVWriter}. * @throws IOException if fails to write the destination. * @throws ModelToCSVBindingException if binding configuration is inconsistent. * @throws CSVInvalidHeaderException if the header is not valid. */ public CSVWriter getCSVWriter( OutputStream os, String[] header ) throws IOException, ModelToCSVBindingException, CSVInvalidHeaderException; /** * Creates the {@link CSVWriter} able to write the given * data model of type {@code M} into the provided * CSV destination. * * @param writer the CSV destination writer. * @return a related {@link CSVWriter}. * @throws IOException if fails to write the destination. * @throws ModelToCSVBindingException if binding configuration is inconsistent. */ public CSVWriter getCSVWriter( Writer writer ) throws IOException, ModelToCSVBindingException; /** * Creates the {@link CSVWriter} able to write the given * data model of type {@code M} into the provided * CSV destination. *

* The given header determine which columns have to be written * and in which order. Each column identifier in the given * header must match a related column identifier in the * configuration. * * @param writer the CSV destination writer. * @param header defines the columns to use. * @return a related {@link CSVWriter}. * @throws IOException if fails to write the destination. * @throws ModelToCSVBindingException if binding configuration is inconsistent. * @throws CSVInvalidHeaderException if the header is not valid. */ public CSVWriter getCSVWriter( Writer writer, String[] header ) throws IOException, ModelToCSVBindingException, CSVInvalidHeaderException; }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy