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

com.avaje.ebean.text.csv.CsvCallback Maven / Gradle / Ivy

package com.avaje.ebean.text.csv;

import com.avaje.ebean.EbeanServer;

/**
 * Provides callback methods for customisation of CSV processing.
 * 

* You can provide your own CsvCallback implementation to customise the CSV * processing. It is expected that the DefaultCsvCallback provides a good base * class that you can extend. *

* * @author rbygrave * * @param */ public interface CsvCallback { /** * The processing is about to begin. *

* Typically the callback will create a transaction, set batch mode, batch * size etc. *

*/ void begin(EbeanServer server); /** * Read the header row. *

* This is only called if {@link CsvReader#setHasHeader(boolean,boolean)} has * been set to true. *

* * @param line * the header line content. */ void readHeader(String[] line); /** * Check that the row should be processed - return true to process the row or * false to ignore the row. Gives ability to handle bad data... empty rows etc * and ignore it rather than fail. */ boolean processLine(int row, String[] line); /** * Called for each bean after it has been loaded from the CSV content. *

* This allows you to process the bean however you like. *

*

* When you use a CsvCallback the CsvReader *WILL NOT* create a transaction * and will not save the bean for you. You have complete control and must do * these things yourself (if that is want you want). *

* * @param row * the index of the content being processed * @param line * the content that has been used to load the bean * @param bean * the entity bean after it has been loaded from the csv content */ void processBean(int row, String[] line, T bean); /** * The processing has ended successfully. *

* Typically the callback will commit the transaction. *

*/ void end(int row); /** * The processing has ended due to an error. *

* This gives the callback the opportunity to rollback the transaction if one * was created. *

* * @param row * the row that the error has occured on * @param e * the error that occured */ void endWithError(int row, Exception e); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy