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

org.dspace.checker.ListDispatcher Maven / Gradle / Ivy

/**
 * 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 org.dspace.checker;

import java.util.Collections;
import java.util.EmptyStackException;
import java.util.List;
import java.util.Stack;

/**
 * Really simple dispatcher that just iterates over a pre-defined list of ids.
 * 
 * @author Jim Downing
 * @author Grace Carpenter
 * @author Nathan Sarr
 * 
 */
public class ListDispatcher implements BitstreamDispatcher
{
    /**
     * List of Integer ids.
     */
    Stack bitstreams = new Stack();

    /**
     * Blanked off, no-op constructor. Do not use.
     */
    private ListDispatcher()
    {
    }

    /**
     * Main constructor.
     * 
     * @param bitstreamIds
     */
    public ListDispatcher(List bitstreamIds)
    {
        Collections.reverse(bitstreamIds);
        bitstreams.addAll(bitstreamIds);
    }

    /**
     * @see org.dspace.checker.BitstreamDispatcher#next()
     */
    public synchronized int next()
    {
        try
        {
            return bitstreams.pop().intValue();
        }
        catch (EmptyStackException e)
        {
            return SENTINEL;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy