public abstract class AbstractFileName extends java.lang.Object implements FileName
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
absPath |
private java.lang.String |
baseName |
private java.lang.String |
decodedAbsPath |
private java.lang.String |
extension |
private java.lang.String |
key |
private static char[] |
RESERVED_URI_CHARS |
private java.lang.String |
rootUri |
private java.lang.String |
scheme |
private FileType |
type |
private java.lang.String |
uri |
ROOT_PATH, SEPARATOR, SEPARATOR_CHAR
Constructor and Description |
---|
AbstractFileName(java.lang.String scheme,
java.lang.String absPath,
FileType type) |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
appendRootUri(java.lang.StringBuilder buffer,
boolean addPassword)
Builds the root URI for this file name.
|
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.
|
int |
compareTo(FileName obj)
Implement Comparable.
|
abstract FileName |
createName(java.lang.String absolutePath,
FileType fileType)
Factory method for creating name instances.
|
protected java.lang.String |
createURI() |
private java.lang.String |
createURI(boolean useAbsolutePath,
boolean usePassword) |
boolean |
equals(java.lang.Object o) |
java.lang.String |
getBaseName()
Returns the base name of the file.
|
int |
getDepth()
Returns the depth of this file name, within its file system.
|
java.lang.String |
getExtension()
Returns the extension of this file name.
|
java.lang.String |
getFriendlyURI()
Returns the URI without a password.
|
private java.lang.String |
getKey()
Create a path that does not use the FileType since that field is not immutable.
|
FileName |
getParent()
Returns the name of the parent of the file.
|
java.lang.String |
getPath()
Returns the absolute path of the file, relative to the root of the file system that the file belongs to.
|
java.lang.String |
getPathDecoded()
Returns the decoded path.
|
java.lang.String |
getRelativeName(FileName name)
Converts a file name to a relative name, relative to this file name.
|
FileName |
getRoot()
find the root of the file system.
|
java.lang.String |
getRootURI()
Returns the root URI of the file system this file belongs to.
|
java.lang.String |
getScheme()
Returns the URI scheme of this file.
|
FileType |
getType()
Returns the requested or current type of this name.
|
java.lang.String |
getURI()
Returns the absolute URI of the file.
|
protected java.lang.String |
getUriTrailer() |
private java.lang.String |
handleURISpecialCharacters(java.lang.String uri) |
int |
hashCode() |
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.
|
boolean |
isFile()
Checks if this file name is a name for a regular file by using its type.
|
(package private) void |
setType(FileType type)
Sets the type of this file e.g.
|
java.lang.String |
toString()
Returns the URI of the file.
|
private static final char[] RESERVED_URI_CHARS
private final java.lang.String scheme
private final java.lang.String absPath
private FileType type
private java.lang.String uri
private java.lang.String baseName
private java.lang.String rootUri
private java.lang.String extension
private java.lang.String decodedAbsPath
private java.lang.String key
public AbstractFileName(java.lang.String scheme, java.lang.String absPath, FileType type)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public int compareTo(FileName obj)
compareTo
in interface java.lang.Comparable<FileName>
obj
- another abstract file namepublic java.lang.String toString()
toString
in class java.lang.Object
public abstract FileName createName(java.lang.String absolutePath, FileType fileType)
absolutePath
- The absolute path.fileType
- The FileType.protected abstract void appendRootUri(java.lang.StringBuilder buffer, boolean addPassword)
buffer
- A StringBuilder to use to construct the URI.addPassword
- true if the password should be added, false otherwise.public java.lang.String getBaseName()
getBaseName
in interface FileName
public java.lang.String getPath()
protected java.lang.String getUriTrailer()
public java.lang.String getPathDecoded() throws FileSystemException
getPathDecoded
in interface FileName
FileSystemException
- If an error occurs.public FileName getParent()
public FileName getRoot()
public java.lang.String getScheme()
public java.lang.String getURI()
protected java.lang.String createURI()
private java.lang.String getKey()
public java.lang.String getFriendlyURI()
getFriendlyURI
in interface FileName
private java.lang.String createURI(boolean useAbsolutePath, boolean usePassword)
private java.lang.String handleURISpecialCharacters(java.lang.String uri)
public java.lang.String getRelativeName(FileName name) throws FileSystemException
getRelativeName
in interface FileName
name
- The FileName.FileSystemException
- if an error occurs.public java.lang.String getRootURI()
getRootURI
in interface FileName
public int getDepth()
public java.lang.String getExtension()
getExtension
in interface FileName
public boolean isAncestor(FileName ancestor)
isAncestor
in interface FileName
ancestor
- The FileName to check.public boolean isDescendent(FileName descendent)
isDescendent
in interface FileName
descendent
- The FileName to check.public boolean isDescendent(FileName descendent, NameScope scope)
isDescendent
in interface FileName
descendent
- The FileName to check.scope
- The NameScope.public boolean isFile() throws FileSystemException
isFile
in interface FileName
FileSystemException
- may be thrown by subclasses.getType()
,
FileType.FILE
public FileType getType()
The "requested" type is the one determined during resolving the name. n 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.
getType
in interface FileName
FileType.FOLDER
or FileType.FILE
void setType(FileType type) throws FileSystemException
type
- FileType.FOLDER
or FileType.FILE
FileSystemException
- if an error occurs.public static boolean checkName(java.lang.String basePath, java.lang.String path, NameScope scope)
basePath
- An absolute, normalised path.path
- An absolute, normalised path.scope
- The NameScope.