adammurdoch    2003/01/22 20:33:34

  Modified:    vfs/src/java/org/apache/commons/vfs FileName.java
               vfs/src/java/org/apache/commons/vfs/provider
                        DefaultFileName.java
  Log:
  Added FileName.getExtension().
  
  Revision  Changes    Path
  1.8       +8 -0      
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/FileName.java
  
  Index: FileName.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/FileName.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FileName.java     23 Nov 2002 00:05:26 -0000      1.7
  +++ FileName.java     23 Jan 2003 04:33:34 -0000      1.8
  @@ -95,6 +95,14 @@
       String getPath();
   
       /**
  +     * Returns the extension of this file name.
  +     *
  +     * @return The extension.  Returns an empty string if the name has no
  +     *         extension.
  +     */
  +    String getExtension();
  +
  +    /**
        * Returns the depth of this file name, within its file system.  The depth
        * of the root of a file system is 0.  The depth of any other file is
        * 1 + the depth of its parent.
  
  
  
  1.6       +18 -0     
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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultFileName.java      31 Oct 2002 10:30:44 -0000      1.5
  +++ DefaultFileName.java      23 Jan 2003 04:33:34 -0000      1.6
  @@ -203,6 +203,24 @@
       }
   
       /**
  +     * Returns the extension of this file name.
  +     */
  +    public String getExtension()
  +    {
  +        getBaseName();
  +        final int pos = baseName.lastIndexOf( '.' );
  +        if ( ( pos == -1 ) || ( pos == baseName.length() - 1 ) )
  +        {
  +            // No extension
  +            return "";
  +        }
  +        else
  +        {
  +            return baseName.substring( 0, pos );
  +        }
  +    }
  +
  +    /**
        * Determines if another file name is an ancestor of this file name.
        */
       public boolean isAncestor( final FileName ancestor )
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to