Package org.apache.commons.vfs.provider
Class AbstractFileName
- java.lang.Object
-
- org.apache.commons.vfs.provider.AbstractFileName
-
- All Implemented Interfaces:
java.lang.Comparable,FileName
- Direct Known Subclasses:
GenericFileName,LayeredFileName,LocalFileName,VirtualFileName
public abstract class AbstractFileName extends java.lang.Object implements FileName
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 Constructor Description AbstractFileName(java.lang.String scheme, java.lang.String absPath, FileType type)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidappendRootUri(java.lang.StringBuffer buffer, boolean addPassword)Builds the root URI for this file name.static booleancheckName(java.lang.String basePath, java.lang.String path, NameScope scope)Checks whether a path fits in a particular scope of another path.intcompareTo(java.lang.Object obj)Implement Comparableabstract FileNamecreateName(java.lang.String absPath, FileType type)Factory method for creating name instances.protected java.lang.StringcreateURI()booleanequals(java.lang.Object obj)Determines if this object is equal to another.java.lang.StringgetBaseName()Returns the base name of the file.intgetDepth()Returns the depth of this file name, within its file system.java.lang.StringgetExtension()Returns the extension of this file name.java.lang.StringgetFriendlyURI()returns a "friendly path", this is a path without a password.FileNamegetParent()Returns the name of the parent of the file.java.lang.StringgetPath()Returns the absolute path of the file, relative to the root of the file system that the file belongs to.java.lang.StringgetPathDecoded()Returns the absolute path of this file, within its file system.java.lang.StringgetRelativeName(FileName name)Converts a file name to a relative name, relative to this file name.FileNamegetRoot()find the root of the filesystemjava.lang.StringgetRootURI()Returns the root URI of the file system this file belongs to.java.lang.StringgetScheme()Returns the URI scheme of this file.FileTypegetType()Returns the requested or current type of this name.java.lang.StringgetURI()Returns the absolute URI of the file.protected java.lang.StringgetUriTrailer()inthashCode()Returns the hashcode for this name.booleanisAncestor(FileName ancestor)Determines if another file name is an ancestor of this file name.booleanisDescendent(FileName descendent)Determines if another file name is a descendent of this file name.booleanisDescendent(FileName descendent, NameScope scope)Determines if another file name is a descendent of this file name.java.lang.StringtoString()Returns the URI of the file.
-
-
-
Constructor Detail
-
AbstractFileName
public AbstractFileName(java.lang.String scheme, java.lang.String absPath, FileType type)
-
-
Method Detail
-
hashCode
public int hashCode()
Returns the hashcode for this name.- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
Determines if this object is equal to another.- Overrides:
equalsin classjava.lang.Object
-
compareTo
public int compareTo(java.lang.Object obj)
Implement Comparable- Specified by:
compareToin interfacejava.lang.Comparable- Parameters:
obj- another abstractfilename
-
toString
public java.lang.String toString()
Returns the URI of the file.- Overrides:
toStringin classjava.lang.Object
-
createName
public abstract FileName createName(java.lang.String absPath, FileType type)
Factory method for creating name instances.
-
appendRootUri
protected abstract void appendRootUri(java.lang.StringBuffer buffer, boolean addPassword)Builds the root URI for this file name. Note that the root URI must not end with a separator character.
-
getBaseName
public java.lang.String getBaseName()
Returns the base name of the file.- Specified by:
getBaseNamein interfaceFileName- Returns:
- The base name. Never returns null.
-
getPath
public java.lang.String getPath()
Returns the absolute path of the file, relative to the root of the file system that the file belongs to.
-
getUriTrailer
protected java.lang.String getUriTrailer()
-
getPathDecoded
public java.lang.String getPathDecoded() throws FileSystemExceptionDescription copied from interface:FileNameReturns 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:
getPathDecodedin interfaceFileName- Returns:
- The path. Never returns null.
- Throws:
FileSystemException- if the path is not correctly encoded
-
getParent
public FileName getParent()
Returns the name of the parent of the file.
-
getRoot
public FileName getRoot()
find the root of the filesystem
-
getScheme
public java.lang.String getScheme()
Returns the URI scheme of this file.
-
getURI
public java.lang.String getURI()
Returns the absolute URI of the file.
-
createURI
protected java.lang.String createURI()
-
getRelativeName
public java.lang.String getRelativeName(FileName name) throws FileSystemException
Converts a file name to a relative name, relative to this file name.- Specified by:
getRelativeNamein interfaceFileName- Parameters:
name- The name to convert to a relative path.- Returns:
- The relative name.
- Throws:
FileSystemException- On error.
-
getRootURI
public java.lang.String getRootURI()
Returns the root URI of the file system this file belongs to.- Specified by:
getRootURIin interfaceFileName
-
getDepth
public int getDepth()
Returns the depth of this file name, within its file system.
-
getExtension
public java.lang.String getExtension()
Returns the extension of this file name.- Specified by:
getExtensionin interfaceFileName- Returns:
- The extension. Returns an empty string if the name has no extension.
-
isAncestor
public boolean isAncestor(FileName ancestor)
Determines if another file name is an ancestor of this file name.- Specified by:
isAncestorin interfaceFileName
-
isDescendent
public boolean isDescendent(FileName descendent)
Determines if another file name is a descendent of this file name.- Specified by:
isDescendentin interfaceFileName
-
isDescendent
public boolean isDescendent(FileName descendent, NameScope scope)
Determines if another file name is a descendent of this file name.- Specified by:
isDescendentin interfaceFileName
-
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 aFileType.FOLDERif 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:
getTypein interfaceFileName- Returns:
FileType.FOLDERorFileType.FILE
-
checkName
public static boolean checkName(java.lang.String basePath, java.lang.String path, NameScope scope)Checks whether a path fits in a particular scope of another path.- Parameters:
basePath- An absolute, normalised path.path- An absolute, normalised path.
-
getFriendlyURI
public java.lang.String getFriendlyURI()
returns a "friendly path", this is a path without a password.- Specified by:
getFriendlyURIin interfaceFileName
-
-