001: /*
002: (c) Copyright 2002, 2003, 2004, 2005 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: [See end of file]
004: $Id: ExtendedIterator.java,v 1.9 2008/01/02 12:07:36 andy_seaborne Exp $
005: */
006:
007: package com.hp.hpl.jena.util.iterator;
008:
009: import java.util.*;
010:
011: /**
012: an ExtendedIterator is a ClosableIterator on which other operations are
013: defined for convenience in iterator composition: composition, filtering
014: in, filtering out, and element mapping.
015: <br>
016: NOTE that the result of each of these operations consumes the base
017: iterator(s); they do not make independant copies.
018: <br>
019: The canonical implementation of ExtendedIterator is NiceIterator, which
020: also defines static methods for these operations that will work on any
021: ClosableIterators.
022: <br>
023: @author kers
024: */
025:
026: public interface ExtendedIterator extends ClosableIterator {
027: /**
028: Answer the next object, and remove it. Equivalent to next(); remove().
029: */
030: public Object removeNext();
031:
032: /**
033: return a new iterator which delivers all the elements of this iterator and
034: then all the elements of the other iterator. Does not copy either iterator;
035: they are consumed as the result iterator is consumed.
036: */
037: public ExtendedIterator andThen(ClosableIterator other);
038:
039: /**
040: return a new iterator containing only the elements of _this_ which
041: pass the filter _f_. The order of the elements is preserved. Does not
042: copy _this_, which is consumed as the result is consumed.
043: */
044: public ExtendedIterator filterKeep(Filter f);
045:
046: /**
047: return a new iterator containing only the elements of _this_ which
048: are rejected by the filter _f_. The order of the elements is preserved.
049: Does not copy _this_, which is consumed as the reult is consumed.
050: */
051: public ExtendedIterator filterDrop(Filter f);
052:
053: /**
054: return a new iterator where each element is the result of applying
055: _map1_ to the corresponding element of _this_. _this_ is not
056: copied; it is consumed as the result is consumed.
057: */
058: public ExtendedIterator mapWith(Map1 map1);
059:
060: /**
061: Answer a list of the [remaining] elements of this iterator, in order,
062: consuming this iterator.
063: */
064: public List toList();
065:
066: /**
067: Answer a set of the [remaining] elements of this iterator, in order,
068: consuming this iterator.
069: */
070: public Set toSet();
071: }
072:
073: /*
074: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
075: All rights reserved.
076:
077: Redistribution and use in source and binary forms, with or without
078: modification, are permitted provided that the following conditions
079: are met:
080:
081: 1. Redistributions of source code must retain the above copyright
082: notice, this list of conditions and the following disclaimer.
083:
084: 2. Redistributions in binary form must reproduce the above copyright
085: notice, this list of conditions and the following disclaimer in the
086: documentation and/or other materials provided with the distribution.
087:
088: 3. The name of the author may not be used to endorse or promote products
089: derived from this software without specific prior written permission.
090:
091: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
092: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
093: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
094: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
095: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
096: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
097: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
098: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
099: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
100: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
101: */
|