Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.hp.hpl.jena.util.iterator
Class LazyIterator

    java.lang.Object
      com.hp.hpl.jena.util.iterator.LazyIterator

All Implemented Interfaces:
  ClosableIterator, ExtendedIterator, java.util.Iterator

    public abstract class LazyIterator

extends java.lang.Object
implements ExtendedIterator

An ExtendedIterator that is created lazily. This is useful when constructing an iterator is expensive and you'd prefer to delay doing it until certain it's actually needed. For example, if you have `iterator1.andThen(iterator2)` you could implement iterator2 as a LazyIterator. The sequence to be defined is defined by the subclass's definition of create(). That is called exactly once on the first attempt to interact with the LazyIterator.

Version:
  $Revision: 1.7 $
Author:
  jjc, modified to use ExtendedIterators by csayers

Constructor Summary
`LazyIterator()` An ExtendedIterator that is created lazily.

Method Summary
`ExtendedIterator` | `andThen(ClosableIterator other)` return a new iterator which delivers all the elements of this iterator and then all the elements of the other iterator.
`void` | `close()` Close the iterator.
`abstract ExtendedIterator` | `create()` The subclass must define this to return the ExtendedIterator to invoke.
`ExtendedIterator` | `filterDrop(Filter f)` return a new iterator containing only the elements of _this_ which are rejected by the filter _f_.
`ExtendedIterator` | `filterKeep(Filter f)` return a new iterator containing only the elements of _this_ which pass the filter _f_.
`boolean` | `hasNext()`
`ExtendedIterator` | `mapWith(Map1 map1)` return a new iterator where each element is the result of applying _map1_ to the corresponding element of _this_.
`java.lang.Object` | `next()`
`void` | `remove()`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.hp.hpl.jena.util.iterator.ExtendedIterator
`removeNext, toList, toSet`

Constructor Detail

### LazyIterator

    public LazyIterator()

  An ExtendedIterator that is created lazily. This constructor has very low overhead - the real work is delayed until the first attempt to use the iterator.

Method Detail

### hasNext

    public boolean hasNext()

  Specified by:
    `hasNext` in interface `java.util.Iterator`

### next

    public java.lang.Object next()

  Specified by:
    `next` in interface `java.util.Iterator`

### remove

    public void remove()

  Specified by:
    `remove` in interface `java.util.Iterator`

### andThen

    public ExtendedIterator andThen(ClosableIterator other)

  Description copied from interface: `ExtendedIterator`
  return a new iterator which delivers all the elements of this iterator and then all the elements of the other iterator. Does not copy either iterator; they are consumed as the result iterator is consumed.

  Specified by:
    `andThen` in interface `ExtendedIterator`

### filterKeep

    public ExtendedIterator filterKeep(Filter f)

  Description copied from interface: `ExtendedIterator`
  return a new iterator containing only the elements of _this_ which pass the filter _f_. The order of the elements is preserved. Does not copy _this_, which is consumed as the result is consumed.

  Specified by:
    `filterKeep` in interface `ExtendedIterator`

### filterDrop

    public ExtendedIterator filterDrop(Filter f)

  Description copied from interface: `ExtendedIterator`
  return a new iterator containing only the elements of _this_ which are rejected by the filter _f_. The order of the elements is preserved. Does not copy _this_, which is consumed as the reult is consumed.

  Specified by:
    `filterDrop` in interface `ExtendedIterator`

### mapWith

    public ExtendedIterator mapWith(Map1 map1)

  Description copied from interface: `ExtendedIterator`
  return a new iterator where each element is the result of applying _map1_ to the corresponding element of _this_. _this_ is not copied; it is consumed as the result is consumed.

  Specified by:
    `mapWith` in interface `ExtendedIterator`

### close

    public void close()

  Description copied from interface: `ClosableIterator`
  Close the iterator. Other oeprations on this iterator may now throw an exception. A ClosableIterator may be closed as many times as desired - the subsequent calls do nothing.

  Specified by:
    `close` in interface `ClosableIterator`

### create

    public abstract ExtendedIterator create()

  The subclass must define this to return the ExtendedIterator to invoke. This method will be called at most once, on the first attempt to use the iterator. From then on, all calls to this will be passed through to the returned Iterator.

  Returns:
    The parent iterator defining the sequence.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP