Class AbstractFileName
java.lang.Object
org.apache.commons.vfs2.provider.AbstractFileName
- All Implemented Interfaces:
Comparable<FileName>, FileName
- Direct Known Subclasses:
GenericFileName, LayeredFileName, LocalFileName, ResourceFileName, VirtualFileName
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate static final char[]private Stringprivate final Stringprivate FileTypeprivate StringFields inherited from interface FileName
EMPTY_ARRAY, ROOT_PATH, SEPARATOR, SEPARATOR_CHAR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidappendRootUri(StringBuilder buffer, boolean addPassword) Builds the root URI for this file name.static booleanChecks whether a path fits in a particular scope of another path.intImplement Comparable.abstract FileNamecreateName(String absolutePath, FileType fileType) Factory method for creating name instances.protected Stringprivate StringcreateURI(boolean useAbsolutePath, boolean usePassword) booleanReturns the base name of the file.intgetDepth()Returns the depth of this file name, within its file system.Returns the extension of this file name.Returns the URI without a password.private StringgetKey()Create a path that does not use the FileType since that field is not immutable.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 decoded path.getRelativeName(FileName name) Converts a file name to a relative name, relative to this file name.getRoot()find the root of the file system.Returns 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 Stringprivate StringinthashCode()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.booleanisFile()Checks if this file name is a name for a regular file by using its type.(package private) voidSets the type of this file e.g.toString()Returns the URI of the file.
-
Field Details
-
RESERVED_URI_CHARS
private static final char[] RESERVED_URI_CHARS -
scheme
-
absPath
-
type
-
uriString
-
baseName
-
rootUri
-
extension
-
decodedAbsPath
-
key
-
-
Constructor Details
-
AbstractFileName
-
-
Method Details
-
equals
-
hashCode
-
compareTo
Implement Comparable.- Specified by:
compareToin interfaceComparable<FileName>- Parameters:
obj- another abstract file name- Returns:
- negative number if less than, 0 if equal, positive if greater than.
-
toString
-
createName
-
appendRootUri
Builds the root URI for this file name. Note that the root URI must not end with a separator character.- Parameters:
buffer- A StringBuilder to use to construct the URI.addPassword- true if the password should be added, false otherwise.
-
getBaseName
Returns the base name of the file.- Specified by:
getBaseNamein interfaceFileName- Returns:
- The base name of the file.
-
getPath
-
getUriTrailer
-
getPathDecoded
Returns the decoded path.- Specified by:
getPathDecodedin interfaceFileName- Returns:
- The decoded path String.
- Throws:
FileSystemException- If an error occurs.
-
getParent
-
getRoot
-
getScheme
-
getURI
-
createURI
-
getKey
Create a path that does not use the FileType since that field is not immutable.- Returns:
- The key.
-
getFriendlyURI
Returns the URI without a password.- Specified by:
getFriendlyURIin interfaceFileName- Returns:
- Returns the URI without a password.
-
createURI
-
handleURISpecialCharacters
-
getRelativeName
Converts a file name to a relative name, relative to this file name.- Specified by:
getRelativeNamein interfaceFileName- Parameters:
name- The FileName.- Returns:
- The relative path to the file.
- Throws:
FileSystemException- if an error occurs.
-
getRootURI
Returns the root URI of the file system this file belongs to.- Specified by:
getRootURIin interfaceFileName- Returns:
- The URI of the root.
-
getDepth
-
getExtension
Returns the extension of this file name.- Specified by:
getExtensionin interfaceFileName- Returns:
- The file extension.
-
isAncestor
Determines if another file name is an ancestor of this file name.- Specified by:
isAncestorin interfaceFileName- Parameters:
ancestor- The FileName to check.- Returns:
- true if the FileName is an ancestor, false otherwise.
-
isDescendent
Determines if another file name is a descendent of this file name.- Specified by:
isDescendentin interfaceFileName- Parameters:
descendent- The FileName to check.- Returns:
- true if the FileName is a descendent, false otherwise.
-
isDescendent
Determines if another file name is a descendent of this file name.- Specified by:
isDescendentin interfaceFileName- Parameters:
descendent- The FileName to check.scope- The NameScope.- Returns:
- true if the FileName is a descendent, false otherwise.
-
isFile
Checks if this file name is a name for a regular file by using its type.- Specified by:
isFilein interfaceFileName- Returns:
- true if this file is a regular file.
- Throws:
FileSystemException- may be thrown by subclasses.- See Also:
-
getType
Returns the requested or current type of this name.The "requested" type is the one determined during resolving the name. n 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.
- Specified by:
getTypein interfaceFileName- Returns:
FileType.FOLDERorFileType.FILE
-
setType
Sets the type of this file e.g. when it will be attached.- Parameters:
type-FileType.FOLDERorFileType.FILE- Throws:
FileSystemException- if an error occurs.
-
checkName
Checks whether a path fits in a particular scope of another path.- Parameters:
basePath- An absolute, normalised path.path- An absolute, normalised path.scope- The NameScope.- Returns:
- true if the path fits in the scope, false otherwise.
-