xp-framework/rfc — Issue #75: I/O Collections
Author: thekid
Created: 2011-10-17 15:51:55+00:00
State: closed
Labels: framework, implemented

Scope of Change
====
A new API io.collections will be added.

Rationale
====
Easier iteration of file system elements.

Functionality
====

Interfaces
----
The following interfaces are defined by this new API:

```
lang.Interface
|
+--+ io.collections.IOElement
| |
| +--+ io.collections.IOCollection
|
+--+ io.collections.iterate.IterationFilter

```

Classes
----
The following classes are defined by this new API:

```
lang.Object
|
+--+ io.collections.FileElement -> io.collections.IOElement
|
+--+ io.collections.FileCollection -> io.collections.IOCollection
|
+--+ io.collections.iterate.RegexFilter -> io.collections.iterate.IterationFilter
|
+--+ io.collections.iterate.IOCollectionIterator -> util.Iterator
|
+--+ io.collections.iterate.FilteredIOCollectionIterator

```

Example
----
Iterating a directory (non-recursively), finding all jpeg-files:

```php
hasNext();
) {
Console::writeLine('Element ', xp::stringOf($i->next()));
}
?>
```

Security considerations
====
n/a

Speed impact
====
n/a

Dependencies
====
n/a

Related documents
====
- http://xp-framework.info/xml/xp.en_US/documentation/class?ports/de.thekid.dialog.io.FilteredFolderIterator
de.thekid.dialog.io.FilteredFolderIterator

- http://xp-framework.net/rfc/contrib/rfc0075.diff
Initial implementation

- http://www.xulplanet.com/references/xpcomref/ifaces/nsIDirectoryIterator.html
Mozilla's DirectoryIterator

- http://wiki.cc/php/Iterator_Directory
SPL's DirectoryIterator