adammurdoch 2002/11/22 16:11:53
Modified: vfs/src/java/org/apache/commons/vfs FileSystem.java
vfs/src/java/org/apache/commons/vfs/provider
AbstractFileSystem.java
Log:
FileSystem changes:
- Added hasCapability(), which allows clients to query the capabilities of a file
system.
- Changed addJunction() and removeJunction() to represent junction points as String,
not FileName.
Revision Changes Path
1.8 +18 -4
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/FileSystem.java
Index: FileSystem.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/FileSystem.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FileSystem.java 17 Nov 2002 03:39:20 -0000 1.7
+++ FileSystem.java 23 Nov 2002 00:11:53 -0000 1.8
@@ -71,8 +71,22 @@
FileObject getRoot() throws FileSystemException;
/**
+ * Determines if this file system has a particular capability.
+ *
+ * @param capability The capability to check for.
+ *
+ * @return true if this filesystem has the requested capability.
+ * Note that not all files in the file system may have the
+ * capability.
+ *
+ * @todo Move this to another interface, so that set of capabilities can be
queried.
+ */
+ boolean hasCapability( Capability capability );
+
+ /**
* Returns the parent layer if this is a layered file system.
- * This returns null if this is not a layered file system.
+ *
+ * @return The parent layer, or null if this is not a layered file system.
*/
FileObject getParentLayer() throws FileSystemException;
@@ -166,7 +180,7 @@
* point or target file is invalid (the file system may not support
* nested junctions, for example).
*/
- void addJunction( FileName junctionPoint, FileObject targetFile )
+ void addJunction( String junctionPoint, FileObject targetFile )
throws FileSystemException;
/**
@@ -177,7 +191,7 @@
* @throws FileSystemException
* On error removing the junction.
*/
- void removeJuntion( FileName junctionPoint ) throws FileSystemException;
+ void removeJuntion( String junctionPoint ) throws FileSystemException;
/**
* Creates a temporary local copy of a file and its descendents. If
1.15 +33 -5
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileSystem.java
Index: AbstractFileSystem.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileSystem.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- AbstractFileSystem.java 17 Nov 2002 03:39:21 -0000 1.14
+++ AbstractFileSystem.java 23 Nov 2002 00:11:53 -0000 1.15
@@ -55,17 +55,20 @@
*/
package org.apache.commons.vfs.provider;
+import java.io.File;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
-import java.io.File;
+import org.apache.commons.vfs.Capability;
import org.apache.commons.vfs.FileChangeEvent;
import org.apache.commons.vfs.FileListener;
import org.apache.commons.vfs.FileName;
import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSelector;
import org.apache.commons.vfs.FileSystem;
import org.apache.commons.vfs.FileSystemException;
-import org.apache.commons.vfs.FileSelector;
import org.apache.commons.vfs.util.Messages;
/**
@@ -81,6 +84,7 @@
private final FileName rootName;
private FileObject parentLayer;
private FileObject root;
+ private final Collection caps = new HashSet();
/** Map from FileName to FileObject. */
private final Map files = new HashMap();
@@ -95,6 +99,17 @@
this.rootName = rootName;
}
+ /**
+ * Initialises this component.
+ */
+ public void init() throws FileSystemException
+ {
+ addCapabilities( caps );
+ }
+
+ /**
+ * Closes this component.
+ */
public void close()
{
// Clean-up
@@ -108,7 +123,12 @@
protected abstract FileObject createFile( final FileName name )
throws FileSystemException;
- /** Returns the name of the root of this file system. */
+ /**
+ * Adds the capabilities of this file system.
+ */
+ protected abstract void addCapabilities( Collection caps );
+
+ /** Returns the name of the root of this file system. */
protected FileName getRootName()
{
return rootName;
@@ -131,6 +151,14 @@
}
/**
+ * Determines if this file system has a particular capability.
+ */
+ public boolean hasCapability( final Capability capability )
+ {
+ return caps.contains( capability );
+ }
+
+ /**
* Retrieves the attribute with the specified name. The default
* implementation simply throws an exception.
*/
@@ -233,7 +261,7 @@
/**
* Adds a junction to this file system.
*/
- public void addJunction( final FileName junctionPoint,
+ public void addJunction( final String junctionPoint,
final FileObject targetFile )
throws FileSystemException
{
@@ -243,7 +271,7 @@
/**
* Removes a junction from this file system.
*/
- public void removeJuntion( final FileName junctionPoint ) throws
FileSystemException
+ public void removeJuntion( final String junctionPoint ) throws
FileSystemException
{
throw new FileSystemException(
"vfs.provider/junctions-not-supported.error", rootName );
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>