Package org.apache.commons.vfs2
Interface FileName
-
- All Superinterfaces:
java.lang.Comparable<FileName>
- All Known Implementing Classes:
AbstractFileName,GenericFileName,GenericURLFileName,LayeredFileName,LocalFileName,ResourceFileName,UrlFileName,URLFileName,VirtualFileName,WindowsFileName
public interface FileName extends java.lang.Comparable<FileName>
Represents a file name. File names are immutable, and work correctly as keys in hash tables.- See Also:
FileObject
-
-
Field Summary
Fields Modifier and Type Field Description static FileName[]EMPTY_ARRAYEmpty array of FileName.static java.lang.StringROOT_PATHThe absolute path of the root of a file system.static java.lang.StringSEPARATORThe separator used in file paths.static charSEPARATOR_CHARThe separator character used in file paths.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.StringgetBaseName()Gets the base name of this file.intgetDepth()Gets the depth of this file name, within its file system.java.lang.StringgetExtension()Gets the extension of this file name.java.lang.StringgetFriendlyURI()Gets a "friendly path", this is a path without a password.FileNamegetParent()Gets the file name of the parent of this file.java.lang.StringgetPath()Gets the absolute path string of this file, within its file system.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()Gets the root of the file system.java.lang.StringgetRootURI()Gets the root URI string of the file system this file belongs to.java.lang.StringgetScheme()Gets the URI scheme of this file.FileTypegetType()Gets the requested or current type of this name.java.lang.StringgetURI()Gets the absolute URI string of this file.booleanisAncestor(FileName ancestor)Tests if another file name is an ancestor of this file name.booleanisDescendent(FileName descendent)Tests if another file name is a descendent of this file name.booleanisDescendent(FileName descendent, NameScope nameScope)Tests if another file name is a descendent of this file name.booleanisFile()Tests if this file name is a name for a regular file.
-
-
-
Field Detail
-
SEPARATOR_CHAR
static final char SEPARATOR_CHAR
The separator character used in file paths.- See Also:
- Constant Field Values
-
SEPARATOR
static final java.lang.String SEPARATOR
The separator used in file paths.- See Also:
- Constant Field Values
-
ROOT_PATH
static final java.lang.String ROOT_PATH
The absolute path of the root of a file system.- See Also:
- Constant Field Values
-
EMPTY_ARRAY
static final FileName[] EMPTY_ARRAY
Empty array of FileName.- Since:
- 2.8.0
-
-
Method Detail
-
getBaseName
java.lang.String getBaseName()
Gets the base name of this file. The base name is the last element of the file name. For example the base name of/somefolder/somefileissomefile.The root file of a file system has an empty base name.
- Returns:
- The base name. Never returns null.
-
getDepth
int getDepth()
Gets 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.- Returns:
- The depth of this file name.
-
getExtension
java.lang.String getExtension()
Gets the extension of this file name.- Returns:
- The extension. Returns an empty string if the name has no extension.
-
getFriendlyURI
java.lang.String getFriendlyURI()
Gets a "friendly path", this is a path without a password.This path cannot be used to resolve the path again.
- Returns:
- the friendly URI as a String.
-
getParent
FileName getParent()
Gets the file name of the parent of this file. The root of a file system has no parent.- Returns:
- A
FileNameobject representing the parent name. Returns null for the root of a file system.
-
getPath
java.lang.String getPath()
Gets the absolute path string of this file, within its file system. This path is normalized, 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
java.lang.String getPathDecoded() throws FileSystemException
Returns the absolute path of this file, within its file system. This path is normalized, 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(), this path is decoded: All %nn escapes are replaced by their respective characters.- Returns:
- The decoded path. Never returns null.
- Throws:
FileSystemException- if the path is not correctly encoded
-
getRelativeName
java.lang.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.
-
getRootURI
java.lang.String getRootURI()
Gets the root URI string of the file system this file belongs to.- Returns:
- the root URI string.
-
getScheme
java.lang.String getScheme()
Gets the URI scheme of this file.- Returns:
- The URI scheme of this file.
-
getType
FileType getType()
Gets 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.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.
- Returns:
FileType.FOLDERorFileType.FILE
-
getURI
java.lang.String getURI()
Gets the absolute URI string of this file.- Returns:
- the absolute URI string of this file.
-
isAncestor
boolean isAncestor(FileName ancestor)
Tests if another file name is an ancestor of this file name.- Parameters:
ancestor- The FileName to check.- Returns:
- true if another file name is an ancestor of this file name.
-
isDescendent
boolean isDescendent(FileName descendent)
Tests if another file name is a descendent of this file name.- Parameters:
descendent- the FileName to check.- Returns:
- true if the other FileName is a descendent of this file name.
-
isDescendent
boolean isDescendent(FileName descendent, NameScope nameScope)
Tests if another file name is a descendent of this file name.- Parameters:
descendent- the FileName to check.nameScope- the NameScope of the FileName.- Returns:
- true if the other FileName is a descendent of this file name.
-
isFile
boolean isFile() throws FileSystemException
Tests if this file name is a name for a regular file.- Returns:
- true if this file name is a name for a regular file.
- Throws:
FileSystemException- if an error occurs.- Since:
- 2.1
- See Also:
getType(),FileType.FILE
-
-