ingo@1115: /*
ingo@1115: * Copyright (c) 2010 by Intevation GmbH
ingo@1115: *
ingo@1115: * This program is free software under the LGPL (>=v2.1)
ingo@1115: * Read the file LGPL.txt coming with the software for details
ingo@1115: * or visit http://www.gnu.org/licenses/ if it does not exist.
ingo@1115: */
ingo@1115:
ingo@230: package de.intevation.gnv.exports;
ingo@230:
sascha@779: import de.intevation.gnv.geobackend.base.Result;
sascha@779:
sascha@779: import de.intevation.gnv.state.exception.StateException;
sascha@779:
sascha@779: import java.io.IOException;
sascha@779: import java.io.OutputStream;
sascha@779: import java.io.UnsupportedEncodingException;
sascha@779:
ingo@230: import java.util.Collection;
ingo@230:
ingo@230: /**
ingo@771: * This interface should be implemented by a class whose instances are intended
sascha@778: * to export a Collection
of Result
s into a specific
ingo@771: * format (e.g. CSV or ODV).
ingo@771: *
ingo@771: * @author Sascha L. Teichmann
ingo@771: * @author Ingo Weinzierl
ingo@230: */
ingo@230: public interface Export {
ingo@230:
ingo@771: /**
ingo@771: * This interface provides some methods which describe the format used by an
ingo@771: * Export
.
ingo@771: */
ingo@230: public interface Profile {
ingo@794: /**
ingo@794: *
ingo@794: * @param column Column index.
ingo@794: * @param value A default value.
ingo@794: * @return A specific column as string.
ingo@794: */
ingo@230: String toString(int column, String value);
ingo@771:
ingo@771: /**
ingo@771: * This method serves information about the character used to separate
ingo@771: * columns.
ingo@771: *
ingo@771: * @return Character used to separate
ingo@771: */
ingo@239: char getSeparator();
ingo@771:
ingo@771: /**
ingo@771: * This method serves information about the character used as escape
ingo@771: * character.
ingo@771: *
ingo@771: * @return Escape character
ingo@771: */
ingo@239: char getEscapeCharacter();
ingo@771:
ingo@771: /**
ingo@771: * This method serves informatin about the character used as quote
ingo@771: * character.
ingo@771: *
ingo@771: * @return Quote character
ingo@771: */
ingo@239: char getQuoteCharacter();
ingo@771:
ingo@771: /**
ingo@771: * This method serves information about the format.
ingo@771: *
ingo@771: * @return Format as string.
ingo@771: */
ingo@239: String getType();
ingo@771:
ingo@771: /**
ingo@771: * This method serves information about the encoding to be used.
ingo@771: *
ingo@771: * @return Encoding
ingo@771: */
ingo@239: String getEncoding();
ingo@771:
ingo@771: /**
ingo@771: * This method returns the header as array.
ingo@771: *
ingo@771: * @return Header as string array.
ingo@771: */
ingo@239: String [] getHeader();
ingo@230: }
ingo@230:
ingo@771: /**
ingo@771: * This interface should be implemeted to collect the required data from
ingo@771: * Result
object.
ingo@771: */
ingo@233: public interface DataCollector {
ingo@771:
ingo@771: /**
ingo@771: * This method serves the required data stored in a Result
ingo@771: * object.
ingo@771: *
ingo@794: * @param result Result
object which contains the required
ingo@794: * data.
ingo@771: * @return String[] which contains all required data.
ingo@771: *
ingo@771: * @throws StateException
ingo@771: */
ingo@233: String[] getData(Result result)
tim@335: throws StateException;
ingo@233: }
ingo@233:
ingo@771: /**
ingo@771: * This method creates an export document specified by {@link Profile} which
ingo@771: * contains the data stored in result
and writes it to
ingo@771: * outputStream
.
ingo@771: *
ingo@771: * @param profile Profile used to specify the format of the resulting export
ingo@771: * document.
ingo@771: * @param outputStream Resulting export document is written to this
ingo@771: * OutputStream.
ingo@771: * @param result Collection which contains the data used to be written into
ingo@771: * the export document.
ingo@771: *
ingo@771: * @throws IOException if an error occured while writing the export document
ingo@771: * to OutputStream
ingo@771: * @throws UnsupportedEncodingException if the given encoding is not
ingo@771: * accepted
ingo@771: * @throws StateException if result
is null
ingo@771: */
ingo@230: public void create(
ingo@230: Profile profile,
sascha@778: OutputStream outputStream,
ingo@230: Collection result
ingo@230: )
tim@335: throws IOException, UnsupportedEncodingException, StateException;
ingo@230:
ingo@230: }
ingo@771: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :