commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1182074 - in /commons/proper/vfs/trunk/core/src: main/java/org/apache/commons/vfs2/ main/java/org/apache/commons/vfs2/impl/ main/java/org/apache/commons/vfs2/provider/ test/java/org/apache/commons/vfs2/test/
Date Tue, 11 Oct 2011 20:24:43 GMT
Author: ggregory
Date: Tue Oct 11 20:24:42 2011
New Revision: 1182074

URL: http://svn.apache.org/viewvc?rev=1182074&view=rev
Log:
[VFS-367] Add APIs FileObject isFile(), FileObject isFolder(), and FileName isFile()

Modified:
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/FileObject.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/impl/DecoratedFileObject.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/FileSystemManagerFactoryTestCase.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/ProviderReadTests.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/ProviderWriteTests.java
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/VerifyingFileSelector.java

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/FileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/FileObject.java?rev=1182074&r1=1182073&r2=1182074&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/FileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/FileObject.java Tue
Oct 11 20:24:42 2011
@@ -342,6 +342,16 @@ public interface FileObject
      */
     public boolean isFile() throws FileSystemException;
 
+    /**
+     * Checks if this file is a folder.
+     * 
+     * @return true if this file is a folder.
+     * @throws FileSystemException if an error occurs.
+     * @see #getType() 
+     * @see FileType#FOLDER
+     */
+    public boolean isFolder() throws FileSystemException;
+
 
     // --- OPERATIONS --
     /**

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/impl/DecoratedFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/impl/DecoratedFileObject.java?rev=1182074&r1=1182073&r2=1182074&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/impl/DecoratedFileObject.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/impl/DecoratedFileObject.java
Tue Oct 11 20:24:42 2011
@@ -190,6 +190,11 @@ public class DecoratedFileObject impleme
         return decoratedFileObject.isFile();        
     }
 
+    public boolean isFolder() throws FileSystemException 
+    {
+        return decoratedFileObject.isFolder();        
+    }
+
     @Override
     public String toString()
     {

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java?rev=1182074&r1=1182073&r2=1182074&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java
Tue Oct 11 20:24:42 2011
@@ -523,6 +523,19 @@ public abstract class AbstractFileObject
     }
     
     /**
+     * Checks if this file is a folder by using its file type.
+     * 
+     * @return true if this file is a regular file.
+     * @throws FileSystemException
+     * @see #getType() 
+     * @see FileType#FOLDER
+     */
+    public boolean isFolder() throws FileSystemException {
+        // Use equals instead of == to avoid any class loader worries.
+        return FileType.FOLDER.equals(this.getType());
+    }
+    
+    /**
      * Determines if this file can be read.
      * @return true if the file is a hidden file, false otherwise.
      * @throws FileSystemException if an error occurs.

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/FileSystemManagerFactoryTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/FileSystemManagerFactoryTestCase.java?rev=1182074&r1=1182073&r2=1182074&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/FileSystemManagerFactoryTestCase.java
(original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/FileSystemManagerFactoryTestCase.java
Tue Oct 11 20:24:42 2011
@@ -53,6 +53,7 @@ public class FileSystemManagerFactoryTes
         assertNotNull(file);
         assertTrue(file.exists());
         assertSame(FileType.FOLDER, file.getType());
+        assertTrue(file.isFolder());
     }
 
 }

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/ProviderReadTests.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/ProviderReadTests.java?rev=1182074&r1=1182073&r2=1182074&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/ProviderReadTests.java
(original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/ProviderReadTests.java
Tue Oct 11 20:24:42 2011
@@ -142,6 +142,7 @@ public class ProviderReadTests
         // Test a folder
         file = getReadFolder().resolveFile("dir1");
         assertSame(FileType.FOLDER, file.getType());
+        assertTrue(file.isFolder());
 
         // Test an unknown file
         file = getReadFolder().resolveFile("unknown-child");

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/ProviderWriteTests.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/ProviderWriteTests.java?rev=1182074&r1=1182073&r2=1182074&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/ProviderWriteTests.java
(original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/ProviderWriteTests.java
Tue Oct 11 20:24:42 2011
@@ -82,6 +82,7 @@ public class ProviderWriteTests
         folder.createFolder();
         assertTrue(folder.exists());
         assertSame(FileType.FOLDER, folder.getType());
+        assertTrue(folder.isFolder());
         assertEquals(0, folder.getChildren().length);
 
         // Create a descendant, where the intermediate folders don't exist
@@ -92,6 +93,7 @@ public class ProviderWriteTests
         folder.createFolder();
         assertTrue(folder.exists());
         assertSame(FileType.FOLDER, folder.getType());
+        assertTrue(folder.isFolder());
         assertEquals(0, folder.getChildren().length);
         assertTrue(folder.getParent().exists());
         assertTrue(folder.getParent().getParent().exists());
@@ -171,6 +173,7 @@ public class ProviderWriteTests
         FileObject folder = scratchFolder.resolveFile("dir1/dir2");
         folder.createFolder();
         assertEquals(FileType.FOLDER, folder.getType());
+        assertTrue(folder.isFolder());
 
         // Attempt to create a file that already exists as a folder
         try

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/VerifyingFileSelector.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/VerifyingFileSelector.java?rev=1182074&r1=1182073&r2=1182074&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/VerifyingFileSelector.java
(original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/test/VerifyingFileSelector.java
Tue Oct 11 20:24:42 2011
@@ -91,6 +91,7 @@ public class VerifyingFileSelector
         // Check that the given file is a folder
         final FileObject folder = fileInfo.getFile();
         assertSame(FileType.FOLDER, folder.getType());
+        assertTrue(folder.isFolder());
 
         // Locate the info for the folder
         final String baseName = folder.getName().getBaseName();



Mime
View raw message