[jboss-cvs] JBossAS SVN: r71408 - in projects/vfs/trunk/src: test/java/org/jboss/test/virtual/test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Mar 28 19:17:27 EDT 2008


Author: alesj
Date: 2008-03-28 19:17:26 -0400 (Fri, 28 Mar 2008)
New Revision: 71408

Modified:
   projects/vfs/trunk/src/main/java/org/jboss/virtual/VFS.java
   projects/vfs/trunk/src/main/java/org/jboss/virtual/VirtualFile.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSUnitTestCase.java
   projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VirtualFileUnitTestCase.java
Log:
No-op on leaves when visiting.

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/VFS.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/VFS.java	2008-03-28 22:52:43 UTC (rev 71407)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/VFS.java	2008-03-28 23:17:26 UTC (rev 71408)
@@ -249,7 +249,6 @@
     * 
     * @return the children
     * @throws IOException for any problem accessing the virtual file system
-    * @throws IllegalStateException if the root is a leaf node
     */
    public List<VirtualFile> getChildren() throws IOException
    {
@@ -262,7 +261,6 @@
     * @param filter to filter the children
     * @return the children
     * @throws IOException for any problem accessing the virtual file system
-    * @throws IllegalStateException if the root is a leaf node
     */
    public List<VirtualFile> getChildren(VirtualFileFilter filter) throws IOException
    {
@@ -276,7 +274,6 @@
     * 
     * @return the children
     * @throws IOException for any problem accessing the virtual file system
-    * @throws IllegalStateException if the root is a leaf node
     */
    public List<VirtualFile> getChildrenRecursively() throws IOException
    {
@@ -291,7 +288,6 @@
     * @param filter to filter the children
     * @return the children
     * @throws IOException for any problem accessing the virtual file system
-    * @throws IllegalStateException if the root is a leaf node
     */
    public List<VirtualFile> getChildrenRecursively(VirtualFileFilter filter) throws IOException
    {
@@ -304,16 +300,15 @@
     * @param visitor the visitor
     * @throws IOException for any problem accessing the VFS
     * @throws IllegalArgumentException if the visitor is null
-    * @throws IllegalStateException if the root is a leaf node
     */
    public void visit(VirtualFileVisitor visitor) throws IOException
    {
       VirtualFileHandler handler = context.getRoot();
-      if (handler.isLeaf())
-         throw new IllegalStateException("File cannot contain children: " + handler);
-      
-      WrappingVirtualFileHandlerVisitor wrapper = new WrappingVirtualFileHandlerVisitor(visitor);
-      context.visit(handler, wrapper);
+      if (handler.isLeaf() == false)
+      {
+         WrappingVirtualFileHandlerVisitor wrapper = new WrappingVirtualFileHandlerVisitor(visitor);
+         context.visit(handler, wrapper);
+      }
    }
 
    /**
@@ -323,7 +318,6 @@
     * @param visitor the visitor
     * @throws IOException for any problem accessing the VFS
     * @throws IllegalArgumentException if the file or visitor is null
-    * @throws IllegalStateException if the root is a leaf node
     */
    protected void visit(VirtualFile file, VirtualFileVisitor visitor) throws IOException
    {

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/VirtualFile.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/VirtualFile.java	2008-03-28 22:52:43 UTC (rev 71407)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/VirtualFile.java	2008-03-28 23:17:26 UTC (rev 71408)
@@ -353,14 +353,12 @@
     * @param visitor the visitor
     * @throws IOException for any problem accessing the virtual file system
     * @throws IllegalArgumentException if the visitor is null
-    * @throws IllegalStateException if the file is closed or it is a leaf node
+    * @throws IllegalStateException if the file is closed
     */
    public void visit(VirtualFileVisitor visitor) throws IOException
    {
-      if (isLeaf())
-         throw new IllegalStateException("File cannot contain children: " + this);
-
-      getVFS().visit(this, visitor);
+      if (isLeaf() == false)
+         getVFS().visit(this, visitor);
    }
 
    /**

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSUnitTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSUnitTestCase.java	2008-03-28 22:52:43 UTC (rev 71407)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VFSUnitTestCase.java	2008-03-28 23:17:26 UTC (rev 71408)
@@ -1285,15 +1285,10 @@
       VFS vfs = VFS.getVFS(context.getRootURI());
       MockVirtualFileFilter filter = new MockVirtualFileFilter();
       FilterVirtualFileVisitor visitor = new FilterVirtualFileVisitor(filter);
-      try
-      {
-         vfs.visit(visitor);
-         fail("Should not be here!");
-      }
-      catch (Throwable t)
-      {
-         checkThrowable(IllegalStateException.class, t);
-      }
+      vfs.visit(visitor);
+      List<VirtualFile> matched = visitor.getMatched();
+      assertNotNull(matched);
+      assertEmpty(matched);
    }
 
    public void testVisitAllChildrenNullVisitor() throws Exception

Modified: projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VirtualFileUnitTestCase.java
===================================================================
--- projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VirtualFileUnitTestCase.java	2008-03-28 22:52:43 UTC (rev 71407)
+++ projects/vfs/trunk/src/test/java/org/jboss/test/virtual/test/VirtualFileUnitTestCase.java	2008-03-28 23:17:26 UTC (rev 71408)
@@ -1089,15 +1089,10 @@
       VirtualFile file = VFS.getRoot(context.getRootURI());
       MockVirtualFileFilter filter = new MockVirtualFileFilter();
       FilterVirtualFileVisitor visitor = new FilterVirtualFileVisitor(filter);
-      try
-      {
-         file.visit(visitor);
-         fail("Should not be here!");
-      }
-      catch (Throwable t)
-      {
-         checkThrowable(IllegalStateException.class, t);
-      }
+      file.visit(visitor);
+      List<VirtualFile> matched = visitor.getMatched();
+      assertNotNull(matched);
+      assertEmpty(matched);
    }
 
    public void testVisitAllChildrenNullVisitor() throws Exception




More information about the jboss-cvs-commits mailing list