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

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

There is a newer version: 1.2.0
Show 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.Closeable;
import java.io.Flushable;
import java.io.IOException;

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


/**
 * Represents a CSV destination writer.
 * 
 * 

* Reads an object of type M that represents the * data model and writes the corresponding CSV record * to the given destination. *

* * @param type of the data model representing the CSV record. * * @author Nerd4J Team */ public interface CSVWriter extends Closeable, Flushable { /** * Writes the given data model, formatted like * a CSV record into the configured CSV destination. *

* This method has a cleaner interface but handles * processing errors by throwing {@link CSVProcessException} * therefore it may be slow. If performance matters * use {@link CSVWriter#write(Object)} instead. *

* * @throws IOException if an error occurs reading the CSV source. * @throws ModelToCSVBindingException if an error occurs during model binding. * @throws CSVProcessException if an error occurs during data processing. */ public void writeModel( M model ) throws IOException, ModelToCSVBindingException; /** * Writes the given data model, formatted like * a CSV record into the configured CSV destination. *

* IMPORTANT for performance reasons there is only one * instance of the read outcome. * So the internal values of this object may * vary during execution. *

* * @return the outcome of the writing process. * @throws IOException if an error occurs reading the CSV source. * @throws ModelToCSVBindingException if an error occurs during model binding. */ public CSVWriteOutcome write( M model ) throws IOException, ModelToCSVBindingException; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy