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

net.sf.jtables.io.WriterTableObjectToRowsAbstract Maven / Gradle / Ivy

package net.sf.jtables.io;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import java.util.Collection;
import java.util.Iterator;

public abstract class WriterTableObjectToRowsAbstract extends WriterTableString {

    public WriterTableObjectToRowsAbstract(final File file) throws IOException {
        super(file);
    }

    public WriterTableObjectToRowsAbstract(final OutputStream stream) throws IOException {
        super(stream);
    }

    public WriterTableObjectToRowsAbstract(final Writer writer) throws IOException {
        super(writer);
    }

    public abstract WriterTableObjectToRowsAbstract writeElement(String delimiter, T element) throws IOException;

    public WriterTableObjectToRowsAbstract writeElement(final T element) throws IOException {
        writeElement(DEFAULT_DELIMITER, element);
        return this;
    }

    public WriterTableObjectToRowsAbstract writeElements(final Collection elements) throws IOException {
        writeElements(DEFAULT_DELIMITER, elements);
        return this;
    }

    public WriterTableObjectToRowsAbstract writeElements(final String delimiter,
            final Collection elements) throws IOException {
        final Iterator it = elements.iterator();
        while (it.hasNext()) {
            writeElement(delimiter, it.next());
            if (it.hasNext()) {
                super.writer.newLine();
            }
        }
        return this;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy