I/O Collections random access #151

Merged
merged 8 commits into from Jan 13, 2013

Conversation

Projects
None yet
1 participant
Owner

thekid commented Apr 20, 2012

This pull request implements xp-framework/rfc#196 and adds the following new methods to io.collections.FileCollection:

  public io.collections.IOElement newElement(string $name)
  public io.collections.IOCollection newCollection(string $name)
  public io.collections.IOElement findElement(string $name)
  public io.collections.IOCollection findCollection(string $name)
  public io.collections.IOElement getElement(string $name) throws util.NoSuchElementException
  public io.collections.IOCollection getCollection(string $name) throws util.NoSuchElementException
  public void removeElement(string $name)
  public void removeCollection(string $name)

All methods may also throw IOExceptions.

Owner

thekid commented Apr 20, 2012

A note on extending this to other IOCollection implementations:

Archives

For io.collections.ArchiveCollection we could support the read-only get and find operations; and throw exceptions (TODO: which?) for new and remove.

FTP

The peer.ftp.collections.FtpCollection class could fully support all operations. This should most probably be included.

What do others think?

@thekid thekid commented on an outdated diff May 15, 2012

.../src/main/php/io/collections/FileCollection.class.php
+ if (!is_file($qualified)) return NULL;
+
+ $found= new FileElement($qualified);
+ $found->setOrigin($this);
+ return $found;
+ }
+
+ /**
+ * Finds a collection inside this collection
+ *
+ * @param string name
+ * @return io.collections.IOCollection
+ */
+ public function findCollection($name) {
+ $qualified= $this->qualifiedName($name);
+ if (!is_file($qualified)) return NULL;
@thekid

thekid May 15, 2012

Owner

This should be is_dir().

Owner

thekid commented May 15, 2012

and throw exceptions (TODO: which?) for new and remove.

How does io.OperationNotSupportedException sound (complementing io.OperationTimedOutException)?

@thekid thekid commented on the diff Jan 13, 2013

.../main/php/io/OperationNotSupportedException.class.php
@@ -0,0 +1,17 @@
+<?php
+/* This class is part of the XP framework
+ *
+ * $Id$
+ */
+
+ uses('io.IOException');
+
+ /**
+ * Indicates an operation is not supported
+ *
+ * @see xp://io.IOException
+ */
+ class OperationTimedOutException extends IOException {
@thekid

thekid Jan 13, 2013

Owner

This should be class OperationNotSupportedException, but reads ...TimedOut.... Copy&paste messup!

thekid merged commit 390f971 into xp-framework:master Jan 13, 2013

@thekid thekid added a commit that referenced this pull request Jan 13, 2013

@thekid thekid - Announce xp-framework/rfc#196 (pull request #151) fcf69dd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment