public final class VirtualFile
extends java.lang.Object
implements java.io.Serializable
VirtualFile instance gives no guarantees as to the presence or immutability of the referenced file or any of its
parent path elements.| Modifier and Type | Field and Description |
|---|---|
private int |
hashCode |
private java.lang.String |
lcname |
private java.lang.String |
name |
private VirtualFile |
parent |
private java.lang.String |
pathName |
private static long |
serialVersionUID |
| Constructor and Description |
|---|
VirtualFile(java.lang.String name,
VirtualFile parent) |
| Modifier and Type | Method and Description |
|---|---|
java.net.URI |
asDirectoryURI()
Get file's URI as a directory.
|
java.net.URL |
asDirectoryURL()
Get file's URL as a directory.
|
java.net.URI |
asFileURI()
Get file's URI as a file.
|
java.net.URL |
asFileURL()
Get file's URL as a file.
|
boolean |
delete()
Delete this virtual file
|
private static <T> T |
doIoPrivileged(java.security.PrivilegedExceptionAction<T> action) |
boolean |
equals(java.lang.Object o)
Determine whether the given object is equal to this one.
|
boolean |
equals(VirtualFile o)
Determine whether the given object is equal to this one.
|
boolean |
exists()
Tests whether the underlying implementation file still exists.
|
java.security.cert.Certificate[] |
getCertificates()
Get the
Certificates for the virtual file. |
VirtualFile |
getChild(java.lang.String path)
Get a child virtual file.
|
java.util.List<VirtualFile> |
getChildren()
Get the children.
|
java.util.List<VirtualFile> |
getChildren(VirtualFileFilter filter)
Get the children
|
java.util.List<VirtualFile> |
getChildrenRecursively()
Get all the children recursively
|
java.util.List<VirtualFile> |
getChildrenRecursively(VirtualFileFilter filter)
Get all the children recursively
|
java.security.CodeSigner[] |
getCodeSigners()
Get the
CodeSigners for a the virtual file. |
long |
getLastModified()
When the file was last modified
|
java.lang.String |
getLowerCaseName()
Deprecated.
should not be used anymore, as the code is case-sensitive from JBVFS-170
|
java.lang.String |
getName()
Get the simple VF name (X.java)
|
VirtualFile |
getParent()
Get a
VirtualFile which represents the parent of this instance. |
java.util.List<VirtualFile> |
getParentFileList()
Get the all the parent files of this virtual file from this file to the root as a list.
|
VirtualFile[] |
getParentFiles()
Get the all the parent files of this virtual file from this file to the root.
|
private VirtualFile[] |
getParentFiles(int idx) |
java.lang.String |
getPathName()
Get the absolute VFS full path name (/xxx/yyy/foo.ear/baz.jar/org/jboss/X.java)
|
(package private) java.lang.String |
getPathName(boolean url)
Get the absolute VFS full path name.
|
java.lang.String |
getPathNameRelativeTo(VirtualFile parent)
Get the path name relative to a parent virtual file.
|
private void |
getPathNameRelativeTo(VirtualFile parent,
java.lang.StringBuilder builder) |
java.io.File |
getPhysicalFile()
Get a physical file for this virtual file.
|
long |
getSize()
Get the size
|
int |
hashCode()
Get a hashcode for this virtual file.
|
boolean |
isDirectory()
Determine whether the named virtual file is a directory.
|
boolean |
isFile()
Determine whether the named virtual file is a plain file.
|
boolean |
isLeaf()
Deprecated.
use
isDirectory() or isFile() instead |
boolean |
isRoot()
Determines whether this virtual file represents a true root of a file system.
|
java.io.InputStream |
openStream()
Access the file contents.
|
java.lang.String |
toString()
Get a human-readable (but non-canonical) representation of this virtual file.
|
java.net.URI |
toURI()
Get file's current URI.
|
java.net.URL |
toURL()
Get file's current URL.
|
void |
visit(VirtualFileVisitor visitor)
Visit the virtual file system
|
private void |
visit(VirtualFileVisitor visitor,
boolean root) |
private static final long serialVersionUID
private final java.lang.String name
private final java.lang.String lcname
private final VirtualFile parent
private final int hashCode
private java.lang.String pathName
VirtualFile(java.lang.String name,
VirtualFile parent)
public java.lang.String getName()
public java.lang.String getLowerCaseName()
public java.lang.String getPathName()
public java.lang.String getPathNameRelativeTo(VirtualFile parent) throws java.lang.IllegalArgumentException
IllegalArgumentException is thrown.parent - the parent virtual filejava.lang.IllegalArgumentException - if the given virtual file is not a parent of this virtual fileprivate void getPathNameRelativeTo(VirtualFile parent, java.lang.StringBuilder builder)
java.lang.String getPathName(boolean url)
url - whether or not this path is being used for a URLpublic long getLastModified()
public long getSize()
public boolean exists()
public boolean isRoot()
true if this represents a root.@Deprecated public boolean isLeaf()
isDirectory() or isFile() insteadtrue if a simple filepublic boolean isFile()
true if it is a plain file, false otherwisepublic boolean isDirectory()
true if it is a directory, false otherwisepublic java.io.InputStream openStream()
throws java.io.IOException
java.io.IOException - for any error accessing the file systempublic boolean delete()
true if file was deletedpublic java.io.File getPhysicalFile()
throws java.io.IOException
java.io.IOException - if an I/O error occurs while producing the physical fileprivate static <T> T doIoPrivileged(java.security.PrivilegedExceptionAction<T> action)
throws java.io.IOException
java.io.IOExceptionpublic VirtualFile getParent()
VirtualFile which represents the parent of this instance.null if there is no parentpublic VirtualFile[] getParentFiles()
public java.util.List<VirtualFile> getParentFileList()
private VirtualFile[] getParentFiles(int idx)
public java.util.List<VirtualFile> getChildren()
public java.util.List<VirtualFile> getChildren(VirtualFileFilter filter) throws java.io.IOException
filter - to filter the childrenjava.io.IOException - for any problem accessing the virtual file systemjava.lang.IllegalStateException - if the file is closed or it is a leaf nodepublic java.util.List<VirtualFile> getChildrenRecursively() throws java.io.IOException
This always uses
VisitorAttributes.RECURSEjava.io.IOException - for any problem accessing the virtual file systemjava.lang.IllegalStateException - if the file is closedpublic java.util.List<VirtualFile> getChildrenRecursively(VirtualFileFilter filter) throws java.io.IOException
This always uses
VisitorAttributes.RECURSEfilter - to filter the childrenjava.io.IOException - for any problem accessing the virtual file systemjava.lang.IllegalStateException - if the file is closed or it is a leaf nodepublic void visit(VirtualFileVisitor visitor) throws java.io.IOException
visitor - the visitorjava.io.IOException - for any problem accessing the virtual file systemjava.lang.IllegalArgumentException - if the visitor is nulljava.lang.IllegalStateException - if the file is closedprivate void visit(VirtualFileVisitor visitor, boolean root) throws java.io.IOException
java.io.IOExceptionpublic VirtualFile getChild(java.lang.String path)
path - the pathjava.lang.IllegalArgumentException - if the path is nullpublic java.net.URL toURL()
throws java.net.MalformedURLException
java.net.MalformedURLException - if the URL is somehow malformedasDirectoryURL(),
asFileURL()public java.net.URI toURI()
throws java.net.URISyntaxException
java.net.URISyntaxException - if the URI is somehow malformedasDirectoryURI(),
asFileURI()public java.net.URL asDirectoryURL()
throws java.net.MalformedURLException
"/" character.java.net.MalformedURLException - if the URL is somehow malformedpublic java.net.URI asDirectoryURI()
throws java.net.URISyntaxException
"/" character.java.net.URISyntaxException - if the URI is somehow malformedpublic java.net.URL asFileURL()
throws java.net.MalformedURLException
"/" character unless this VirtualFile
represents a root.java.net.MalformedURLException - if the URL is somehow malformedpublic java.net.URI asFileURI()
throws java.net.URISyntaxException
"/" character unless this VirtualFile
represents a root.java.net.URISyntaxException - if the URI is somehow malformedpublic java.security.CodeSigner[] getCodeSigners()
CodeSigners for a the virtual file.CodeSigners for the virtual file, or null if not signedpublic java.security.cert.Certificate[] getCertificates()
Certificates for the virtual file. Simply extracts the certificate entries from
the code signers array.null if not signedpublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object o)
VirtualFile
from the same VFS instance with the same name.equals in class java.lang.Objecto - the other objecttrue if they are equalpublic boolean equals(VirtualFile o)
VirtualFile
from the same VFS instance with the same name.o - the other virtual filetrue if they are equalpublic int hashCode()
hashCode in class java.lang.Object