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

io.gdcc.xoai.serviceprovider.lazy.ItemIterator Maven / Gradle / Ivy

Go to download

OAI-PMH service provider implementation. Use it as a harvesting client to read remote repositories.

The newest version!
/*
 * The contents of this file are subject to the license and copyright
 * detailed in the LICENSE and NOTICE files at the root of the source
 * tree and available online at
 *
 * http://www.dspace.org/license/
 */

package io.gdcc.xoai.serviceprovider.lazy;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ItemIterator implements Iterator {
    private List items = new ArrayList<>();
    private Source source;
    private int position = 0;

    public ItemIterator(Source source) {
        this.source = source;
        hasNext();
    }

    @Override
    public boolean hasNext() {
        if (items.size() > position) return true;
        else {
            if (source.endReached()) return false;
            else {
                items.addAll(source.nextIteration());
                return hasNext();
            }
        }
    }

    @Override
    public T next() {
        return items.get(position++);
    }

    @Override
    public void remove() {
        throw new UnsupportedOperationException("OAI-PMH is a read-only interface");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy