You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by gg...@apache.org on 2003/12/17 21:31:31 UTC
cvs commit: jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs Resources.properties FileObject.java
ggregory 2003/12/17 12:31:31
Modified: vfs/src/java/org/apache/commons/vfs/provider
DelegateFileObject.java AbstractFileObject.java
vfs/src/test/org/apache/commons/vfs/test
ProviderWriteTests.java
vfs/src/java/org/apache/commons/vfs/provider/local
LocalFile.java
vfs/src/java/org/apache/commons/vfs Resources.properties
FileObject.java
Log:
Implement isHidden (forgot to commit this from a couple of weeks ago).
Revision Changes Path
1.10 +17 -1 jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/DelegateFileObject.java
Index: DelegateFileObject.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/DelegateFileObject.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- DelegateFileObject.java 13 Oct 2003 08:44:26 -0000 1.9
+++ DelegateFileObject.java 17 Dec 2003 20:31:30 -0000 1.10
@@ -72,6 +72,7 @@
* A file backed by another file.
*
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @author Gary D. Gregory
* @version $Revision$ $Date$
*
* @todo Extract subclass that overlays the children
@@ -183,6 +184,21 @@
}
else
{
+ return false;
+ }
+ }
+
+ /**
+ * Determines if this file is hidden.
+ */
+ protected boolean doIsHidden() throws FileSystemException
+ {
+ if ( file != null )
+ {
+ return file.isHidden();
+ }
+ else
+ {
return false;
}
}
1.33 +35 -0 jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java
Index: AbstractFileObject.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- AbstractFileObject.java 13 Oct 2003 08:44:26 -0000 1.32
+++ AbstractFileObject.java 17 Dec 2003 20:31:30 -0000 1.33
@@ -88,6 +88,7 @@
* (eg 'this file type does not support listing children', vs 'this is not a folder')
*
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @author Gary D. Gregory
* @version $Revision$ $Date$
*/
public abstract class AbstractFileObject
@@ -142,6 +143,17 @@
protected abstract FileType doGetType() throws Exception;
/**
+ * Determines if this file is hidden. Is only called if {@link #doGetType}
+ * does not return {@link FileType#IMAGINARY}.
+ *
+ * This implementation always returns false.
+ */
+ protected boolean doIsHidden() throws Exception
+ {
+ return false;
+ }
+
+ /**
* Determines if this file can be read. Is only called if {@link #doGetType}
* does not return {@link FileType#IMAGINARY}.
*
@@ -380,6 +392,29 @@
{
attach();
return type;
+ }
+
+ /**
+ * Determines if this file can be read.
+ */
+ public boolean isHidden() throws FileSystemException
+ {
+ try
+ {
+ attach();
+ if ( exists() )
+ {
+ return doIsHidden();
+ }
+ else
+ {
+ return false;
+ }
+ }
+ catch ( final Exception exc )
+ {
+ throw new FileSystemException( "vfs.provider/check-is-hidden.error", name, exc );
+ }
}
/**
1.12 +11 -3 jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/ProviderWriteTests.java
Index: ProviderWriteTests.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/test/org/apache/commons/vfs/test/ProviderWriteTests.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ProviderWriteTests.java 13 Oct 2003 08:42:27 -0000 1.11
+++ ProviderWriteTests.java 17 Dec 2003 20:31:31 -0000 1.12
@@ -153,7 +153,10 @@
assertTrue( file.exists() );
assertSame( FileType.FILE, file.getType() );
assertEquals( 0, file.getContent().getSize() );
-
+ assertFalse( file.isHidden() );
+ assertTrue( file.isReadable() );
+ assertTrue( file.isWriteable() );
+
// Create a descendant, where the intermediate folders don't exist
file = scratchFolder.resolveFile( "dir1/dir1/file1.txt" );
assertTrue( !file.exists() );
@@ -165,11 +168,16 @@
assertEquals( 0, file.getContent().getSize() );
assertTrue( file.getParent().exists() );
assertTrue( file.getParent().getParent().exists() );
-
+ assertFalse( file.getParent().isHidden() );
+ assertFalse( file.getParent().getParent().isHidden() );
+
// Test creating a file that already exists
assertTrue( file.exists() );
file.createFile();
- }
+ assertTrue( file.exists() );
+ assertTrue( file.isReadable() );
+ assertTrue( file.isWriteable() );
+ }
/**
* Tests file/folder creation with mismatched types.
1.12 +9 -0 jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/local/LocalFile.java
Index: LocalFile.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/local/LocalFile.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- LocalFile.java 13 Oct 2003 08:44:27 -0000 1.11
+++ LocalFile.java 17 Dec 2003 20:31:31 -0000 1.12
@@ -70,6 +70,7 @@
* A file object implementation which uses direct file access.
*
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @author Gary D. Gregory
* @version $Revision$ $Date$
*/
final class LocalFile
@@ -171,6 +172,14 @@
protected boolean doIsWriteable() throws FileSystemException
{
return file.canWrite();
+ }
+
+ /**
+ * Determines if this file is hidden.
+ */
+ protected boolean doIsHidden()
+ {
+ return file.isHidden();
}
/**
1.26 +3 -0 jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/Resources.properties
Index: Resources.properties
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/Resources.properties,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- Resources.properties 28 Jun 2003 10:50:38 -0000 1.25
+++ Resources.properties 17 Dec 2003 20:31:31 -0000 1.26
@@ -1,3 +1,5 @@
+# $Id$
+
# Factory
vfs/create-manager.error=Could not create a file system manager of class "{0}".
@@ -25,6 +27,7 @@
vfs.provider/copy-read-only.error=Could not copy {0} "{1}" to "{2}" because the destination file is read-only.
vfs.provider/copy-missing-file.error=Could not copy "{0}" because it does not exist.
vfs.provider/find-files.error=Could not find files in "{0}".
+vfs.provider/check-is-hidden.error=Could not determine if file "{0}" is hidden.
vfs.provider/check-is-writeable.error=Could not determine if file "{0}" is writeable.
vfs.provider/check-is-readable.error=Could not determine if file "{0}" is readable.
vfs.provider/get-url.error=Could not create URL for "{0}".
1.20 +11 -0 jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/FileObject.java
Index: FileObject.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/FileObject.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- FileObject.java 13 Oct 2003 08:45:23 -0000 1.19
+++ FileObject.java 17 Dec 2003 20:31:31 -0000 1.20
@@ -131,6 +131,17 @@
boolean exists() throws FileSystemException;
/**
+ * Determines if this file is hidden.
+ *
+ * @return
+ * <code>true</code> if this file is hidden, <code>false</code> if not.
+ *
+ * @throws FileSystemException
+ * On error determining if this file exists.
+ */
+ boolean isHidden() throws FileSystemException;
+
+ /**
* Determines if this file can be read.
*
* @return
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org