| Method from org.jboss.virtual.VirtualFile Detail: |
protected void checkStreams() {
if (streams == null)
{
synchronized (closed)
{
// double null check, so that possible
// waiting threads don't override streams
if (streams == null)
streams = Collections.synchronizedSet(new WeakSet());
}
}
}
Check if streams set exist. |
public void cleanup() {
try
{
getHandler().cleanup();
}
finally
{
VFS.cleanup(this);
}
}
Do file cleanup.
e.g. delete temp files |
public void close() {
if (closed.getAndSet(true) == false)
{
closeStreams();
handler.close();
}
}
Close the file resources (stream, etc.) |
public void closeStreams() {
if (streams == null)
return;
// Close the streams
for (InputStream stream : streams)
{
if (stream != null)
{
try
{
stream.close();
}
catch (IOException ignored)
{
}
}
}
streams.clear();
}
|
public boolean delete() throws IOException {
// gracePeriod of 2 seconds
return getHandler().delete(2000);
}
|
public boolean delete(int gracePeriod) throws IOException {
return getHandler().delete(gracePeriod);
}
|
public boolean equals(Object obj) {
if (obj == this)
return true;
if (obj == null || obj instanceof VirtualFile == false)
return false;
VirtualFile other = (VirtualFile) obj;
return handler.equals(other.handler);
}
|
public boolean exists() throws IOException {
return getHandler().exists();
}
Tests whether the underlying implementation file still exists. |
public VirtualFile findChild(String path) throws IOException {
if (path == null)
throw new IllegalArgumentException("Null path");
VirtualFileHandler handler = getHandler();
VirtualFileHandler child = handler.getChild(VFSUtils.fixName(path));
if (child == null)
{
List< VirtualFileHandler > children = handler.getChildren(true);
throw new IOException("Child not found " + path + " for " + handler + ", available children: " + children);
}
return child.getVirtualFile();
} Deprecated! use - getChild, and handle null if not found
|
public VirtualFile getChild(String path) throws IOException {
if (path == null)
throw new IllegalArgumentException("Null path");
VirtualFileHandler handler = getHandler();
VirtualFileHandler child = handler.getChild(VFSUtils.fixName(path));
return child != null ? child.getVirtualFile() : null;
}
|
public List<VirtualFile> getChildren() throws IOException {
return getChildren(null);
}
|
public List<VirtualFile> getChildren(VirtualFileFilter filter) throws IOException {
if (isLeaf())
return Collections.emptyList();
if (filter == null)
filter = MatchAllVirtualFileFilter.INSTANCE;
FilterVirtualFileVisitor visitor = new FilterVirtualFileVisitor(filter, null);
visit(visitor);
return visitor.getMatched();
}
|
public List<VirtualFile> getChildrenRecursively() throws IOException {
return getChildrenRecursively(null);
}
|
public List<VirtualFile> getChildrenRecursively(VirtualFileFilter filter) throws IOException {
if (isLeaf())
return Collections.emptyList();
if (filter == null)
filter = MatchAllVirtualFileFilter.INSTANCE;
FilterVirtualFileVisitor visitor = new FilterVirtualFileVisitor(filter, VisitorAttributes.RECURSE);
visit(visitor);
return visitor.getMatched();
}
|
VirtualFileHandler getHandler() {
if (closed.get())
throw new IllegalStateException("The virtual file is closed");
return handler;
}
Get the virtual file handler |
public long getLastModified() throws IOException {
return getHandler().getLastModified();
}
When the file was last modified |
public String getName() {
return getHandler().getName();
}
Get the simple VF name (X.java) |
public VirtualFile getParent() throws IOException {
VirtualFileHandler parent = getHandler().getParent();
if (parent != null)
return parent.getVirtualFile();
return null;
}
|
public String getPathName() {
return getHandler().getPathName();
}
Get the VFS relative path name (org/jboss/X.java) |
public long getSize() throws IOException {
return getHandler().getSize();
}
|
public VFS getVFS() {
VFSContext context = getHandler().getVFSContext();
return context.getVFS();
}
Get the VFS instance for this virtual file |
public boolean hasBeenModified() throws IOException {
return getHandler().hasBeenModified();
}
Returns true if the file has been modified since this method was last called
Last modified time is initialized at handler instantiation. |
public int hashCode() {
return handler.hashCode();
}
|
public boolean isArchive() throws IOException {
return getHandler().isArchive();
}
|
public boolean isHidden() throws IOException {
return getHandler().isHidden();
}
|
public boolean isLeaf() throws IOException {
return getHandler().isLeaf();
}
Whether it is a simple leaf of the VFS,
i.e. whether it can contain other files |
public InputStream openStream() throws IOException {
InputStream result = getHandler().openStream();
checkStreams();
streams.add(result);
return result;
}
Access the file contents. |
public String toString() {
return handler.toString();
}
|
public URI toURI() throws MalformedURLException, URISyntaxException {
return VFSUtils.toURI(toURL());
}
Get the VF URI (file://root/org/jboss/X.java) |
public URL toURL() throws MalformedURLException, URISyntaxException {
return getHandler().toVfsUrl();
}
Get the VF URL (file://root/org/jboss/X.java) |
public void visit(VirtualFileVisitor visitor) throws IOException {
if (isLeaf() == false)
getVFS().visit(this, visitor);
}
Visit the virtual file system |