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 ZipFileSystemProvider.java ZipFileNameParser.java
Date Thu, 23 Jan 2003 12:33:05 GMT
adammurdoch    2003/01/23 04:33:04

  Modified:    vfs/src/java/org/apache/commons/vfs/provider/ftp
                        FtpFileSystemProvider.java
               vfs/src/java/org/apache/commons/vfs/provider/jar
                        JarFileSystemProvider.java
               vfs/src/java/org/apache/commons/vfs/provider/local
                        DefaultLocalFileSystemProvider.java
               vfs/src/java/org/apache/commons/vfs/provider/smb
                        SmbFileSystemProvider.java
               vfs/src/java/org/apache/commons/vfs/provider/zip
                        ZipFileSystemProvider.java
  Added:       vfs/src/java/org/apache/commons/vfs/provider
                        GenericFileName.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/zip
                        ZipFileName.java
  Removed:     vfs/src/java/org/apache/commons/vfs/provider GenericUri.java
               vfs/src/java/org/apache/commons/vfs/provider/ftp FtpUri.java
               vfs/src/java/org/apache/commons/vfs/provider/local
                        LocalFileUri.java
               vfs/src/java/org/apache/commons/vfs/provider/smb SmbUri.java
               vfs/src/java/org/apache/commons/vfs/provider/zip
                        ZipFileNameParser.java
  Log:
  Renamed *Uri to *FileName.
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/GenericFileName.java
  
  Index: GenericFileName.java
  ===================================================================
  /* ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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.FileSystemException;
  
  /**
   * A file name that represents a 'generic' URI, as per RFC 2396.  Consists of
   * a scheme, userinfo (typically username and password), hostname, port, and
   * path.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2003/01/23 12:33:02 $
   */
  public class GenericFileName
      extends DefaultFileName
  {
      private String userInfo;
      private String hostName;
      private String port;
  
      /** Returns the user info part of the URI. */
      public String getUserInfo()
      {
          return userInfo;
      }
  
      /** Sets the user info part of the URI. */
      public void setUserInfo( final String userInfo )
      {
          this.userInfo = userInfo;
      }
  
      /** Returns the host name part of the URI. */
      public String getHostName()
      {
          return hostName;
      }
  
      /** Sets the host name part of the URI. */
      public void setHostName( final String hostName )
      {
          this.hostName = hostName;
      }
  
      /** Returns the port part of the URI. */
      public String getPort()
      {
          return port;
      }
  
      /** Sets the port part of the URI. */
      public void setPort( final String port )
      {
          this.port = port;
      }
  
      /**
       * Parses a generic URI.  Briefly, a generic URI looks like:
       *
       * <pre>
       * &lt;scheme> '://' [ &lt;userinfo> '@' ] &lt;hostname> [ ':'
&lt;port> ] '/' &lt;path>
       * </pre>
       *
       * <p>This method differs from the RFC, in that either / or \ is allowed
       * as a path separator.
       *
       * @param uri
       *          The URI to parse.
       */
      protected void parseGenericUri( final String uri )
          throws FileSystemException
      {
          final StringBuffer name = new StringBuffer();
  
          // Extract the scheme and authority parts
          extractToPath( uri, name );
  
          // Decode and normalise the file name
          decode( name, 0, name.length() );
          normalisePath( name );
          setPath( name.toString() );
      }
  
      /**
       * 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 void extractToPath( final String uri,
                                    final StringBuffer name )
          throws FileSystemException
      {
          // Extract the scheme
          final String scheme = extractScheme( uri, name );
          setScheme( scheme );
  
          // 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
          final String userInfo = extractUserInfo( name );
          setUserInfo( userInfo );
  
          // Extract hostname, and normalise
          final String hostName = extractHostName( name );
          if ( hostName == null )
          {
              throw new FileSystemException( "vfs.provider/missing-hostname.error", uri );
          }
          setHostName( hostName.toLowerCase() );
  
          // Extract port
          final String port = extractPort( name );
          if ( port != null && port.length() == 0 )
          {
              throw new FileSystemException( "vfs.provider/missing-port.error", uri );
          }
          setPort( port );
  
          // Expecting '/' or empty name
          if ( name.length() > 0 && name.charAt( 0 ) != '/' )
          {
              throw new FileSystemException( "vfs.provider/missing-hostname-path-sep.error",
uri );
          }
      }
  
      /**
       * 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.
       */
      protected String extractPort( final StringBuffer name )
      {
          if ( name.length() < 1 || name.charAt( 0 ) != ':' )
          {
              return null;
          }
  
          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 );
          return port;
      }
  
      /**
       * Assembles a generic URI, appending to the supplied StringBuffer.
       */
      protected void appendRootUri( final StringBuffer rootUri )
      {
          rootUri.append( getScheme() );
          rootUri.append( "://" );
          final String userInfo = getUserInfo();
          if ( userInfo != null && userInfo.length() != 0 )
          {
              rootUri.append( userInfo );
              rootUri.append( "@" );
          }
          rootUri.append( getHostName() );
          final String port = getPort();
          if ( port != null && port.length() > 0 )
          {
              rootUri.append( ":" );
              rootUri.append( port );
          }
      }
  
  }
  
  
  
  1.10      +2 -2      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemProvider.java
  
  Index: FtpFileSystemProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/ftp/FtpFileSystemProvider.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- FtpFileSystemProvider.java	23 Jan 2003 12:27:23 -0000	1.9
  +++ FtpFileSystemProvider.java	23 Jan 2003 12:33:02 -0000	1.10
  @@ -75,7 +75,7 @@
       protected FileName parseUri( final String uri )
           throws FileSystemException
       {
  -        return new FtpUri( uri );
  +        return new FtpFileName( uri );
       }
   
       /**
  @@ -84,7 +84,7 @@
       protected FileSystem doCreateFileSystem( final FileName name )
           throws FileSystemException
       {
  -        final FtpUri ftpUri = (FtpUri)name;
  +        final FtpFileName ftpUri = (FtpFileName)name;
   
           // Build the root name
           final FileName rootName = ftpUri.resolveName( FileName.ROOT_PATH );
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/ftp/FtpFileName.java
  
  Index: FtpFileName.java
  ===================================================================
  /* ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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.ftp;
  
  import org.apache.commons.vfs.provider.GenericFileName;
  import org.apache.commons.vfs.FileSystemException;
  
  /**
   * An FTP URI.  Splits userinfo (see {@link #getUserInfo}) into username and
   * password.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2003/01/23 12:33:02 $
   */
  class FtpFileName
      extends GenericFileName
  {
      private String userName;
      private String password;
  
      public FtpFileName( final String uri )
          throws FileSystemException
      {
          // FTP URI are generic URI (as per RFC 2396)
          parseGenericUri( uri );
  
          // Drop the port if it is 21
          final String port = getPort();
          if ( port != null && port.equals( "21" ) )
          {
              setPort( null );
          }
  
          // Split up the userinfo into a username and password
          // TODO - push this into GenericFileName
          final String userInfo = getUserInfo();
          if ( userInfo != null )
          {
              int idx = userInfo.indexOf( ':' );
              if ( idx == -1 )
              {
                  setUserName( userInfo );
              }
              else
              {
                  String userName = userInfo.substring( 0, idx );
                  String password = userInfo.substring( idx + 1 );
                  setUserName( userName );
                  setPassword( password );
              }
          }
  
          // Now build the root URI
          final StringBuffer rootUri = new StringBuffer();
          appendRootUri( rootUri );
          setRootURI( rootUri.toString() );
      }
  
      public String getUserName()
      {
          return userName;
      }
  
      public void setUserName( final String userName )
      {
          this.userName = userName;
      }
  
      public String getPassword()
      {
          return password;
      }
  
      public void setPassword( final String password )
      {
          this.password = password;
      }
  }
  
  
  
  1.9       +3 -3      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/jar/JarFileSystemProvider.java
  
  Index: JarFileSystemProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/jar/JarFileSystemProvider.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JarFileSystemProvider.java	23 Jan 2003 12:27:24 -0000	1.8
  +++ JarFileSystemProvider.java	23 Jan 2003 12:33:02 -0000	1.9
  @@ -59,7 +59,7 @@
   import org.apache.commons.vfs.FileObject;
   import org.apache.commons.vfs.FileSystem;
   import org.apache.commons.vfs.FileSystemException;
  -import org.apache.commons.vfs.provider.zip.ZipFileNameParser;
  +import org.apache.commons.vfs.provider.zip.ZipFileName;
   import org.apache.commons.vfs.provider.zip.ZipFileSystemProvider;
   
   /**
  @@ -85,7 +85,7 @@
           throws FileSystemException
       {
           final FileName name =
  -            new ZipFileNameParser( scheme, file.getName().getURI(), FileName.ROOT_PATH
);
  +            new ZipFileName( scheme, file.getName().getURI(), FileName.ROOT_PATH );
           return new JarFileSystem( name, file );
       }
   }
  
  
  
  1.13      +2 -2      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/local/DefaultLocalFileSystemProvider.java
  
  Index: DefaultLocalFileSystemProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/local/DefaultLocalFileSystemProvider.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DefaultLocalFileSystemProvider.java	23 Jan 2003 12:27:24 -0000	1.12
  +++ DefaultLocalFileSystemProvider.java	23 Jan 2003 12:33:02 -0000	1.13
  @@ -123,7 +123,7 @@
       protected FileName parseUri( final String uri )
           throws FileSystemException
       {
  -        return new LocalFileUri( uri, parser );
  +        return new LocalFileName( uri, parser );
       }
   
       /**
  @@ -133,7 +133,7 @@
           throws FileSystemException
       {
           // Build the name of the root file.
  -        final LocalFileUri fileUri = (LocalFileUri)name;
  +        final LocalFileName fileUri = (LocalFileName)name;
           final String rootFile = fileUri.getRootFile();
   
           // Create the file system
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java
  
  Index: LocalFileName.java
  ===================================================================
  /* ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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.local;
  
  import org.apache.commons.vfs.FileSystemException;
  import org.apache.commons.vfs.provider.DefaultFileName;
  
  /**
   * A local file URI.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2003/01/23 12:33:02 $
   */
  class LocalFileName
      extends DefaultFileName
  {
      private String rootFile;
  
      public LocalFileName( final String uri, final LocalFileNameParser parser )
          throws FileSystemException
      {
          final StringBuffer name = new StringBuffer();
  
          // Extract the scheme
          final String scheme = extractScheme( uri, name );
          setScheme( scheme );
  
          // Remove encoding, and adjust the separators
          decode( name, 0, name.length() );
          fixSeparators( name );
  
          // Extract the root prefix
          final String rootFile = parser.extractRootPrefix( uri, name );
          setRootFile( rootFile );
  
          // Normalise the path
          normalisePath( name );
          setPath( name.toString() );
  
          // Build the root URI
          final StringBuffer rootUri = new StringBuffer();
          rootUri.append( scheme );
          rootUri.append( "://" );
          rootUri.append( rootFile );
          setRootURI( rootUri.toString() );
      }
  
      public String getRootFile()
      {
          return rootFile;
      }
  
      public void setRootFile( final String rootPrefix )
      {
          rootFile = rootPrefix;
      }
  }
  
  
  
  1.10      +2 -2      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/smb/SmbFileSystemProvider.java
  
  Index: SmbFileSystemProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/smb/SmbFileSystemProvider.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SmbFileSystemProvider.java	23 Jan 2003 12:27:24 -0000	1.9
  +++ SmbFileSystemProvider.java	23 Jan 2003 12:33:02 -0000	1.10
  @@ -77,7 +77,7 @@
       protected FileName parseUri( final String uri )
           throws FileSystemException
       {
  -        return new SmbUri( uri );
  +        return new SmbFileName( uri );
       }
   
       /**
  @@ -86,7 +86,7 @@
       protected FileSystem doCreateFileSystem( final FileName name )
           throws FileSystemException
       {
  -        final SmbUri smbUri = (SmbUri)name;
  +        final SmbFileName smbUri = (SmbFileName)name;
           final FileName rootName = smbUri.resolveName( FileName.ROOT_PATH );
           return new SmbFileSystem( rootName );
       }
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/smb/SmbFileName.java
  
  Index: SmbFileName.java
  ===================================================================
  /* ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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.smb;
  
  import org.apache.commons.vfs.provider.GenericFileName;
  import org.apache.commons.vfs.FileSystemException;
  
  /**
   * An SMB URI.  Adds a share name to the generic URI.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2003/01/23 12:33:02 $
   */
  class SmbFileName
      extends GenericFileName
  {
      private String share;
  
      public SmbFileName( final String uri )
          throws FileSystemException
      {
          final StringBuffer name = new StringBuffer();
  
          // Extract the scheme and authority parts
          extractToPath( uri, name );
  
          // TODO - drop the default port
  
          // Decode and adjust separators
          decode( name, 0, name.length() );
          fixSeparators( name );
  
          // Extract the share
          final String share = extractFirstElement( name );
          if ( share == null )
          {
              throw new FileSystemException( "vfs.provider.smb/missing-share-name.error",
uri );
          }
          setShare( share );
  
          // Normalise the path
          normalisePath( name );
  
          // Set the path
          setPath( name.toString() );
  
          // Set the root URI
          StringBuffer rootUri = new StringBuffer();
          appendRootUri( rootUri );
          rootUri.append( '/' );
          rootUri.append( share );
          setRootURI( rootUri.toString() );
      }
  
      public String getShare()
      {
          return share;
      }
  
      public void setShare( final String share )
      {
          this.share = share;
      }
  }
  
  
  
  1.16      +2 -2      jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/zip/ZipFileSystemProvider.java
  
  Index: ZipFileSystemProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/zip/ZipFileSystemProvider.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ZipFileSystemProvider.java	23 Jan 2003 12:27:28 -0000	1.15
  +++ ZipFileSystemProvider.java	23 Jan 2003 12:33:04 -0000	1.16
  @@ -79,7 +79,7 @@
       protected FileName parseUri( final String uri )
           throws FileSystemException
       {
  -        return new ZipFileNameParser( uri );
  +        return new ZipFileName( uri );
       }
   
       /**
  @@ -94,7 +94,7 @@
           throws FileSystemException
       {
           final FileName rootName =
  -            new ZipFileNameParser( scheme, file.getName().getURI(), FileName.ROOT_PATH
);
  +            new ZipFileName( scheme, file.getName().getURI(), FileName.ROOT_PATH );
           return new ZipFileSystem( rootName, file );
       }
   }
  
  
  
  1.1                  jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/zip/ZipFileName.java
  
  Index: ZipFileName.java
  ===================================================================
  /* ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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.zip;
  
  import org.apache.commons.vfs.FileSystemException;
  import org.apache.commons.vfs.provider.LayeredFileName;
  
  /**
   * A parser for Zip file names.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2003/01/23 12:33:04 $
   */
  public class ZipFileName
      extends LayeredFileName
  {
      private static final char[] ZIP_URL_RESERVED_CHARS = {'!'};
  
      public ZipFileName( final String uri )
          throws FileSystemException
      {
          final StringBuffer name = new StringBuffer();
  
          // Extract the scheme
          final String scheme = extractScheme( uri, name );
          setScheme( scheme );
  
          // Extract the Zip file URI
          final String zipUri = extractZipName( name );
          setOuterUri( zipUri );
  
          // Decode and normalise the path
          decode( name, 0, name.length() );
          normalisePath( name );
          setPath( name.toString() );
      }
  
      public ZipFileName( final String scheme,
                                final String outerFileUri,
                                final String path )
      {
          final StringBuffer rootUri = new StringBuffer();
          rootUri.append( scheme );
          rootUri.append( ":" );
          appendEncoded( rootUri, outerFileUri, ZIP_URL_RESERVED_CHARS );
          rootUri.append( "!" );
          setRootURI( rootUri.toString() );
          setPath( path );
      }
  
      /**
       * Pops the root prefix off a URI, which has had the scheme removed.
       */
      private static String extractZipName( final StringBuffer uri )
          throws FileSystemException
      {
          // Looking for <name>!<abspath>
          int maxlen = uri.length();
          int pos = 0;
          for ( ; pos < maxlen && 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 );
          }
  
          // Decode the name
          return decode( prefix );
      }
  }
  
  
  

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


Mime
View raw message