org.apache.commons.vfs
Interface FileName

All Superinterfaces:
Comparable
All Known Implementing Classes:
AbstractFileName

public interface FileName
extends Comparable

Represents a file name. File names are immutable, and work correctly as keys in hash tables.

Version:
$Revision: 480428 $ $Date: 2006-11-29 07:15:24 +0100 (Mi, 29 Nov 2006) $
Author:
Adam Murdoch
See Also:
FileObject

Field Summary
static String ROOT_PATH
          The absolute path of the root of a file system.
static String SEPARATOR
          The separator used in file paths.
static char SEPARATOR_CHAR
          The separator character used in file paths.
 
Method Summary
 String getBaseName()
          Returns the base name of this file.
 int getDepth()
          Returns the depth of this file name, within its file system.
 String getExtension()
          Returns the extension of this file name.
 String getFriendlyURI()
          returns a "friendly path", this is a path without a password.
 FileName getParent()
          Returns the file name of the parent of this file.
 String getPath()
          Returns the absolute path of this file, within its file system.
 String getPathDecoded()
          Returns the absolute path of this file, within its file system.
 String getRelativeName(FileName name)
          Converts a file name to a relative name, relative to this file name.
 FileName getRoot()
          find the root of the filesystem
 String getRootURI()
          Returns the root URI of the file system this file belongs to.
 String getScheme()
          Returns the URI scheme of this file.
 FileType getType()
          Returns the requested or current type of this name.
 String getURI()
          Returns the absolute URI of this file.
 boolean isAncestor(FileName ancestor)
          Determines if another file name is an ancestor of this file name.
 boolean isDescendent(FileName descendent)
          Determines if another file name is a descendent of this file name.
 boolean isDescendent(FileName descendent, NameScope nameScope)
          Determines if another file name is a descendent of this file name.
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

SEPARATOR_CHAR

public static final char SEPARATOR_CHAR
The separator character used in file paths.

See Also:
Constant Field Values

SEPARATOR

public static final String SEPARATOR
The separator used in file paths.

See Also:
Constant Field Values

ROOT_PATH

public static final String ROOT_PATH
The absolute path of the root of a file system.

See Also:
Constant Field Values
Method Detail

getBaseName

public String getBaseName()
Returns the base name of this file. The base name is the last element of the file name. For example the base name of /somefolder/somefile is somefile.

The root file of a file system has an empty base name.

Returns:
The base name. Never returns null.

getPath

public String getPath()
Returns the absolute path of this file, within its file system. This path is normalised, so that . and .. elements have been removed. Also, the path only contains / as its separator character. The path always starts with /

The root of a file system has / as its absolute path.

Returns:
The path. Never returns null.

getPathDecoded

public String getPathDecoded()
                      throws FileSystemException
Returns the absolute path of this file, within its file system. This path is normalised, so that . and .. elements have been removed. Also, the path only contains / as its separator character. The path always starts with /

The root of a file system has / as its absolute path.

In contrast to getPath() the path is decoded i.e. all %nn stuff replaced by its character.

Returns:
The path. Never returns null.
Throws:
FileSystemException - if the path is not correctly encoded

getExtension

public String getExtension()
Returns the extension of this file name.

Returns:
The extension. Returns an empty string if the name has no extension.

getDepth

public int getDepth()
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.


getScheme

public String getScheme()
Returns the URI scheme of this file.


getURI

public String getURI()
Returns the absolute URI of this file.


getRootURI

public String getRootURI()
Returns the root URI of the file system this file belongs to.


getRoot

public FileName getRoot()
find the root of the filesystem


getParent

public FileName getParent()
Returns the file name of the parent of this file. The root of a file system has no parent.

Returns:
A FileName object representing the parent name. Returns null for the root of a file system.

getRelativeName

public String getRelativeName(FileName name)
                       throws FileSystemException
Converts a file name to a relative name, relative to this file name.

Parameters:
name - The name to convert to a relative path.
Returns:
The relative name.
Throws:
FileSystemException - On error.

isAncestor

public boolean isAncestor(FileName ancestor)
Determines if another file name is an ancestor of this file name.


isDescendent

public boolean isDescendent(FileName descendent)
Determines if another file name is a descendent of this file name.


isDescendent

public boolean isDescendent(FileName descendent,
                            NameScope nameScope)
Determines if another file name is a descendent of this file name.


getType

public FileType getType()
Returns the requested or current type of this name.

The "requested" type is the one determined during resolving the name.
In this case the name is a FileType.FOLDER if it ends with an "/" else it will be a FileType.FILE

Once attached it will be changed to reflect the real type of this resource.

Returns:
FileType.FOLDER or FileType.FILE

getFriendlyURI

public String getFriendlyURI()
returns a "friendly path", this is a path without a password.
This path can not be used to resolve the path again



Copyright © 2002-2006 The Apache Software Foundation. All Rights Reserved.