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

cdc.impex.exports.CheckedSheetExporter Maven / Gradle / Ivy

The newest version!
package cdc.impex.exports;

import cdc.impex.ImpExStatus;
import cdc.impex.templates.SheetTemplateInstance;
import cdc.issues.Issue;
import cdc.issues.IssuesHandler;

/**
 * Implementation of {@link SheetExporter} that inserts checks.
 * 

* It can be extended and used like this: *

{@code
 * public class FooExporter extends CheckedSheetExporter {
 *     @Override
 *     public void beginSheetExport(SheetTemplate template,
 *                                  IssuesHandler issuesHandler) {
 *         super.beginSheetExport(template, issuesHandler);
 *         // Add your code here
 *     }
 *
 *     @Override
 *     public int getNumberOfRemainingRows() {
 *        checkStatus(ImpExStatus.SHEET);
 *        return ...;
 *     }
 *
 *     @Override
 *     public void exportRow(ExportRow row,
 *                           IssuesHandler issuesHandler) {
 *         super.exportRow(row, issuesHandler);
 *         // Add your code here
 *     }
 *
 *     @Override
 *     public void endSheetExport(SheetTemplate template,
 *                                IssuesHandler issuesHandler) {
 *         super.endSheetExport(template, issuesHandler);
 *         // Add your code here
 *     }
 * }
 * }
* * @author Damien Carbonne */ public class CheckedSheetExporter implements SheetExporter { protected ImpExStatus status = ImpExStatus.WORKBOOK; public CheckedSheetExporter() { super(); } protected void checkStatus(ImpExStatus expected) { ImpExStatus.checkStatus(status, expected); } @Override public void beginSheetExport(SheetTemplateInstance templateInstance, IssuesHandler issuesHandler) { checkStatus(ImpExStatus.WORKBOOK); status = ImpExStatus.SHEET; } @Override public int getNumberOfRemainingRows() { checkStatus(ImpExStatus.SHEET); return 0; } @Override public void exportRow(ExportRow row, IssuesHandler issuesHandler) { checkStatus(ImpExStatus.SHEET); throw new UnsupportedOperationException(); } @Override public void endSheetExport(SheetTemplateInstance templateInstance, IssuesHandler issuesHandler) { checkStatus(ImpExStatus.SHEET); status = ImpExStatus.WORKBOOK; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy