    001    package calhoun.analysis.crf.io;
    002
    003    import java.util.Iterator;
    004    import java.util.Map;
    005
    006    /** utility adapter class for creating an iterator of input components from an {@link InputSequenceComposite} iterator.
    007     *  */
    008    public class IteratorAdapterInputComponent implements Iterator<Map<String, InputSequence<?>>> {
    009
    010            Iterator<? extends InputSequence<?>> parent;
    011
    012            /** constructs an iterator that separates out the input components of the parent iterator
    013             * @param parent the iterator over composite input sequences
    014             */
    015            public IteratorAdapterInputComponent(Iterator<? extends InputSequence<?>> parent) {
    016                    this.parent = parent;
    017            }
    018
    019            public boolean hasNext() {
    020                    return parent.hasNext();
    021            }
    022
    023            public Map<String, InputSequence<?>> next() {
    024                    InputSequenceComposite seq = (InputSequenceComposite) parent.next();
    025                    return seq.getComponents();
    026            }
    027
    028            public void remove() {
    029                    throw new UnsupportedOperationException();
    030            }
    031    }