commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject svn commit: r159046 [1/2] - in jakarta/commons/sandbox/vfs/trunk: src/java/org/apache/commons/vfs/ src/java/org/apache/commons/vfs/impl/ src/java/org/apache/commons/vfs/provider/ src/java/org/apache/commons/vfs/provider/compressed/ src/java/org/apache/commons/vfs/provider/ftp/ src/java/org/apache/commons/vfs/provider/http/ src/java/org/apache/commons/vfs/provider/jar/ src/java/org/apache/commons/vfs/provider/local/ src/java/org/apache/commons/vfs/provider/sftp/ src/java/org/apache/commons/vfs/provider/smb/ src/java/org/apache/commons/vfs/provider/tar/ src/java/org/apache/commons/vfs/provider/temp/ src/java/org/apache/commons/vfs/provider/url/ src/java/org/apache/commons/vfs/provider/webdav/ src/java/org/apache/commons/vfs/provider/zip/ src/test/org/apache/commons/vfs/provider/smb/test/ src/test/org/apache/commons/vfs/provider/test/ src/test/org/apache/commons/vfs/test/ xdocs/
Date Fri, 25 Mar 2005 19:12:31 GMT
Author: imario
Date: Fri Mar 25 11:12:17 2005
New Revision: 159046

URL: http://svn.apache.org/viewcvs?view=rev&rev=159046
Log:
refactored filename parsing
tests passed, though manual testing needet

Now every FileProvider can handle its own set of reserved characters through the *FileNameParser.
This encoding is immediatley reflected in the FileName.


Added:
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileNameParser.java   (with props)
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/FileNameParser.java   (with props)
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileNameParser.java   (with props)
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileNameParser.java   (with props)
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileNameParser.java   (with props)
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileNameParser.java   (with props)
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileNameParser.java   (with props)
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpRandomAccessContent.java   (with props)
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileNameParser.java   (with props)
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileNameParser.java   (with props)
Modified:
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileName.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileSystemManager.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileReplicator.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultVfsComponentContext.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileSystem.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/providers.xml
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileProvider.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileSystem.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractLayeredFileProvider.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/BasicFileName.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/FileProvider.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/GenericFileName.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileName.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/UriParser.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/VfsComponentContext.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/compressed/CompressedFileFileProvider.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileProvider.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/jar/JarFileProvider.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/DefaultLocalFileProvider.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/GenericFileNameParser.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFile.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileNameParser.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileSystem.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileProvider.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileName.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileObject.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileProvider.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileSystem.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileName.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileObject.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileProvider.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileSystem.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/temp/TemporaryFileProvider.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/url/UrlFileName.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileProvider.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileName.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileProvider.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileSystem.java
    jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/provider/smb/test/FileNameTestCase.java
    jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/provider/test/GenericFileNameTestCase.java
    jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/AbstractProviderTestCase.java
    jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/AbstractTestSuite.java
    jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/ContentTests.java
    jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/NamingTests.java
    jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/ProviderWriteTests.java
    jakarta/commons/sandbox/vfs/trunk/src/test/org/apache/commons/vfs/test/UrlTests.java
    jakarta/commons/sandbox/vfs/trunk/xdocs/filesystems.xml
    jakarta/commons/sandbox/vfs/trunk/xdocs/index.xml

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileName.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileName.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileName.java Fri Mar 25 11:12:17 2005
@@ -64,6 +64,22 @@
     String getPath();
 
     /**
+     * Returns the absolute path of this file, within its file system.  This
+     * path is normalised, so that <code>.</code> and <code>..</code> elements
+     * have been removed.  Also, the path only contains <code>/</code> as its
+     * separator character.  The path always starts with <code>/</code>
+     * <p/>
+     * <p>The root of a file system has <code>/</code> as its absolute path.
+     * <p/>
+     * In contrast to {@link #getPath()} the path is decoded i.e. all %nn stuff
+     * replaced by its character.
+     *
+     * @return The path.  Never returns null.
+     * @throws FileSystemException if the path is not correctly encoded 
+     */
+    String getPathDecoded() throws FileSystemException;
+
+    /**
      * Returns the extension of this file name.
      *
      * @return The extension.  Returns an empty string if the name has no
@@ -110,7 +126,7 @@
      * @return A {@link FileName} object representing the resolved file name.
      * @throws FileSystemException If the name is invalid.
      */
-    FileName resolveName(String name) throws FileSystemException;
+    // FileName resolveName(String name) throws FileSystemException;
 
     /**
      * Resolves a name, relative to this file name.  Refer to {@link NameScope}
@@ -121,8 +137,8 @@
      * @return A {@link FileName} object representing the resolved file name.
      * @throws FileSystemException If the name is invalid.
      */
-    FileName resolveName(String name, NameScope scope)
-        throws FileSystemException;
+    // FileName resolveName(String name, NameScope scope)
+    //     throws FileSystemException;
 
     /**
      * Converts a file name to a relative name, relative to this file name.

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileSystemManager.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileSystemManager.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileSystemManager.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/FileSystemManager.java Fri Mar 25 11:12:17 2005
@@ -126,6 +126,30 @@
         throws FileSystemException;
 
     /**
+     * Resolves a name, relative to this file name.  Equivalent to calling
+     * <code>resolveName( path, NameScope.FILE_SYSTEM )</code>.
+     *
+     * @param root the base filename
+     * @param name The name to resolve.
+     * @return A {@link FileName} object representing the resolved file name.
+     * @throws FileSystemException If the name is invalid.
+     */
+    FileName resolveName(final FileName root, final String name) throws FileSystemException;
+
+    /**
+     * Resolves a name, relative to the "root" file name.  Refer to {@link NameScope}
+     * for a description of how names are resolved.
+     *
+     * @param root the base filename
+     * @param name  The name to resolve.
+     * @param scope The {@link NameScope} to use when resolving the name.
+     * @return A {@link FileName} object representing the resolved file name.
+     * @throws FileSystemException If the name is invalid.
+     */
+    FileName resolveName(final FileName root, String name, NameScope scope)
+        throws FileSystemException;
+
+    /**
      * Converts a local file into a {@link FileObject}.
      *
      * @param file The file to convert.
@@ -226,4 +250,6 @@
      * @throws FileSystemException if the given scheme is not konwn
      */
     public FileSystemConfigBuilder getFileSystemConfigBuilder(final String scheme) throws FileSystemException;
+
+    public FileName resolveURI(String uri) throws FileSystemException;
 }

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties Fri Mar 25 11:12:17 2005
@@ -88,6 +88,9 @@
 vfs.provider/replicate-file.error=Could not replicate "{0}".
 vfs.provider/resolve-file.error=Could not resolve file "{0}".
 
+# AbstractFileProvider
+vfs.provider/filename-parser-missing.error=No filename-parser implementation set.
+
 # RandomAccess
 vfs.provider/random-access-invalid-position.error=Invalid position: "{0}"
 vfs.provider/random-access-open-failed.error=Could not access file "{0}" because it does not exist.

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileReplicator.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileReplicator.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileReplicator.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileReplicator.java Fri Mar 25 11:12:17 2005
@@ -25,6 +25,7 @@
 import org.apache.commons.vfs.provider.AbstractVfsComponent;
 import org.apache.commons.vfs.provider.FileReplicator;
 import org.apache.commons.vfs.provider.TemporaryFileStore;
+import org.apache.commons.vfs.provider.UriParser;
 import org.apache.commons.vfs.util.Messages;
 
 import java.io.File;
@@ -107,7 +108,7 @@
     /**
      * Allocates a new temporary file.
      */
-    public File allocateFile(final String baseName)
+    public File allocateFile(final String baseName) throws FileSystemException
     {
         // Create a unique-ish file name
         final String basename = createFilename(baseName);
@@ -138,9 +139,9 @@
     /**
      * create the temporary file
      */
-    protected File createFile(final File parent, final String name)
+    protected File createFile(final File parent, final String name) throws FileSystemException
     {
-        return new File(parent, name);
+        return new File(parent, UriParser.decode(name));
     }
 
     /**

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java Fri Mar 25 11:12:17 2005
@@ -17,6 +17,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.vfs.FileContentInfoFactory;
+import org.apache.commons.vfs.FileName;
 import org.apache.commons.vfs.FileObject;
 import org.apache.commons.vfs.FileSystem;
 import org.apache.commons.vfs.FileSystemConfigBuilder;
@@ -24,7 +25,9 @@
 import org.apache.commons.vfs.FileSystemManager;
 import org.apache.commons.vfs.FileSystemOptions;
 import org.apache.commons.vfs.FilesCache;
+import org.apache.commons.vfs.NameScope;
 import org.apache.commons.vfs.cache.SoftRefFilesCache;
+import org.apache.commons.vfs.provider.AbstractFileName;
 import org.apache.commons.vfs.provider.AbstractFileProvider;
 import org.apache.commons.vfs.provider.DefaultURLStreamHandler;
 import org.apache.commons.vfs.provider.FileProvider;
@@ -489,6 +492,11 @@
     public FileObject resolveFile(final FileObject baseFile, final String uri, final FileSystemOptions fileSystemOptions)
         throws FileSystemException
     {
+        // TODO: use resolveName and use this name to resolve the fileObject
+
+
+        UriParser.checkUriEncoding(uri);
+
         if (uri == null)
         {
             throw new IllegalArgumentException();
@@ -504,19 +512,117 @@
             {
                 return provider.findFile(baseFile, uri, fileSystemOptions);
             }
-
 // Otherwise, assume a local file
         }
 
+// Handle absolute file names
+        if (localFileProvider != null
+            && localFileProvider.isAbsoluteLocalName(uri))
+        {
+            return localFileProvider.findLocalFile(uri);
+        }
+
+        if (scheme != null)
+        {
+// An unknown scheme - hand it to the default provider
+            if (defaultProvider == null)
+            {
+                throw new FileSystemException("vfs.impl/unknown-scheme.error", new Object[]{scheme, uri});
+            }
+            return defaultProvider.findFile(baseFile, uri, fileSystemOptions);
+        }
+
+// Assume a relative name - use the supplied base file
+        if (baseFile == null)
+        {
+            throw new FileSystemException("vfs.impl/find-rel-file.error", uri);
+        }
+
+        return baseFile.resolveFile(uri);
+    }
+
+    /**
+     * Resolves a name, relative to the file.  If the supplied name is an
+     * absolute path, then it is resolved relative to the root of the
+     * file system that the file belongs to.  If a relative name is supplied,
+     * then it is resolved relative to this file name.
+     */
+    public FileName resolveName(final FileName root, final String path) throws FileSystemException
+    {
+        return resolveName(root, path, NameScope.FILE_SYSTEM);
+    }
+
+    /**
+     * Resolves a name, relative to the root.
+     *
+     * @param root the base filename
+     * @param name the name
+     * @param scope the {@link NameScope}
+     * @return
+     * @throws FileSystemException
+     */
+    public FileName resolveName(final FileName root,
+                                final String name,
+                                final NameScope scope)
+        throws FileSystemException
+    {
+        final StringBuffer buffer = new StringBuffer(name);
+
+        // Adjust separators
+        UriParser.fixSeparators(buffer);
+
+        // Determine whether to prepend the base path
+        if (name.length() == 0 || name.charAt(0) != FileName.SEPARATOR_CHAR)
+        {
+            // Supplied path is not absolute
+            buffer.insert(0, FileName.SEPARATOR_CHAR);
+            buffer.insert(0, root.getPath());
+        }
+
+        //// UriParser.canonicalizePath(buffer, 0, name.length());
+
+        // Normalise the path
+        UriParser.normalisePath(buffer);
+
+        // Check the name is ok
+        final String resolvedPath = buffer.toString();
+        if (!AbstractFileName.checkName(root.getPath(), resolvedPath, scope))
+        {
+            throw new FileSystemException("vfs.provider/invalid-descendent-name.error", name);
+        }
+
+        // todo: pass this down to the fileProvider
+        return ((AbstractFileName) root).createName(resolvedPath);
+    }
+
+    public FileName resolveURI(String uri) throws FileSystemException
+    {
+        UriParser.checkUriEncoding(uri);
+
+        if (uri == null)
+        {
+            throw new IllegalArgumentException();
+        }
+
+// Extract the scheme
+        final String scheme = UriParser.extractScheme(uri);
+        if (scheme != null)
+        {
+// An absolute URI - locate the provider
+            final FileProvider provider = (FileProvider) providers.get(scheme);
+            if (provider != null)
+            {
+                return provider.parseUri(scheme, uri);
+            }
 
-// Decode the URI (remove %nn encodings)
-        final String decodedUri = UriParser.decode(uri);
+// Otherwise, assume a local file
+        }
 
 // Handle absolute file names
         if (localFileProvider != null
-            && localFileProvider.isAbsoluteLocalName(decodedUri))
+            && localFileProvider.isAbsoluteLocalName(uri))
         {
-            return localFileProvider.findLocalFile(decodedUri);
+            return localFileProvider.parseUri(null, uri);
         }
 
         if (scheme != null)
@@ -526,7 +632,7 @@
             {
                 throw new FileSystemException("vfs.impl/unknown-scheme.error", new Object[]{scheme, uri});
             }
-            return defaultProvider.findFile(baseFile, uri, fileSystemOptions);
+            return defaultProvider.parseUri(null, uri);
         }
 
 // Assume a relative name - use the supplied base file
@@ -535,7 +641,7 @@
             throw new FileSystemException("vfs.impl/find-rel-file.error", uri);
         }
 
-        return baseFile.resolveFile(decodedUri);
+        return resolveName(baseFile.getName(), uri, NameScope.FILE_SYSTEM);
     }
 
     /**

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultVfsComponentContext.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultVfsComponentContext.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultVfsComponentContext.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultVfsComponentContext.java Fri Mar 25 11:12:17 2005
@@ -19,6 +19,7 @@
 import org.apache.commons.vfs.FileSystemException;
 import org.apache.commons.vfs.FileSystemManager;
 import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.FileName;
 import org.apache.commons.vfs.provider.FileReplicator;
 import org.apache.commons.vfs.provider.TemporaryFileStore;
 import org.apache.commons.vfs.provider.VfsComponentContext;
@@ -58,6 +59,11 @@
         throws FileSystemException
     {
         return manager.resolveFile(name, fileSystemOptions);
+    }
+
+    public FileName parseURI(String uri) throws FileSystemException
+    {
+        return manager.resolveURI(uri);
     }
 
     /**

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileSystem.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileSystem.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileSystem.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileSystem.java Fri Mar 25 11:12:17 2005
@@ -101,7 +101,7 @@
                             final FileObject targetFile)
         throws FileSystemException
     {
-        final FileName junctionName = getRootName().resolveName(junctionPoint);
+        final FileName junctionName = getFileSystemManager().resolveName(getRootName(), junctionPoint);
 
         // Check for nested junction - these are not supported yet
         if (getJunctionForFile(junctionName) != null)
@@ -155,7 +155,7 @@
     public void removeJunction(final String junctionPoint)
         throws FileSystemException
     {
-        final FileName junctionName = getRootName().resolveName(junctionPoint);
+        final FileName junctionName = getFileSystemManager().resolveName(getRootName(), junctionPoint);
         junctions.remove(junctionName);
 
         // TODO - remove from parents of junction point

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/providers.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/providers.xml?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/providers.xml (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/impl/providers.xml Fri Mar 25 11:12:17 2005
@@ -28,7 +28,7 @@
     </provider>
     <provider class-name="org.apache.commons.vfs.provider.ftp.FtpFileProvider">
         <scheme name="ftp"/>
-        <if-available class-name="org.apache.commons.net.ftp.FTPFile"/>
+        <if-available class-name="org.apache.commons.net.ftp.FTPFileX"/>
     </provider>
     <provider class-name="org.apache.commons.vfs.provider.smb.SmbFileProvider">
         <scheme name="smb"/>

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java Fri Mar 25 11:12:17 2005
@@ -36,6 +36,7 @@
     private String baseName;
     private String rootUri;
     private String extension;
+    private String decodedAbsPath;
 
     public AbstractFileName(final String scheme,
                             final String absPath)
@@ -56,7 +57,7 @@
      */
     public int hashCode()
     {
-        return (getRootURI().hashCode() ^ absPath.hashCode());
+        return (getRootURI().hashCode() ^ getPath().hashCode());
     }
 
     /**
@@ -65,7 +66,7 @@
     public boolean equals(final Object obj)
     {
         final AbstractFileName name = (AbstractFileName) obj;
-        return (getRootURI().equals(name.getRootURI()) && absPath.equals(name.absPath));
+        return (getRootURI().equals(name.getRootURI()) && getPath().equals(name.getPath()));
     }
 
     /**
@@ -83,7 +84,15 @@
             return ret;
         }
 
-        return absPath.compareTo(name.absPath);
+        // return absPath.compareTo(name.absPath);
+        try
+        {
+            return getPathDecoded().compareTo(name.getPathDecoded());
+        }
+        catch (FileSystemException e)
+        {
+            throw new RuntimeException(e.getMessage());
+        }
     }
 
     /**
@@ -97,7 +106,7 @@
     /**
      * Factory method for creating name instances.
      */
-    protected abstract FileName createName(String absPath);
+    public abstract FileName createName(String absPath);
 
     /**
      * Builds the root URI for this file name.  Note that the root URI must not
@@ -112,14 +121,14 @@
     {
         if (baseName == null)
         {
-            final int idx = absPath.lastIndexOf(SEPARATOR_CHAR);
+            final int idx = getPath().lastIndexOf(SEPARATOR_CHAR);
             if (idx == -1)
             {
-                baseName = absPath;
+                baseName = getPath();
             }
             else
             {
-                baseName = absPath.substring(idx + 1);
+                baseName = getPath().substring(idx + 1);
             }
         }
 
@@ -135,37 +144,14 @@
         return absPath;
     }
 
-    /**
-     * Resolves a name, relative to this file name.
-     */
-    public FileName resolveName(final String name,
-                                final NameScope scope)
-        throws FileSystemException
+    public String getPathDecoded() throws FileSystemException
     {
-        final StringBuffer buffer = new StringBuffer(name);
-
-        // Adjust separators
-        UriParser.fixSeparators(buffer);
-
-        // Determine whether to prepend the base path
-        if (name.length() == 0 || name.charAt(0) != SEPARATOR_CHAR)
+        if (decodedAbsPath == null)
         {
-            // Supplied path is not absolute
-            buffer.insert(0, SEPARATOR_CHAR);
-            buffer.insert(0, absPath);
+            decodedAbsPath = UriParser.decode(absPath);
         }
 
-        // Normalise the path
-        UriParser.normalisePath(buffer);
-
-        // Check the name is ok
-        final String resolvedPath = buffer.toString();
-        if (!checkName(absPath, resolvedPath, scope))
-        {
-            throw new FileSystemException("vfs.provider/invalid-descendent-name.error", name);
-        }
-
-        return createName(resolvedPath);
+        return decodedAbsPath;
     }
 
     /**
@@ -174,8 +160,8 @@
     public FileName getParent()
     {
         final String parentPath;
-        final int idx = absPath.lastIndexOf(SEPARATOR_CHAR);
-        if (idx == -1 || idx == absPath.length() - 1)
+        final int idx = getPath().lastIndexOf(SEPARATOR_CHAR);
+        if (idx == -1 || idx == getPath().length() - 1)
         {
             // No parent
             return null;
@@ -187,23 +173,12 @@
         }
         else
         {
-            parentPath = absPath.substring(0, idx);
+            parentPath = getPath().substring(0, idx);
         }
         return createName(parentPath);
     }
 
     /**
-     * Resolves a name, relative to the file.  If the supplied name is an
-     * absolute path, then it is resolved relative to the root of the
-     * file system that the file belongs to.  If a relative name is supplied,
-     * then it is resolved relative to this file name.
-     */
-    public FileName resolveName(final String path) throws FileSystemException
-    {
-        return resolveName(path, NameScope.FILE_SYSTEM);
-    }
-
-    /**
      * Returns the URI scheme of this file.
      */
     public String getScheme()
@@ -220,7 +195,7 @@
         {
             final StringBuffer buffer = new StringBuffer();
             appendRootUri(buffer);
-            buffer.append(absPath);
+            buffer.append(getPath());
             uri = buffer.toString();
         }
         return uri;
@@ -234,7 +209,7 @@
         final String path = name.getPath();
 
         // Calculate the common prefix
-        final int basePathLen = absPath.length();
+        final int basePathLen = getPath().length();
         final int pathLen = path.length();
 
         // Deal with root
@@ -249,7 +224,7 @@
 
         final int maxlen = Math.min(basePathLen, pathLen);
         int pos = 0;
-        for (; pos < maxlen && absPath.charAt(pos) == path.charAt(pos); pos++)
+        for (; pos < maxlen && getPath().charAt(pos) == path.charAt(pos); pos++)
         {
         }
 
@@ -266,21 +241,21 @@
 
         // Strip the common prefix off the path
         final StringBuffer buffer = new StringBuffer();
-        if (pathLen > 1 && (pos < pathLen || absPath.charAt(pos) != SEPARATOR_CHAR))
+        if (pathLen > 1 && (pos < pathLen || getPath().charAt(pos) != SEPARATOR_CHAR))
         {
             // Not a direct ancestor, need to back up
-            pos = absPath.lastIndexOf(SEPARATOR_CHAR, pos);
+            pos = getPath().lastIndexOf(SEPARATOR_CHAR, pos);
             buffer.append(path.substring(pos));
         }
 
         // Prepend a '../' for each element in the base path past the common
         // prefix
         buffer.insert(0, "..");
-        pos = absPath.indexOf(SEPARATOR_CHAR, pos + 1);
+        pos = getPath().indexOf(SEPARATOR_CHAR, pos + 1);
         while (pos != -1)
         {
             buffer.insert(0, "../");
-            pos = absPath.indexOf(SEPARATOR_CHAR, pos + 1);
+            pos = getPath().indexOf(SEPARATOR_CHAR, pos + 1);
         }
 
         return buffer.toString();
@@ -306,15 +281,15 @@
      */
     public int getDepth()
     {
-        final int len = absPath.length();
-        if (len == 0 || (len == 1 && absPath.charAt(0) == SEPARATOR_CHAR))
+        final int len = getPath().length();
+        if (len == 0 || (len == 1 && getPath().charAt(0) == SEPARATOR_CHAR))
         {
             return 0;
         }
         int depth = 1;
         for (int pos = 0; pos > -1 && pos < len; depth++)
         {
-            pos = absPath.indexOf(SEPARATOR_CHAR, pos + 1);
+            pos = getPath().indexOf(SEPARATOR_CHAR, pos + 1);
         }
         return depth;
     }
@@ -355,7 +330,7 @@
         {
             return false;
         }
-        return checkName(ancestor.getPath(), absPath, NameScope.DESCENDENT);
+        return checkName(ancestor.getPath(), getPath(), NameScope.DESCENDENT);
     }
 
     /**
@@ -376,7 +351,7 @@
         {
             return false;
         }
-        return checkName(absPath, descendent.getPath(), scope);
+        return checkName(getPath(), descendent.getPath(), scope);
     }
 
     /**
@@ -385,7 +360,7 @@
      * @param basePath An absolute, normalised path.
      * @param path     An absolute, normalised path.
      */
-    private boolean checkName(final String basePath,
+    public static boolean checkName(final String basePath,
                               final String path,
                               final NameScope scope)
     {

Added: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileNameParser.java?view=auto&rev=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileNameParser.java (added)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileNameParser.java Fri Mar 25 11:12:17 2005
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2002, 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider;
+
+/**
+ * Provides methods to parse a filename into a {@link org.apache.commons.vfs.FileName}
+ */
+public abstract class AbstractFileNameParser implements FileNameParser
+{
+    public boolean encodeCharacter(char ch)
+    {
+        return ch == '%';
+    }
+}

Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileNameParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileNameParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileNameParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java Fri Mar 25 11:12:17 2005
@@ -566,7 +566,8 @@
                 {
                     final String file = files[i];
                     // children[i] = fs.resolveFile(name.resolveName(file, NameScope.CHILD));
-                    children[i] = name.resolveName(file, NameScope.CHILD);
+                    // children[i] = name.resolveName(file, NameScope.CHILD);
+                    children[i] = getFileSystem().getFileSystemManager().resolveName(name, file, NameScope.CHILD);
                 }
             }
 
@@ -638,7 +639,8 @@
     public FileObject resolveFile(final String name, final NameScope scope)
         throws FileSystemException
     {
-        return fs.resolveFile(this.name.resolveName(name, scope));
+        // return fs.resolveFile(this.name.resolveName(name, scope));
+        return fs.resolveFile(getFileSystem().getFileSystemManager().resolveName(this.name, name, scope));
     }
 
     /**
@@ -651,7 +653,7 @@
      */
     public FileObject resolveFile(final String path) throws FileSystemException
     {
-        final FileName otherName = name.resolveName(path);
+        final FileName otherName = getFileSystem().getFileSystemManager().resolveName(name, path);
         return fs.resolveFile(otherName);
     }
 

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileProvider.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileProvider.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileProvider.java Fri Mar 25 11:12:17 2005
@@ -20,6 +20,8 @@
 import org.apache.commons.vfs.FileSystemConfigBuilder;
 import org.apache.commons.vfs.FileSystemException;
 import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.provider.local.GenericFileNameParser;
 
 import java.util.Iterator;
 import java.util.Map;
@@ -36,8 +38,21 @@
     extends AbstractVfsContainer
     implements FileProvider
 {
+    private FileNameParser parser;
+
     public AbstractFileProvider()
     {
+        parser = GenericFileNameParser.getInstance();
+    }
+
+    protected FileNameParser getFileNameParser()
+    {
+        return parser;
+    }
+
+    protected void setFileNameParser(FileNameParser parser)
+    {
+        this.parser = parser;
     }
 
     /**
@@ -133,5 +148,22 @@
             removeComponent(fileSystems);
             fs.close();
         }
+    }
+
+    /**
+     * Parses an absolute URI.
+     *
+     * @param schme
+     * @param uri The URI to parse.
+     */
+    public FileName parseUri(String schme, String uri) throws FileSystemException
+    {
+        if (getFileNameParser() != null)
+        {
+            return getFileNameParser().parseUri(getContext(), uri);
+        }
+
+        throw new FileSystemException("vfs.provider/filename-parser-missing.error");
+        // return GenericFileName.parseUri(getFileNameParser(), uri, 0);
     }
 }

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileSystem.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileSystem.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileSystem.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileSystem.java Fri Mar 25 11:12:17 2005
@@ -244,7 +244,7 @@
     public FileObject resolveFile(final String nameStr) throws FileSystemException
     {
         // Resolve the name, and create the file
-        final FileName name = rootName.resolveName(nameStr);
+        final FileName name = getFileSystemManager().resolveName(rootName, nameStr);
         return resolveFile(name);
     }
 

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractLayeredFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractLayeredFileProvider.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractLayeredFileProvider.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractLayeredFileProvider.java Fri Mar 25 11:12:17 2005
@@ -35,6 +35,7 @@
     public AbstractLayeredFileProvider()
     {
         super();
+        setFileNameParser(LayeredFileNameParser.getInstance());
     }
 
     /**
@@ -45,13 +46,13 @@
                                final FileSystemOptions properties) throws FileSystemException
     {
         // Split the URI up into its parts
-        final LayeredFileName name = (LayeredFileName) parseUri(uri);
+        final LayeredFileName name = (LayeredFileName) parseUri(baseFile!=null?baseFile.getName().getScheme():null, uri);
 
         // Make the URI canonical
 
         // Resolve the outer file name
-        final String fileName = name.getOuterUri();
-        final FileObject file = getContext().resolveFile(baseFile, fileName, properties);
+        final FileName fileName = name.getOuterName();
+        final FileObject file = getContext().resolveFile(baseFile, fileName.getURI(), properties);
 
         // Create the file system
         final FileObject rootFile = createFileSystem(name.getScheme(), file, properties);
@@ -93,11 +94,4 @@
                                                      final FileSystemOptions fileSystemOptions)
         throws FileSystemException;
 
-    /**
-     * Parses an absolute URI.
-     *
-     * @param uri The URI to parse.
-     */
-    protected abstract FileName parseUri(String uri)
-        throws FileSystemException;
 }

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java Fri Mar 25 11:12:17 2005
@@ -50,7 +50,7 @@
         final FileName name;
         try
         {
-            name = parseUri(uri);
+            name = parseUri(baseFile!=null?baseFile.getName().getScheme():null, uri);
         }
         catch (FileSystemException exc)
         {
@@ -68,7 +68,7 @@
         throws FileSystemException
     {
         // Check in the cache for the file system
-        final FileName rootName = name.resolveName(FileName.ROOT_PATH);
+        final FileName rootName = getContext().getFileSystemManager().resolveName(name, FileName.ROOT_PATH);
         FileSystem fs = findFileSystem(rootName, fileSystemOptions);
         if (fs == null)
         {
@@ -80,16 +80,6 @@
         // Locate the file
         return fs.resolveFile(name.getPath());
     }
-
-    /**
-     * Parses an absolute URI.
-     *
-     * @return The name of the file.  This name is used to locate the file
-     *         system in the cache, using the root URI.  This name is also
-     *         passed to {@link #doCreateFileSystem} to create the file system.
-     */
-    protected abstract FileName parseUri(final String uri)
-        throws FileSystemException;
 
     /**
      * Creates a {@link FileSystem}.  If the returned FileSystem implements

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/BasicFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/BasicFileName.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/BasicFileName.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/BasicFileName.java Fri Mar 25 11:12:17 2005
@@ -72,7 +72,7 @@
     /**
      * Factory method for creating name instances.
      */
-    protected FileName createName(final String path)
+    public FileName createName(final String path)
     {
         return new BasicFileName(getScheme(), rootUri, path, true);
     }

Added: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/FileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/FileNameParser.java?view=auto&rev=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/FileNameParser.java (added)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/FileNameParser.java Fri Mar 25 11:12:17 2005
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2002, 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider;
+
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileSystemException;
+
+/**
+ * Provides methods to parse a filename into a {@link org.apache.commons.vfs.FileName}
+ */
+public interface FileNameParser
+{
+    /**
+     * Check if a character needs encoding (%nn)
+     * @param ch the character
+     * @return true if character should be encoded
+     */
+    public boolean encodeCharacter(char ch);
+
+    /**
+     * parses a String into a filename
+     * @param filename
+     * @return
+     * @throws org.apache.commons.vfs.FileSystemException
+     */
+    public FileName parseUri(final VfsComponentContext context, final String filename) throws FileSystemException;
+}

Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/FileNameParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/FileNameParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/FileNameParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/FileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/FileProvider.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/FileProvider.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/FileProvider.java Fri Mar 25 11:12:17 2005
@@ -19,6 +19,7 @@
 import org.apache.commons.vfs.FileSystemConfigBuilder;
 import org.apache.commons.vfs.FileSystemException;
 import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.FileName;
 
 import java.util.Collection;
 
@@ -66,4 +67,6 @@
      * instanciated.
      */
     public Collection getCapabilities();
+
+    public FileName parseUri(String schme, String uri) throws FileSystemException;
 }

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/GenericFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/GenericFileName.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/GenericFileName.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/GenericFileName.java Fri Mar 25 11:12:17 2005
@@ -16,7 +16,6 @@
 package org.apache.commons.vfs.provider;
 
 import org.apache.commons.vfs.FileName;
-import org.apache.commons.vfs.FileSystemException;
 
 /**
  * A file name that represents a 'generic' URI, as per RFC 2396.  Consists of
@@ -103,7 +102,7 @@
     /**
      * Factory method for creating name instances.
      */
-    protected FileName createName(final String absPath)
+    public FileName createName(final String absPath)
     {
         return new GenericFileName(getScheme(),
             hostName,
@@ -115,192 +114,6 @@
     }
 
     /**
-     * Parses a generic URI.
-     */
-    public static GenericFileName parseUri(final String uri,
-                                           final int defaultPort)
-        throws FileSystemException
-    {
-        // FTP URI are generic URI (as per RFC 2396)
-        final StringBuffer name = new StringBuffer();
-
-        // Extract the scheme and authority parts
-        final Authority auth = extractToPath(uri, name);
-
-        // Decode and normalise the file name
-        UriParser.decode(name, 0, name.length());
-        UriParser.normalisePath(name);
-        final String path = name.toString();
-
-        return new GenericFileName(auth.scheme,
-            auth.hostName,
-            auth.port,
-            defaultPort,
-            auth.userName,
-            auth.password,
-            path);
-    }
-
-    /**
-     * Extracts the scheme, userinfo, hostname and port components of a
-     * generic URI.
-     *
-     * @param uri  The absolute URI to parse.
-     * @param name Used to return the remainder of the URI.
-     */
-    protected static Authority extractToPath(final String uri,
-                                             final StringBuffer name)
-        throws FileSystemException
-    {
-        final Authority auth = new Authority();
-
-        // Extract the scheme
-        auth.scheme = UriParser.extractScheme(uri, name);
-
-        // Expecting "//"
-        if (name.length() < 2 || name.charAt(0) != '/' || name.charAt(1) != '/')
-        {
-            throw new FileSystemException("vfs.provider/missing-double-slashes.error", uri);
-        }
-        name.delete(0, 2);
-
-        // Extract userinfo, and split into username and password
-        final String userInfo = extractUserInfo(name);
-        final String userName;
-        final String password;
-        if (userInfo != null)
-        {
-            int idx = userInfo.indexOf(':');
-            if (idx == -1)
-            {
-                userName = userInfo;
-                password = null;
-            }
-            else
-            {
-                userName = userInfo.substring(0, idx);
-                password = userInfo.substring(idx + 1);
-            }
-        }
-        else
-        {
-            userName = null;
-            password = null;
-        }
-        auth.userName = UriParser.decode(userName);
-        auth.password = UriParser.decode(password);
-
-        // Extract hostname, and normalise (lowercase)
-        final String hostName = extractHostName(name);
-        if (hostName == null)
-        {
-            throw new FileSystemException("vfs.provider/missing-hostname.error", uri);
-        }
-        auth.hostName = hostName.toLowerCase();
-
-        // Extract port
-        auth.port = extractPort(name, uri);
-
-        // Expecting '/' or empty name
-        if (name.length() > 0 && name.charAt(0) != '/')
-        {
-            throw new FileSystemException("vfs.provider/missing-hostname-path-sep.error", uri);
-        }
-
-        return auth;
-    }
-
-    /**
-     * Extracts the user info from a URI.  The scheme:// part has been removed
-     * already.
-     */
-    protected static String extractUserInfo(final StringBuffer name)
-    {
-        final int maxlen = name.length();
-        for (int pos = 0; pos < maxlen; pos++)
-        {
-            final char ch = name.charAt(pos);
-            if (ch == '@')
-            {
-                // Found the end of the user info
-                String userInfo = name.substring(0, pos);
-                name.delete(0, pos + 1);
-                return userInfo;
-            }
-            if (ch == '/' || ch == '?')
-            {
-                // Not allowed in user info
-                break;
-            }
-        }
-
-        // Not found
-        return null;
-    }
-
-    /**
-     * Extracts the hostname from a URI.  The scheme://userinfo@ part has
-     * been removed.
-     */
-    protected static String extractHostName(final StringBuffer name)
-    {
-        final int maxlen = name.length();
-        int pos = 0;
-        for (; pos < maxlen; pos++)
-        {
-            final char ch = name.charAt(pos);
-            if (ch == '/' || ch == ';' || ch == '?' || ch == ':'
-                || ch == '@' || ch == '&' || ch == '=' || ch == '+'
-                || ch == '$' || ch == ',')
-            {
-                break;
-            }
-        }
-        if (pos == 0)
-        {
-            return null;
-        }
-
-        final String hostname = name.substring(0, pos);
-        name.delete(0, pos);
-        return hostname;
-    }
-
-    /**
-     * Extracts the port from a URI.  The scheme://userinfo@hostname
-     * part has been removed.
-     *
-     * @return The port, or -1 if the URI does not contain a port.
-     */
-    private static int extractPort(final StringBuffer name, final String uri) throws FileSystemException
-    {
-        if (name.length() < 1 || name.charAt(0) != ':')
-        {
-            return -1;
-        }
-
-        final int maxlen = name.length();
-        int pos = 1;
-        for (; pos < maxlen; pos++)
-        {
-            final char ch = name.charAt(pos);
-            if (ch < '0' || ch > '9')
-            {
-                break;
-            }
-        }
-
-        final String port = name.substring(1, pos);
-        name.delete(0, pos);
-        if (port.length() == 0)
-        {
-            throw new FileSystemException("vfs.provider/missing-port.error", uri);
-        }
-
-        return Integer.parseInt(port);
-    }
-
-    /**
      * Builds the root URI for this file name.
      */
     protected void appendRootUri(final StringBuffer buffer)
@@ -323,17 +136,5 @@
             buffer.append(':');
             buffer.append(port);
         }
-    }
-
-    /**
-     * Parsed authority info (scheme, hostname, userinfo, port)
-     */
-    protected static class Authority
-    {
-        public String scheme;
-        public String hostName;
-        public String userName;
-        public String password;
-        public int port;
     }
 }

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileName.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileName.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileName.java Fri Mar 25 11:12:17 2005
@@ -15,20 +15,22 @@
  */
 package org.apache.commons.vfs.provider;
 
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileName;
+
 /**
  * A file name for layered files.
  *
  * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  * @version $Revision$ $Date$
  */
-public abstract class LayeredFileName
-    extends AbstractFileName
+public class LayeredFileName extends AbstractFileName
 {
-    private final String outerUri;
+    private final FileName outerUri;
 
-    protected LayeredFileName(final String scheme,
-                              final String outerUri,
-                              final String path)
+    public LayeredFileName(final String scheme,
+                           final FileName outerUri,
+                           final String path)
     {
         super(scheme, path);
         this.outerUri = outerUri;
@@ -37,8 +39,21 @@
     /**
      * Returns the URI of the outer file.
      */
-    public String getOuterUri()
+    public FileName getOuterName()
     {
         return outerUri;
+    }
+
+    public FileName createName(String path)
+    {
+        return new LayeredFileName(getScheme(), getOuterName(), path);
+    }
+
+    protected void appendRootUri(StringBuffer buffer)
+    {
+        buffer.append(getScheme());
+        buffer.append(":");
+        buffer.append(getOuterName().getURI());
+        buffer.append("!");
     }
 }

Added: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileNameParser.java?view=auto&rev=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileNameParser.java (added)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileNameParser.java Fri Mar 25 11:12:17 2005
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2002, 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider;
+
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileSystemException;
+
+/**
+ * Implementation for layered filesystems.
+ * <p/>
+ * Additionally encodes the '!' character.
+ */
+public class LayeredFileNameParser extends AbstractFileNameParser
+{
+    private final static LayeredFileNameParser INSTANCE = new LayeredFileNameParser();
+
+    public static LayeredFileNameParser getInstance()
+    {
+        return INSTANCE;
+    }
+
+    public boolean encodeCharacter(char ch)
+    {
+        return super.encodeCharacter(ch) || ch == '!';
+    }
+
+    public FileName parseUri(final VfsComponentContext context, final String filename) throws FileSystemException
+    {
+        final StringBuffer name = new StringBuffer();
+
+        // Extract the scheme
+        final String scheme = UriParser.extractScheme(filename, name);
+
+        // Extract the Layered file URI
+        final String rootUriName = extractRootName(name);
+        FileName rootUri = null;
+        if (rootUriName != null)
+        {
+            rootUri = context.parseURI(rootUriName);
+        }
+
+        // Decode and normalise the path
+        UriParser.canonicalizePath(name, 0, name.length(), this);
+        UriParser.normalisePath(name);
+        final String path = name.toString();
+
+        return new LayeredFileName(scheme, rootUri, path);
+    }
+
+    /**
+     * Pops the root prefix off a URI, which has had the scheme removed.
+     */
+    protected String extractRootName(final StringBuffer uri)
+        throws FileSystemException
+    {
+        // Looking for <name>!<abspath> (staring at the end)
+        int maxlen = uri.length();
+        int pos = maxlen-1;
+        for (; pos > 0 && uri.charAt(pos) != '!'; pos--)
+        {
+        }
+
+        // Extract the name
+        String prefix = uri.substring(0, pos);
+        if (pos < maxlen)
+        {
+            uri.delete(0, pos + 1);
+        }
+        else
+        {
+            uri.setLength(0);
+        }
+
+        return prefix;
+    }
+
+}

Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileNameParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileNameParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileNameParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileNameParser.java?view=auto&rev=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileNameParser.java (added)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileNameParser.java Fri Mar 25 11:12:17 2005
@@ -0,0 +1,233 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider;
+
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileSystemException;
+
+/**
+ * Implementation for the webdav filesystem.
+ * < p/>
+ * Additionally encodes every character below space (' ')
+ */
+public class URLFileNameParser extends AbstractFileNameParser
+{
+    private final int defaultPort;
+
+    public URLFileNameParser(final int defaultPort)
+    {
+        this.defaultPort = defaultPort;
+    }
+
+    public int getDefaultPort()
+    {
+        return defaultPort;
+    }
+
+    public FileName parseUri(final VfsComponentContext context, final String filename) throws FileSystemException
+    {
+        // FTP URI are generic URI (as per RFC 2396)
+        final StringBuffer name = new StringBuffer();
+
+        // Extract the scheme and authority parts
+        final Authority auth = extractToPath(filename, name);
+
+        // Decode and normalise the file name
+        UriParser.canonicalizePath(name, 0, name.length(), this);
+        UriParser.normalisePath(name);
+        final String path = name.toString();
+
+        return new GenericFileName(
+            auth.scheme,
+            auth.hostName,
+            auth.port,
+            defaultPort,
+            auth.userName,
+            auth.password,
+            path);
+    }
+
+    /**
+     * Extracts the scheme, userinfo, hostname and port components of a
+     * generic URI.
+     *
+     * @param uri  The absolute URI to parse.
+     * @param name Used to return the remainder of the URI.
+     */
+    protected Authority extractToPath(final String uri,
+                                             final StringBuffer name)
+        throws FileSystemException
+    {
+        final Authority auth = new Authority();
+
+        // Extract the scheme
+        auth.scheme = UriParser.extractScheme(uri, name);
+
+        // Expecting "//"
+        if (name.length() < 2 || name.charAt(0) != '/' || name.charAt(1) != '/')
+        {
+            throw new FileSystemException("vfs.provider/missing-double-slashes.error", uri);
+        }
+        name.delete(0, 2);
+
+        // Extract userinfo, and split into username and password
+        final String userInfo = extractUserInfo(name);
+        final String userName;
+        final String password;
+        if (userInfo != null)
+        {
+            int idx = userInfo.indexOf(':');
+            if (idx == -1)
+            {
+                userName = userInfo;
+                password = null;
+            }
+            else
+            {
+                userName = userInfo.substring(0, idx);
+                password = userInfo.substring(idx + 1);
+            }
+        }
+        else
+        {
+            userName = null;
+            password = null;
+        }
+        auth.userName = UriParser.decode(userName);
+        auth.password = UriParser.decode(password);
+
+        // Extract hostname, and normalise (lowercase)
+        final String hostName = extractHostName(name);
+        if (hostName == null)
+        {
+            throw new FileSystemException("vfs.provider/missing-hostname.error", uri);
+        }
+        auth.hostName = hostName.toLowerCase();
+
+        // Extract port
+        auth.port = extractPort(name, uri);
+
+        // Expecting '/' or empty name
+        if (name.length() > 0 && name.charAt(0) != '/')
+        {
+            throw new FileSystemException("vfs.provider/missing-hostname-path-sep.error", uri);
+        }
+
+        return auth;
+    }
+
+    /**
+     * Extracts the user info from a URI.  The scheme:// part has been removed
+     * already.
+     */
+    protected String extractUserInfo(final StringBuffer name)
+    {
+        final int maxlen = name.length();
+        for (int pos = 0; pos < maxlen; pos++)
+        {
+            final char ch = name.charAt(pos);
+            if (ch == '@')
+            {
+                // Found the end of the user info
+                String userInfo = name.substring(0, pos);
+                name.delete(0, pos + 1);
+                return userInfo;
+            }
+            if (ch == '/' || ch == '?')
+            {
+                // Not allowed in user info
+                break;
+            }
+        }
+
+        // Not found
+        return null;
+    }
+
+    /**
+     * Extracts the hostname from a URI.  The scheme://userinfo@ part has
+     * been removed.
+     */
+    protected String extractHostName(final StringBuffer name)
+    {
+        final int maxlen = name.length();
+        int pos = 0;
+        for (; pos < maxlen; pos++)
+        {
+            final char ch = name.charAt(pos);
+            if (ch == '/' || ch == ';' || ch == '?' || ch == ':'
+                || ch == '@' || ch == '&' || ch == '=' || ch == '+'
+                || ch == '$' || ch == ',')
+            {
+                break;
+            }
+        }
+        if (pos == 0)
+        {
+            return null;
+        }
+
+        final String hostname = name.substring(0, pos);
+        name.delete(0, pos);
+        return hostname;
+    }
+
+    /**
+     * Extracts the port from a URI.  The scheme://userinfo@hostname
+     * part has been removed.
+     *
+     * @return The port, or -1 if the URI does not contain a port.
+     */
+    protected int extractPort(final StringBuffer name, final String uri) throws FileSystemException
+    {
+        if (name.length() < 1 || name.charAt(0) != ':')
+        {
+            return -1;
+        }
+
+        final int maxlen = name.length();
+        int pos = 1;
+        for (; pos < maxlen; pos++)
+        {
+            final char ch = name.charAt(pos);
+            if (ch < '0' || ch > '9')
+            {
+                break;
+            }
+        }
+
+        final String port = name.substring(1, pos);
+        name.delete(0, pos);
+        if (port.length() == 0)
+        {
+            throw new FileSystemException("vfs.provider/missing-port.error", uri);
+        }
+
+        return Integer.parseInt(port);
+    }
+
+    /**
+     * Parsed authority info (scheme, hostname, userinfo, port)
+     */
+    protected static class Authority
+    {
+        public String scheme;
+        public String hostName;
+        public String userName;
+        public String password;
+        public int port;
+    }
+}

Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileNameParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileNameParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileNameParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/UriParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/UriParser.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/UriParser.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/UriParser.java Fri Mar 25 11:12:17 2005
@@ -365,4 +365,89 @@
             }
         }
     }
+
+    /**
+     * Removes %nn encodings from a string.
+     */
+    public static String encode(final String decodedStr)
+    {
+        return encode(decodedStr,  null);
+    }
+
+    public static String encode(final String decodedStr, final char[] reserved)
+    {
+        if (decodedStr == null)
+        {
+            return null;
+        }
+        final StringBuffer buffer = new StringBuffer(decodedStr);
+        encode(buffer, 0, buffer.length(), reserved);
+        return buffer.toString();
+    }
+
+    public static String[] encode(String[] strings)
+    {
+        for (int i = 0; i<strings.length; i++)
+        {
+            strings[i] = encode(strings[i]);
+        }
+        return strings;
+    }
+
+    public static void checkUriEncoding(String uri) throws FileSystemException
+    {
+        decode(uri);
+    }
+
+    public static void canonicalizePath(StringBuffer buffer, int offset, int length, FileNameParser fileNameParser) throws FileSystemException
+    {
+        int index = offset;
+        int count = length;
+        for (; count > 0; count--, index++)
+        {
+            final char ch = buffer.charAt(index);
+            if (ch == '%')
+            {
+                if (count < 3)
+                {
+                    throw new FileSystemException("vfs.provider/invalid-escape-sequence.error", buffer.substring(index, index + count));
+                }
+
+                // Decode
+                int dig1 = Character.digit(buffer.charAt(index + 1), 16);
+                int dig2 = Character.digit(buffer.charAt(index + 2), 16);
+                if (dig1 == -1 || dig2 == -1)
+                {
+                    throw new FileSystemException("vfs.provider/invalid-escape-sequence.error", buffer.substring(index, index + 3));
+                }
+                char value = (char) (dig1 << 4 | dig2);
+
+                boolean match = (ch == '%') || (fileNameParser != null && fileNameParser.encodeCharacter(ch));
+
+                if (match)
+                {
+                    // this is a reserved character, not allowed to decode
+                    index+=2;
+                    count-=2;
+                    continue;
+                }
+
+                // Replace
+                buffer.setCharAt(index, value);
+                buffer.delete(index + 1, index + 3);
+                count -= 2;
+            }
+            else if (fileNameParser.encodeCharacter(ch))
+            {
+                // Encode
+                char[] digits = {
+                    Character.forDigit(((ch >> 4) & 0xF), 16),
+                    Character.forDigit((ch & 0xF), 16)
+                };
+                buffer.setCharAt(index, '%');
+                buffer.insert(index + 1, digits);
+                index += 2;
+            }
+        }
+    }
 }

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/VfsComponentContext.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/VfsComponentContext.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/VfsComponentContext.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/VfsComponentContext.java Fri Mar 25 11:12:17 2005
@@ -19,6 +19,7 @@
 import org.apache.commons.vfs.FileSystemException;
 import org.apache.commons.vfs.FileSystemManager;
 import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.FileName;
 
 import java.io.File;
 
@@ -48,6 +49,8 @@
      */
     FileObject resolveFile(String name, FileSystemOptions fileSystemOptions)
         throws FileSystemException;
+
+    FileName parseURI(String uri) throws FileSystemException;
 
     /**
      * Locates a file replicator for the provider to use.

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/compressed/CompressedFileFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/compressed/CompressedFileFileProvider.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/compressed/CompressedFileFileProvider.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/compressed/CompressedFileFileProvider.java Fri Mar 25 11:12:17 2005
@@ -22,6 +22,7 @@
 import org.apache.commons.vfs.FileSystemOptions;
 import org.apache.commons.vfs.provider.AbstractLayeredFileProvider;
 import org.apache.commons.vfs.provider.FileProvider;
+import org.apache.commons.vfs.provider.LayeredFileName;
 import org.apache.commons.vfs.provider.zip.ZipFileName;
 
 import java.util.Collection;
@@ -47,11 +48,13 @@
      *
      * @param uri The URI to parse.
      */
-    protected FileName parseUri(final String uri)
+    /*
+    public FileName parseUri(final String uri)
         throws FileSystemException
     {
         return ZipFileName.parseUri(uri);
     }
+    */
 
     /**
      * Creates a layered file system.  This method is called if the file system
@@ -67,7 +70,7 @@
         throws FileSystemException
     {
         final FileName name =
-            new ZipFileName(scheme, file.getName().getURI(), FileName.ROOT_PATH);
+            new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH);
         return createFileSystem(name, file, fileSystemOptions);
     }
 

Added: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileNameParser.java?view=auto&rev=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileNameParser.java (added)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileNameParser.java Fri Mar 25 11:12:17 2005
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.ftp;
+
+import org.apache.commons.vfs.provider.FileNameParser;
+import org.apache.commons.vfs.provider.URLFileNameParser;
+import org.apache.commons.vfs.provider.http.HttpFileNameParser;
+import org.apache.commons.vfs.provider.webdav.WebdavFileNameParser;
+
+/**
+ * Implementation for the webdav filesystem.
+ * < p/>
+ * Additionally encodes every character below space (' ')
+ */
+public class FtpFileNameParser extends URLFileNameParser
+{
+    private final static FtpFileNameParser INSTANCE = new FtpFileNameParser();
+
+    public FtpFileNameParser()
+    {
+        super(21);
+    }
+
+    public boolean encodeCharacter(char ch)
+    {
+        return super.encodeCharacter(ch) || ch < ' ';
+    }
+
+    public static FileNameParser getInstance()
+    {
+        return INSTANCE;
+    }
+}

Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileNameParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileNameParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileNameParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java Fri Mar 25 11:12:17 2005
@@ -22,6 +22,7 @@
 import org.apache.commons.vfs.FileType;
 import org.apache.commons.vfs.RandomAccessContent;
 import org.apache.commons.vfs.provider.AbstractFileObject;
+import org.apache.commons.vfs.provider.UriParser;
 import org.apache.commons.vfs.util.MonitorInputStream;
 import org.apache.commons.vfs.util.MonitorOutputStream;
 import org.apache.commons.vfs.util.RandomAccessMode;
@@ -60,12 +61,12 @@
     {
         super(name, fileSystem);
         ftpFs = fileSystem;
-        String relPath = rootName.getRelativeName(name);
+        String relPath = UriParser.decode(rootName.getRelativeName(name));
         if (".".equals(relPath))
         {
             // do not use the "." as path against the ftp-server
             // e.g. the uu.net ftp-server do a recursive listing then
-            this.relPath = rootName.getPath();
+            this.relPath = UriParser.decode(rootName.getPath());
         }
         else
         {
@@ -75,9 +76,11 @@
 
     /**
      * Called by child file objects, to locate their ftp file info.
+     *
+     * @param name the filename in its native form ie. without uri stuff (%nn)
+     * @param flush recreate children cache
      */
-    private FTPFile getChildFile(final String name, final boolean flush)
-        throws IOException
+    private FTPFile getChildFile(final String name, final boolean flush) throws IOException
     {
         if (flush)
         {
@@ -161,7 +164,7 @@
         final FtpFileObject parent = (FtpFileObject) getParent();
         if (parent != null)
         {
-            fileInfo = parent.getChildFile(getName().getBaseName(), flush);
+            fileInfo = parent.getChildFile(UriParser.decode(getName().getBaseName()), flush);
         }
         else
         {
@@ -234,7 +237,7 @@
             {
                 relativeTo = getName();
             }
-            FileName linkDestinationName = relativeTo.resolveName(path);
+            FileName linkDestinationName = getFileSystem().getFileSystemManager().resolveName(relativeTo, path);
             linkDestination = getFileSystem().resolveFile(linkDestinationName);
         }
 
@@ -267,7 +270,7 @@
             childNames[i] = child.getName();
         }
 
-        return childNames;
+        return UriParser.encode(childNames);
     }
 
     /**

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileProvider.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileProvider.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/ftp/FtpFileProvider.java Fri Mar 25 11:12:17 2005
@@ -38,7 +38,6 @@
     extends AbstractOriginatingFileProvider
 {
     public final static String ATTR_FILE_ENTRY_PARSER = "FEP";
-    private static final int DEFAULT_PORT = 21;
 
     final static Collection capabilities = Collections.unmodifiableCollection(Arrays.asList(new Capability[]
     {
@@ -60,15 +59,7 @@
     public FtpFileProvider()
     {
         super();
-    }
-
-    /**
-     * Parses a URI.
-     */
-    protected FileName parseUri(final String uri)
-        throws FileSystemException
-    {
-        return GenericFileName.parseUri(uri, DEFAULT_PORT);
+        setFileNameParser(FtpFileNameParser.getInstance());
     }
 
     /**

Added: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileNameParser.java?view=auto&rev=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileNameParser.java (added)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileNameParser.java Fri Mar 25 11:12:17 2005
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.http;
+
+import org.apache.commons.vfs.provider.FileNameParser;
+import org.apache.commons.vfs.provider.URLFileNameParser;
+
+/**
+ * Implementation for the webdav filesystem.
+ * < p/>
+ * Additionally encodes every character below space (' ')
+ */
+public class HttpFileNameParser extends URLFileNameParser
+{
+    private final static HttpFileNameParser INSTANCE = new HttpFileNameParser();
+
+    public HttpFileNameParser()
+    {
+        super(80);
+    }
+
+    public boolean encodeCharacter(char ch)
+    {
+        return super.encodeCharacter(ch) || ch < ' ';
+    }
+
+    public static FileNameParser getInstance()
+    {
+        return INSTANCE;
+    }
+}

Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileNameParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileNameParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileNameParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/http/HttpFileProvider.java Fri Mar 25 11:12:17 2005
@@ -52,15 +52,7 @@
     public HttpFileProvider()
     {
         super();
-    }
-
-    /**
-     * Parses an abolute URI.
-     */
-    protected FileName parseUri(final String uri)
-        throws FileSystemException
-    {
-        return GenericFileName.parseUri(uri, 80);
+        setFileNameParser(HttpFileNameParser.getInstance());
     }
 
     /**

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/jar/JarFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/jar/JarFileProvider.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/jar/JarFileProvider.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/jar/JarFileProvider.java Fri Mar 25 11:12:17 2005
@@ -23,6 +23,8 @@
 import org.apache.commons.vfs.FileSystemOptions;
 import org.apache.commons.vfs.provider.zip.ZipFileName;
 import org.apache.commons.vfs.provider.zip.ZipFileProvider;
+import org.apache.commons.vfs.provider.UriParser;
+import org.apache.commons.vfs.provider.LayeredFileName;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -76,7 +78,7 @@
         throws FileSystemException
     {
         final FileName name =
-            new ZipFileName(scheme, file.getName().getURI(), FileName.ROOT_PATH);
+            new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH);
         return new JarFileSystem(name, file, fileSystemOptions);
     }
 

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/DefaultLocalFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/DefaultLocalFileProvider.java?view=diff&r1=159045&r2=159046
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/DefaultLocalFileProvider.java (original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/DefaultLocalFileProvider.java Fri Mar 25 11:12:17 2005
@@ -23,6 +23,7 @@
 import org.apache.commons.vfs.FileSystemOptions;
 import org.apache.commons.vfs.provider.AbstractOriginatingFileProvider;
 import org.apache.commons.vfs.provider.LocalFileProvider;
+import org.apache.commons.vfs.provider.UriParser;
 import org.apache.commons.vfs.util.Os;
 
 import java.io.File;
@@ -91,7 +92,7 @@
         StringBuffer uri = new StringBuffer(name.length() + 5);
         uri.append("file:");
         uri.append(name);
-        FileName filename = parseUri(uri.toString(), false);
+        FileName filename = parseUri("file", uri.toString());
         return findFile(filename, null);
     }
 
@@ -101,25 +102,8 @@
     public FileObject findLocalFile(final File file)
         throws FileSystemException
     {
-        return findLocalFile(file.getAbsolutePath());
-    }
-
-    /**
-     * Parses a URI.
-     */
-    protected FileName parseUri(final String uri, final boolean uriEncoded)
-        throws FileSystemException
-    {
-        return LocalFileName.parseUri(uri, uriEncoded, parser);
-    }
-
-    /**
-     * Parses a URI.
-     */
-    protected FileName parseUri(final String uri)
-        throws FileSystemException
-    {
-        return parseUri(uri, true);
+        return findLocalFile(UriParser.encode(file.getAbsolutePath()));
+        // return findLocalFile(file.getAbsolutePath());
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message