commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adammurd...@apache.org
Subject cvs commit: jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/zip ZipFileName.java
Date Wed, 12 Feb 2003 02:05:20 GMT
adammurdoch    2003/02/11 18:05:20

  Modified:    vfs/src/java/org/apache/commons/vfs/impl
                        VirtualFileProvider.java
               vfs/src/java/org/apache/commons/vfs/provider
                        DefaultFileName.java GenericFileName.java
                        LayeredFileName.java
               vfs/src/java/org/apache/commons/vfs/provider/ftp
                        FtpFileName.java
               vfs/src/java/org/apache/commons/vfs/provider/local
                        LocalFileName.java
               vfs/src/java/org/apache/commons/vfs/provider/smb
                        SmbFileName.java
               vfs/src/java/org/apache/commons/vfs/provider/temp
                        TemporaryFileProvider.java
               vfs/src/java/org/apache/commons/vfs/provider/url
                        UrlFileProvider.java
               vfs/src/java/org/apache/commons/vfs/provider/zip
                        ZipFileName.java
  Added:       vfs/src/java/org/apache/commons/vfs/provider
                        BasicFileName.java
  Log:
  Some tidy-us to the FileName hierarchy:
  - The root URI for a DefaultFileName is assembled lazily, rather than being
    supplied to the constructor.
  - Implemented createName() factory method for all subclasses of DefaultFileName.
  - SmbFileName and FtpFileName don't include the port in the root URI if the port
    is the default for the protocol.
  - Added BasicFileName, a FileName implementation made up of a root URI and path.
  
  Revision  Changes    Path
  1.4       +4 -5      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/VirtualFileProvider.java
  
  Index: VirtualFileProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/impl/VirtualFileProvider.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- VirtualFileProvider.java	23 Jan 2003 12:27:23 -0000	1.3
  +++ VirtualFileProvider.java	12 Feb 2003 02:05:19 -0000	1.4
  @@ -60,6 +60,7 @@
   import org.apache.commons.vfs.FileSystemException;
   import org.apache.commons.vfs.provider.AbstractVfsContainer;
   import org.apache.commons.vfs.provider.DefaultFileName;
  +import org.apache.commons.vfs.provider.BasicFileName;
   
   
   /**
  @@ -78,9 +79,7 @@
           throws FileSystemException
       {
           final FileName rootName =
  -            new DefaultFileName( rootFile.getName().getScheme(),
  -                                 rootFile.getName().getURI(),
  -                                 FileName.ROOT_PATH );
  +            new BasicFileName( rootFile.getName(), FileName.ROOT_PATH );
           final VirtualFileSystem fs = new VirtualFileSystem( rootName );
           addComponent( fs );
           fs.addJunction( FileName.ROOT_PATH, rootFile );
  @@ -93,7 +92,7 @@
       public FileObject createFileSystem( final String rootUri ) throws FileSystemException
       {
           final FileName rootName =
  -            new DefaultFileName( rootUri, FileName.ROOT_PATH );
  +            new BasicFileName( rootUri, FileName.ROOT_PATH );
           final VirtualFileSystem fs = new VirtualFileSystem( rootName );
           addComponent( fs );
           return fs.getRoot();
  
  
  
  1.9       +41 -41    jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/DefaultFileName.java
  
  Index: DefaultFileName.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/DefaultFileName.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultFileName.java	24 Jan 2003 00:20:03 -0000	1.8
  +++ DefaultFileName.java	12 Feb 2003 02:05:19 -0000	1.9
  @@ -65,42 +65,26 @@
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    * @version $Revision$ $Date$
    */
  -public class DefaultFileName
  +public abstract class DefaultFileName
       implements FileName
   {
       public static final char separatorChar = UriParser.separatorChar;
       public static final String separator = UriParser.separator;
   
       private final String scheme;
  -    private final String rootUri;
       private final String absPath;
   
       // Cached stuff
       private String uri;
       private String baseName;
  +    private String rootUri;
  +    private String extension;
   
       public DefaultFileName( final String scheme,
  -                            final String rootUri,
                               final String absPath )
       {
           this.scheme = scheme;
           this.absPath = absPath;
  -
  -        // Remove trailing separator, if any
  -        if ( rootUri.endsWith( separator ) )
  -        {
  -            this.rootUri = rootUri.substring( 0, rootUri.length() - 1 );
  -        }
  -        else
  -        {
  -            this.rootUri = rootUri;
  -        }
  -    }
  -
  -    public DefaultFileName( final String rootUri,
  -                            final String absPath )
  -    {
  -        this( UriParser.extractScheme( rootUri ), rootUri, absPath );
       }
   
       /**
  @@ -108,7 +92,7 @@
        */
       public int hashCode()
       {
  -        return ( rootUri.hashCode() ^ absPath.hashCode() );
  +        return ( getRootURI().hashCode() ^ absPath.hashCode() );
       }
   
       /**
  @@ -117,7 +101,7 @@
       public boolean equals( final Object obj )
       {
           final DefaultFileName name = (DefaultFileName)obj;
  -        return ( rootUri.equals( name.rootUri ) && absPath.equals( absPath ) );
  +        return ( getRootURI().equals( name.getRootURI() ) && absPath.equals( absPath
) );
       }
   
       /**
  @@ -129,14 +113,14 @@
       }
   
       /**
  -     * Factory method for creating name instances.  Can be overridden.
  -     *
  -     * @todo Implement this for all subclasses
  +     * Factory method for creating name instances.
        */
  -    protected FileName createName( final String absPath )
  -    {
  -        return new DefaultFileName( scheme, rootUri, absPath );
  -    }
  +    protected abstract FileName createName( String absPath );
  +
  +    /**
  +     * Builds the root URI for this file name.
  +     */
  +    protected abstract void appendRootUri( StringBuffer buffer );
   
       /**
        * Returns the base name of the file.
  @@ -251,7 +235,7 @@
       {
           if ( uri == null )
           {
  -            uri = rootUri + absPath;
  +            uri = getRootURI() + absPath;
           }
           return uri;
       }
  @@ -321,6 +305,19 @@
        */
       public String getRootURI()
       {
  +        if ( rootUri == null )
  +        {
  +            final StringBuffer buffer = new StringBuffer();
  +            appendRootUri( buffer );
  +
  +            // Remove trailing separator, if any
  +            if ( buffer.charAt( buffer.length() - 1 ) == separatorChar )
  +            {
  +                buffer.deleteCharAt( buffer.length() - 1 );
  +            }
  +
  +            rootUri = buffer.toString();
  +        }
           return rootUri;
       }
   
  @@ -347,17 +344,21 @@
        */
       public String getExtension()
       {
  -        getBaseName();
  -        final int pos = baseName.lastIndexOf( '.' );
  -        if ( ( pos == -1 ) || ( pos == baseName.length() - 1 ) )
  +        if ( extension == null )
           {
  -            // No extension
  -            return "";
  -        }
  -        else
  -        {
  -            return baseName.substring( 0, pos );
  +            getBaseName();
  +            final int pos = baseName.lastIndexOf( '.' );
  +            if ( ( pos == -1 ) || ( pos == baseName.length() - 1 ) )
  +            {
  +                // No extension
  +                extension = "";
  +            }
  +            else
  +            {
  +                extension = baseName.substring( 0, pos );
  +            }
           }
  +        return extension;
       }
   
       /**
  @@ -365,7 +366,7 @@
        */
       public boolean isAncestor( final FileName ancestor )
       {
  -        if ( !ancestor.getRootURI().equals( rootUri ) )
  +        if ( !ancestor.getRootURI().equals( getRootURI() ) )
           {
               return false;
           }
  @@ -386,7 +387,7 @@
       public boolean isDescendent( final FileName descendent,
                                    final NameScope scope )
       {
  -        if ( !descendent.getRootURI().equals( rootUri ) )
  +        if ( !descendent.getRootURI().equals( getRootURI() ) )
           {
               return false;
           }
  @@ -448,5 +449,4 @@
   
           return true;
       }
  -
   }
  
  
  
  1.3       +16 -17    jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/GenericFileName.java
  
  Index: GenericFileName.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/GenericFileName.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GenericFileName.java	24 Jan 2003 00:20:03 -0000	1.2
  +++ GenericFileName.java	12 Feb 2003 02:05:19 -0000	1.3
  @@ -65,7 +65,7 @@
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    * @version $Revision$ $Date$
    */
  -public class GenericFileName
  +public abstract class GenericFileName
       extends DefaultFileName
   {
       private final String userInfo;
  @@ -73,13 +73,12 @@
       private final String port;
   
       protected GenericFileName( final String scheme,
  -                               final String rootUri,
                                  final String hostName,
                                  final String port,
                                  final String userInfo,
                                  final String path )
       {
  -        super( scheme, rootUri, path );
  +        super( scheme, path );
           this.hostName = hostName;
           this.port = port;
           this.userInfo = userInfo;
  @@ -103,6 +102,9 @@
           return port;
       }
   
  +    /** Returns the default port for this file name. */
  +    public abstract String getDefaultPort();
  +
       /**
        * Extracts the scheme, userinfo, hostname and port components of a
        * generic URI.
  @@ -241,25 +243,22 @@
       }
   
       /**
  -     * Assembles a generic URI, appending to the supplied StringBuffer.
  +     * Builds the root URI for this file name.
        */
  -    protected static void appendRootUri( final Authority auth,
  -                                         final StringBuffer rootUri )
  +    protected void appendRootUri( final StringBuffer buffer )
       {
  -        rootUri.append( auth.scheme );
  -        rootUri.append( "://" );
  -        final String userInfo = auth.userInfo;
  +        buffer.append( getScheme() );
  +        buffer.append( "://" );
           if ( userInfo != null && userInfo.length() != 0 )
           {
  -            rootUri.append( userInfo );
  -            rootUri.append( "@" );
  +            buffer.append( userInfo );
  +            buffer.append( "@" );
           }
  -        rootUri.append( auth.hostName );
  -        final String port = auth.port;
  -        if ( port != null && port.length() > 0 )
  +        buffer.append( hostName );
  +        if ( port != null && port.length() > 0 && !port.equals( getDefaultPort()
) )
           {
  -            rootUri.append( ":" );
  -            rootUri.append( port );
  +            buffer.append( ":" );
  +            buffer.append( port );
           }
       }
   
  
  
  
  1.3       +3 -4      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/LayeredFileName.java
  
  Index: LayeredFileName.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/LayeredFileName.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LayeredFileName.java	24 Jan 2003 00:20:03 -0000	1.2
  +++ LayeredFileName.java	12 Feb 2003 02:05:19 -0000	1.3
  @@ -61,17 +61,16 @@
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    * @version $Revision$ $Date$
    */
  -public class LayeredFileName
  +public abstract class LayeredFileName
       extends DefaultFileName
   {
       private final String outerUri;
   
       protected LayeredFileName( final String scheme,
  -                               final String rootUri,
                                  final String outerUri,
                                  final String path )
       {
  -        super( scheme, rootUri, path );
  +        super( scheme, path );
           this.outerUri = outerUri;
       }
   
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/BasicFileName.java
  
  Index: BasicFileName.java
  ===================================================================
  /* ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.vfs.provider;
  
  import org.apache.commons.vfs.FileName;
  import java.net.URL;
  
  /**
   * A simple file name, made up of a root URI and an absolute path.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2003/02/12 02:05:19 $
   */
  public class BasicFileName
      extends DefaultFileName
  {
      private final String rootUri;
  
      public BasicFileName( final String rootUri, final String path )
      {
          this( UriParser.extractScheme( rootUri ), rootUri, path );
      }
  
      public BasicFileName( final String scheme,
                            final String rootUri,
                            final String path )
      {
          super( scheme, path );
          this.rootUri = rootUri;
      }
  
      public BasicFileName( final FileName rootUri, final String path )
      {
          this( rootUri.getScheme(), rootUri.getURI(), path );
      }
  
      public BasicFileName( final URL rootUrl, final String path )
      {
          this( rootUrl.getProtocol(), rootUrl.toExternalForm(), path );
      }
  
      /**
       * Factory method for creating name instances.
       */
      protected FileName createName( final String path )
      {
          return new BasicFileName( getScheme(), rootUri, path );
      }
  
      /**
       * Builds the root URI for this file name.
       */
      protected void appendRootUri( final StringBuffer buffer )
      {
          buffer.append( rootUri );
      }
  }
  
  
  
  1.3       +23 -16    jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/ftp/FtpFileName.java
  
  Index: FtpFileName.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/ftp/FtpFileName.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FtpFileName.java	24 Jan 2003 00:20:04 -0000	1.2
  +++ FtpFileName.java	12 Feb 2003 02:05:19 -0000	1.3
  @@ -58,6 +58,7 @@
   import org.apache.commons.vfs.provider.GenericFileName;
   import org.apache.commons.vfs.provider.UriParser;
   import org.apache.commons.vfs.FileSystemException;
  +import org.apache.commons.vfs.FileName;
   
   /**
    * An FTP URI.  Splits userinfo (see {@link #getUserInfo}) into username and
  @@ -73,7 +74,6 @@
       private final String password;
   
       private FtpFileName( final String scheme,
  -                         final String rootUri,
                            final String hostName,
                            final String port,
                            final String userInfo,
  @@ -81,7 +81,7 @@
                            final String password,
                            final String path )
       {
  -        super( scheme, rootUri, hostName, port, userInfo, path );
  +        super( scheme, hostName, port, userInfo, path );
           this.password = password;
           this.userName = userName;
       }
  @@ -103,13 +103,6 @@
           UriParser.normalisePath( name );
           final String path = name.toString();
   
  -        // Drop the port if it is 21
  -        final String port = auth.port;
  -        if ( port != null && port.equals( "21" ) )
  -        {
  -            auth.port = null;
  -        }
  -
           // Split up the userinfo into a username and password
           // TODO - push this into GenericFileName
           final String userInfo = auth.userInfo;
  @@ -135,13 +128,7 @@
               password = null;
           }
   
  -        // Now build the root URI
  -        final StringBuffer buffer = new StringBuffer();
  -        appendRootUri( auth, buffer );
  -        final String rootUri = buffer.toString();
  -
           return new FtpFileName( auth.scheme,
  -                                rootUri,
                                   auth.hostName,
                                   auth.port,
                                   auth.userInfo,
  @@ -164,5 +151,25 @@
       public String getPassword()
       {
           return password;
  +    }
  +
  +    /** Returns the default port for this file name. */
  +    public String getDefaultPort()
  +    {
  +        return "21";
  +    }
  +
  +    /**
  +     * Factory method for creating name instances.
  +     */
  +    protected FileName createName( final String path )
  +    {
  +        return new FtpFileName( getScheme(),
  +                                getHostName(),
  +                                getPort(),
  +                                getUserInfo(),
  +                                userName,
  +                                password,
  +                                path );
       }
   }
  
  
  
  1.3       +22 -11    jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java
  
  Index: LocalFileName.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LocalFileName.java	24 Jan 2003 00:20:04 -0000	1.2
  +++ LocalFileName.java	12 Feb 2003 02:05:19 -0000	1.3
  @@ -56,6 +56,7 @@
   package org.apache.commons.vfs.provider.local;
   
   import org.apache.commons.vfs.FileSystemException;
  +import org.apache.commons.vfs.FileName;
   import org.apache.commons.vfs.provider.DefaultFileName;
   import org.apache.commons.vfs.provider.UriParser;
   
  @@ -71,11 +72,10 @@
       private final String rootFile;
   
       private LocalFileName( final String scheme,
  -                           final String rootUri,
                              final String rootFile,
                              final String path )
       {
  -        super( scheme, rootUri, path );
  +        super( scheme, path );
           this.rootFile = rootFile;
       }
   
  @@ -104,14 +104,7 @@
           UriParser.normalisePath( name );
           final String path = name.toString();
   
  -        // Build the root URI
  -        final StringBuffer buffer = new StringBuffer();
  -        buffer.append( scheme );
  -        buffer.append( "://" );
  -        buffer.append( rootFile );
  -        final String rootUri = buffer.toString();
  -
  -        return new LocalFileName( scheme, rootUri, rootFile, path );
  +        return new LocalFileName( scheme, rootFile, path );
       }
   
       /**
  @@ -120,5 +113,23 @@
       public String getRootFile()
       {
           return rootFile;
  +    }
  +
  +    /**
  +     * Factory method for creating name instances.
  +     */
  +    protected FileName createName( final String path )
  +    {
  +        return new LocalFileName( getScheme(), rootFile, path );
  +    }
  +
  +    /**
  +     * Builds the root URI for this file name.
  +     */
  +    protected void appendRootUri( final StringBuffer buffer )
  +    {
  +        buffer.append( getScheme() );
  +        buffer.append( "://" );
  +        buffer.append( rootFile );
       }
   }
  
  
  
  1.3       +32 -13    jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/smb/SmbFileName.java
  
  Index: SmbFileName.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/smb/SmbFileName.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SmbFileName.java	24 Jan 2003 00:20:04 -0000	1.2
  +++ SmbFileName.java	12 Feb 2003 02:05:19 -0000	1.3
  @@ -58,6 +58,7 @@
   import org.apache.commons.vfs.provider.GenericFileName;
   import org.apache.commons.vfs.provider.UriParser;
   import org.apache.commons.vfs.FileSystemException;
  +import org.apache.commons.vfs.FileName;
   
   /**
    * An SMB URI.  Adds a share name to the generic URI.
  @@ -71,14 +72,13 @@
       private final String share;
   
       private SmbFileName( final String scheme,
  -                         final String rootUri,
                            final String hostName,
                            final String port,
                            final String userInfo,
                            final String share,
                            final String path )
       {
  -        super( scheme, rootUri, hostName, port, userInfo, path );
  +        super( scheme, hostName, port, userInfo, path );
           this.share = share;
       }
   
  @@ -93,8 +93,6 @@
           // Extract the scheme and authority parts
           final Authority auth = extractToPath( uri, name );
   
  -        // TODO - drop the default port
  -
           // Decode and adjust separators
           UriParser.decode( name, 0, name.length() );
           UriParser.fixSeparators( name );
  @@ -111,15 +109,7 @@
           UriParser.normalisePath( name );
           final String path = name.toString();
   
  -        // Set the root URI
  -        StringBuffer buffer = new StringBuffer();
  -        appendRootUri( auth, buffer );
  -        buffer.append( '/' );
  -        buffer.append( share );
  -        final String rootUri = buffer.toString();
  -
           return new SmbFileName( auth.scheme,
  -                                rootUri,
                                   auth.hostName,
                                   auth.port,
                                   auth.userInfo,
  @@ -133,5 +123,34 @@
       public String getShare()
       {
           return share;
  +    }
  +
  +    /** Returns the default port for this file name. */
  +    public String getDefaultPort()
  +    {
  +        return "139";
  +    }
  +
  +    /**
  +     * Builds the root URI for this file name.
  +     */
  +    protected void appendRootUri( final StringBuffer buffer )
  +    {
  +        super.appendRootUri( buffer );
  +        buffer.append( '/' );
  +        buffer.append( share );
  +    }
  +
  +    /**
  +     * Factory method for creating name instances.
  +     */
  +    protected FileName createName( final String path )
  +    {
  +        return new SmbFileName( getScheme(),
  +                                getHostName(),
  +                                getPort(),
  +                                getUserInfo(),
  +                                share,
  +                                path );
       }
   }
  
  
  
  1.6       +3 -3      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/temp/TemporaryFileProvider.java
  
  Index: TemporaryFileProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/temp/TemporaryFileProvider.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TemporaryFileProvider.java	24 Jan 2003 00:20:04 -0000	1.5
  +++ TemporaryFileProvider.java	12 Feb 2003 02:05:20 -0000	1.6
  @@ -61,7 +61,7 @@
   import org.apache.commons.vfs.FileSystem;
   import org.apache.commons.vfs.FileSystemException;
   import org.apache.commons.vfs.provider.AbstractFileSystemProvider;
  -import org.apache.commons.vfs.provider.DefaultFileName;
  +import org.apache.commons.vfs.provider.BasicFileName;
   import org.apache.commons.vfs.provider.FileProvider;
   import org.apache.commons.vfs.provider.UriParser;
   import org.apache.commons.vfs.provider.local.LocalFileSystem;
  @@ -109,7 +109,7 @@
                   rootFile = getContext().getTemporaryFileStore().allocateFile( "tempfs"
);
               }
               final FileName rootName =
  -                new DefaultFileName( scheme, scheme + ":",  FileName.ROOT_PATH );
  +                new BasicFileName( scheme, scheme + ":",  FileName.ROOT_PATH );
               filesystem = new LocalFileSystem( rootName, rootFile.getAbsolutePath() );
               addFileSystem( this, filesystem );
           }
  
  
  
  1.11      +3 -4      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/url/UrlFileProvider.java
  
  Index: UrlFileProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/url/UrlFileProvider.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- UrlFileProvider.java	23 Jan 2003 12:27:26 -0000	1.10
  +++ UrlFileProvider.java	12 Feb 2003 02:05:20 -0000	1.11
  @@ -63,6 +63,7 @@
   import org.apache.commons.vfs.FileSystemException;
   import org.apache.commons.vfs.provider.AbstractFileSystemProvider;
   import org.apache.commons.vfs.provider.DefaultFileName;
  +import org.apache.commons.vfs.provider.BasicFileName;
   
   /**
    * A file provider backed by Java's URL API.
  @@ -88,9 +89,7 @@
               if ( fs == null )
               {
                   final FileName rootName =
  -                    new DefaultFileName( rootUrl.getProtocol(),
  -                                         rootUrl.toExternalForm(),
  -                                         FileName.ROOT_PATH );
  +                    new BasicFileName( rootUrl, FileName.ROOT_PATH );
                   fs = new UrlFileSystem( rootName );
                   addFileSystem( rootUrl, fs );
               }
  
  
  
  1.3       +15 -11    jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/zip/ZipFileName.java
  
  Index: ZipFileName.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/zip/ZipFileName.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ZipFileName.java	24 Jan 2003 00:20:04 -0000	1.2
  +++ ZipFileName.java	12 Feb 2003 02:05:20 -0000	1.3
  @@ -56,6 +56,7 @@
   package org.apache.commons.vfs.provider.zip;
   
   import org.apache.commons.vfs.FileSystemException;
  +import org.apache.commons.vfs.FileName;
   import org.apache.commons.vfs.provider.LayeredFileName;
   import org.apache.commons.vfs.provider.UriParser;
   
  @@ -74,23 +75,26 @@
                           final String zipFileUri,
                           final String path )
       {
  -        super( scheme,
  -               formatRootUri( scheme, zipFileUri ),
  -               zipFileUri, path );
  +        super( scheme, zipFileUri, path );
       }
   
       /**
  -     * Assembles the root URI for a Zip file.
  +     * Builds the root URI for this file name.
        */
  -    private static String formatRootUri( final String scheme,
  -                                         final String outerFileUri )
  +    protected void appendRootUri( final StringBuffer buffer )
       {
  -        final StringBuffer buffer = new StringBuffer();
  -        buffer.append( scheme );
  +        buffer.append( getScheme() );
           buffer.append( ":" );
  -        UriParser.appendEncoded( buffer, outerFileUri, ZIP_URL_RESERVED_CHARS );
  +        UriParser.appendEncoded( buffer, getOuterUri(), ZIP_URL_RESERVED_CHARS );
           buffer.append( "!" );
  -        return buffer.toString();
  +    }
  +
  +    /**
  +     * Factory method for creating name instances.
  +     */
  +    protected FileName createName( final String path )
  +    {
  +        return new ZipFileName( getScheme(), getOuterUri(), path );
       }
   
       /**
  
  
  

---------------------------------------------------------------------
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