com.partnersoft.io.vfs
Interface VfsNode

All Known Subinterfaces:
VfsDirectory, VfsFile
All Known Implementing Classes:
AbstractVfsDirectory, AbstractVfsFile, NonexistentVfsDirectory, NonexistentVfsFile

public interface VfsNode

Abstract node in a hierarchical filesystem (specifically a Vfs).

This interface encapsulates the behavior common to both VfsFile and VfsDirectory. Many of the search and listing features may return both types, so we need a common supertype to capture that as well.

Copyright 2004-2007 Partner Software, Inc.

Version:
$Id: VfsNode.java 2013 2009-08-10 03:29:31Z paul $
Author:
Paul Reavis

Method Summary
 boolean exists()
          Whether the Vfs node exists.
 Path getAbsolutePath()
          The absolute path to the Vfs node.
 java.lang.String getBaseName()
          Base name of node; this is the part before the '.' if there's a file extension.
 VfsDirectory getDirectory()
          The VfsDirectory this node is in, or null if it is the root directory.
 java.lang.String getExtension()
          File extension (the part after the '.' in most file names; includes the '.').
 java.lang.String getName()
          Bare name of node.
 Path getPath()
          The path to the Vfs node.
 java.net.URI getUri()
          URI for this VfsNode.
 java.net.URL getUrl()
          URL for this VfsNode.
 Vfs getVfs()
          The Vfs this node is in.
 boolean isBackup()
          True if the file is a backup file - commonly this is based on file name patterns like *~ or *.bak.
 boolean isHidden()
          True if the file is a hidden file - commonly this is based on the file name starting with a ".".
 void make()
          Creates the node and any ancestor directories needed to contain it.
 java.io.File toFile()
          java.io.File for this VfsNode.
 

Method Detail

exists

boolean exists()
               throws java.io.IOException
Whether the Vfs node exists. VfsNode objects serve as addresses as well as handles, so they may not point to existing resources. Use make() to create the node if it does not exist.

Returns:
true if node exists
Throws:
java.io.IOException - if it can't tell for some reason.

make

void make()
          throws java.io.IOException
Creates the node and any ancestor directories needed to contain it.

Throws:
java.io.IOException - if it can't.

getPath

Path getPath()
The path to the Vfs node.

Returns:
path to Vfs node.

getAbsolutePath

Path getAbsolutePath()
The absolute path to the Vfs node. This has different meanings in different contexts.


getVfs

Vfs getVfs()
The Vfs this node is in.

Returns:
Vfs this node is in.

getDirectory

VfsDirectory getDirectory()
The VfsDirectory this node is in, or null if it is the root directory.


getName

java.lang.String getName()
Bare name of node. name = baseName + extension

Returns:
name of node.

getBaseName

java.lang.String getBaseName()
Base name of node; this is the part before the '.' if there's a file extension. name = baseName + extension


getExtension

java.lang.String getExtension()
File extension (the part after the '.' in most file names; includes the '.'). Returns the blank string "" if there is none. name = baseName + extension


getUrl

java.net.URL getUrl()
URL for this VfsNode. Returns null if for some reason a URL cannot be supplied or is not applicable.


getUri

java.net.URI getUri()
URI for this VfsNode. Returns null if for some reason a URI cannot be supplied or is not applicable.


toFile

java.io.File toFile()
java.io.File for this VfsNode. Returns null if it's not a regular file (e.g. in a URL-based VFS).


isBackup

boolean isBackup()
True if the file is a backup file - commonly this is based on file name patterns like *~ or *.bak.


isHidden

boolean isHidden()
True if the file is a hidden file - commonly this is based on the file name starting with a ".".