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

io.robe.convert.common.Importer Maven / Gradle / Ivy

The newest version!
package io.robe.convert.common;


import java.io.InputStream;
import java.util.List;

public abstract class Importer extends Converter {
    protected static final String DEFAULT_ENCODING = "UTF-8";

    public Importer(Class dataClass) {
        super(dataClass);
    }

    // Gets all entities at once, ram usage could increase while reading
    public abstract List importStream(InputStream inputStream) throws Exception;

    public abstract List importStream(InputStream inputStream, String charSetName) throws Exception;


    // invokes handler in each atom, good for big sized data sets, less ram usage
    public abstract void importStream(InputStream inputStream, OnItemHandler handler) throws Exception;

    public abstract void importStream(InputStream inputStream, OnItemHandler handler, String charSetName) throws Exception;

    protected class DefaultOnItemHandler implements OnItemHandler {
        private List list = null;

        public DefaultOnItemHandler(List list) {
            this.list = list;
        }

        @Override
        public void onItem(T item) throws Exception {
            list.add(item);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy