Package org.apache.commons.vfs.provider
Class AbstractFileName
java.lang.Object
org.apache.commons.vfs.provider.AbstractFileName
- All Implemented Interfaces:
Comparable
,FileName
- Direct Known Subclasses:
GenericFileName
,LayeredFileName
,LocalFileName
,VirtualFileName
A default file name implementation.
- Version:
- $Revision: 480428 $ $Date: 2006-11-29 07:15:24 +0100 (Wed, 29 Nov 2006) $
- Author:
- Adam Murdoch
-
Field Summary
Fields inherited from interface org.apache.commons.vfs.FileName
ROOT_PATH, SEPARATOR, SEPARATOR_CHAR
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
appendRootUri
(StringBuffer buffer, boolean addPassword) Builds the root URI for this file name.static boolean
Checks whether a path fits in a particular scope of another path.int
Implement Comparableabstract FileName
createName
(String absPath, FileType type) Factory method for creating name instances.protected String
boolean
Determines if this object is equal to another.Returns the base name of the file.int
getDepth()
Returns the depth of this file name, within its file system.Returns the extension of this file name.returns a "friendly path", this is a path without a password.Returns the name of the parent of the file.getPath()
Returns the absolute path of the file, relative to the root of the file system that the file belongs to.Returns the absolute path of this file, within its file system.getRelativeName
(FileName name) Converts a file name to a relative name, relative to this file name.getRoot()
find the root of the filesystemReturns the root URI of the file system this file belongs to.Returns the URI scheme of this file.getType()
Returns the requested or current type of this name.getURI()
Returns the absolute URI of the file.protected String
int
hashCode()
Returns the hashcode for this name.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 scope) Determines if another file name is a descendent of this file name.toString()
Returns the URI of the file.
-
Constructor Details
-
AbstractFileName
-
-
Method Details
-
hashCode
public int hashCode()Returns the hashcode for this name. -
equals
Determines if this object is equal to another. -
compareTo
Implement Comparable- Specified by:
compareTo
in interfaceComparable
- Parameters:
obj
- another abstractfilename
-
toString
Returns the URI of the file. -
createName
Factory method for creating name instances. -
appendRootUri
Builds the root URI for this file name. Note that the root URI must not end with a separator character. -
getBaseName
Returns the base name of the file.- Specified by:
getBaseName
in interfaceFileName
- Returns:
- The base name. Never returns null.
-
getPath
Returns the absolute path of the file, relative to the root of the file system that the file belongs to. -
getUriTrailer
-
getPathDecoded
Description copied from interface:FileName
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
In contrast to/
as its absolute path.FileName.getPath()
the path is decoded i.e. all %nn stuff replaced by its character.- Specified by:
getPathDecoded
in interfaceFileName
- Returns:
- The path. Never returns null.
- Throws:
FileSystemException
- if the path is not correctly encoded
-
getParent
Returns the name of the parent of the file. -
getRoot
find the root of the filesystem -
getScheme
Returns the URI scheme of this file. -
getURI
Returns the absolute URI of the file. -
createURI
-
getRelativeName
Converts a file name to a relative name, relative to this file name.- Specified by:
getRelativeName
in interfaceFileName
- Parameters:
name
- The name to convert to a relative path.- Returns:
- The relative name.
- Throws:
FileSystemException
- On error.
-
getRootURI
Returns the root URI of the file system this file belongs to.- Specified by:
getRootURI
in interfaceFileName
-
getDepth
public int getDepth()Returns the depth of this file name, within its file system. -
getExtension
Returns the extension of this file name.- Specified by:
getExtension
in interfaceFileName
- Returns:
- The extension. Returns an empty string if the name has no extension.
-
isAncestor
Determines if another file name is an ancestor of this file name.- Specified by:
isAncestor
in interfaceFileName
-
isDescendent
Determines if another file name is a descendent of this file name.- Specified by:
isDescendent
in interfaceFileName
-
isDescendent
Determines if another file name is a descendent of this file name.- Specified by:
isDescendent
in interfaceFileName
-
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 aFileType.FOLDER
if it ends with an "/" else it will be aFileType.FILE
Once attached it will be changed to reflect the real type of this resource.- Specified by:
getType
in interfaceFileName
- Returns:
FileType.FOLDER
orFileType.FILE
-
checkName
Checks whether a path fits in a particular scope of another path.- Parameters:
basePath
- An absolute, normalised path.path
- An absolute, normalised path.
-
getFriendlyURI
returns a "friendly path", this is a path without a password.- Specified by:
getFriendlyURI
in interfaceFileName
-