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

## com.trolltech.qt.core
Class QAbstractFileEngineIterator

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.core.QAbstractFileEngineIterator

All Implemented Interfaces:
  QtJambiInterface

    public abstract class QAbstractFileEngineIterator

extends QtJambiObject

The QAbstractFileEngineIterator class provides an iterator interface for custom file engines. If all you want is to iterate over entries in a directory, see `QDirIterator` instead. This class is only for custom file engine authors.

QAbstractFileEngineIterator is a unidirectional single-use virtual iterator that plugs into `QDirIterator`, providing transparent proxy iteration for custom file engines.

You can subclass QAbstractFileEngineIterator to provide an iterator when writing your own file engine. To plug the iterator into your file system, you simply return an instance of this subclass from a reimplementation of QAbstractFileEngine::beginEntryList().

Example:

        class CustomFileEngine extends QAbstractFileEngine
        {
            QAbstractFileEngineIterator beginEntryList(QDir.Filters filters, java.util.List<String> nameFilters)
            {
                return new CustomFileEngineIterator(filters, nameFilters);
            }
            //...
        }

QAbstractFileEngineIterator is associated with a path, name filters, and entry filters. The path is the directory that the iterator lists entries in. The name filters and entry filters are provided for file engines that can optimize directory listing at the iterator level (e.g., network file systems that need to minimize network traffic), but they can also be ignored by the iterator subclass; QAbstractFileEngineIterator already provides the required filtering logics in the matchesFilters() function. You can call dirName() to get the directory name, `nameFilters()` to get a stringlist of name filters, and `filters()` to get the entry filters.

The pure virual function `hasNext()` returns true if the current directory has at least one more entry (i.e., the directory name is valid and accessible, and we have not reached the end of the entry list), and false otherwise. Reimplement `next()` to seek to the next entry.

The pure virtual function `currentFileName()` returns the name of the current entry without advancing the iterator. The `currentFilePath()` function is provided for convenience; it returns the full path of the current entry.

Here is an example of how to implement an interator that returns each of three fixed entries in sequence.

        class CustomIterator extends QAbstractFileEngineIterator
        {
            private java.util.List<String> entries;
            private int index;

            public CustomIterator(java.util.List<String> nameFilters, QDir.Filters filters)
            {
                super(filters, nameFilters);
                index = 0;

                // In a real iterator, these entries are fetched from the
                // file system based on the value of path().
                entries.add("entry1");
                entries.add("entry2");
                entries.add("entry3");
            }

            public boolean hasNext()
            {
                return index < entries.size() - 1;
            }

            public String next()
            {
               if (!hasNext())
                   return "";
               ++index;
               return currentFilePath();
            }

            public String currentFileName()
            {
                return entries.get(index);
            }
        }

Note: QAbstractFileEngineIterator does not deal with QDir::IteratorFlags; it simply returns entries for a single directory.

See also:
  `QDirIterator`.

Nested Class Summary

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QAbstractFileEngineIterator(QDir.Filters filters, java.util.List nameFilters)` Constructs a QAbstractFileEngineIterator, using the entry filters `filters`, and wildcard name filters `nameFilters`.

Method Summary
`QFileInfo` | `currentFileInfo()` The virtual function returns a `QFileInfo` for the current directory entry.
`abstract java.lang.String` | `currentFileName()` This pure virtual function returns the name of the current directory entry, excluding the path.
`java.lang.String` | `currentFilePath()` Returns the path to the current directory entry.
`QDir.Filters` | `filters()` Returns the entry filters for this iterator.
`abstract boolean` | `hasNext()` This pure virtual function returns true if there is at least one more entry in the current directory (i.
`java.util.List` | `nameFilters()` Returns the name filters for this iterator.
`abstract java.lang.String` | `next()` This pure virtual function advances the iterator to the next directory entry, and returns the file path to the current entry.
`java.lang.String` | `path()` Returns the path for this iterator.

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

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

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Constructor Detail

### QAbstractFileEngineIterator

    public QAbstractFileEngineIterator(QDir.Filters filters,
                                       java.util.List nameFilters)

  Constructs a QAbstractFileEngineIterator, using the entry filters `filters`, and wildcard name filters `nameFilters`.

Method Detail

### currentFilePath

    public final java.lang.String currentFilePath()

  Returns the path to the current directory entry. It's the same as prepending `path()` to the return value of `currentFileName()`.

See also:
  `currentFileName()`.

### filters

    public final QDir.Filters filters()

  Returns the entry filters for this iterator.

See also:
  `QDir::filter()`, `nameFilters()`, and `path()`.

### nameFilters

    public final java.util.List nameFilters()

  Returns the name filters for this iterator.

See also:
  `QDir::nameFilters()`, `filters()`, and `path()`.

### path

    public final java.lang.String path()

  Returns the path for this iterator. `QDirIterator` is responsible for assigning this path; it cannot change during the iterator's lifetime.

See also:
  `nameFilters()`, and `filters()`.

### currentFileInfo

    public QFileInfo currentFileInfo()

  The virtual function returns a `QFileInfo` for the current directory entry. This function is provided for convenience. It can also be slightly faster that creating a `QFileInfo` object yourself, as the object returned by this function might contain cached information that `QFileInfo` otherwise would have to access through the file engine.

See also:
  `currentFileName()`.

### currentFileName

    public abstract java.lang.String currentFileName()

  This pure virtual function returns the name of the current directory entry, excluding the path.

See also:
  `currentFilePath()`.

### hasNext

    public abstract boolean hasNext()

  This pure virtual function returns true if there is at least one more entry in the current directory (i. ., the iterator path is valid and accessible, and the iterator has not reached the end of the entry list).

See also:
  `QDirIterator::hasNext()`.

### next

    public abstract java.lang.String next()

  This pure virtual function advances the iterator to the next directory entry, and returns the file path to the current entry.

  This function can optionally make use of `nameFilters()` and `filters()` to optimize its performance.

  Reimplement this function in a subclass to advance the iterator.

See also:
  `QDirIterator::next()`.

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