|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The Filesystem interface defines a means of interacting with a particular persistant storage mechanism. The same interface is used for both read/write and read-only filesystems, with exceptions thrown as appropriate to indicate situations when writing is not allowed.
Individual files are identified by a Url which is translated by a filesystem implementation into a meaningful underlying representation. The appropriate filesystem for a given Url is determined by examining the Url's protocol. The VFS provides a registration procedure for associating a filesystem instance with a protocol string.
Three filesystem implementations are provided with JBuilder: FileFilesystem for a "file://" Url, ZipFilesystem for a "zip://" Url, and NewFilesystem for a "new://" Url.
Url
,
VFS
,
FileFilesystem
,
ZipFilesystem
,
NewFilesystem
Field Summary | |
static int |
TYPE_BOTH
|
static int |
TYPE_DIRECTORY
|
static int |
TYPE_FILE
|
Method Summary | |
void |
delete(Url url)
Deletes the specified resource. |
boolean |
exists(Url url)
Tests if the specified resource actually exists. |
boolean |
fileEquals(Url url,
Url otherUrl)
Compares the file portion of two Url objects in a case sensitive manner. |
int |
fileHashCode(Url url)
Produces a hash value for the file portion of a Url compatible with the definition of equality provided by fileEquals . |
Url |
getCanonicalUrl(Url url)
Reports the exact Url representation of a resource. |
Url |
getChild(Url url,
java.lang.String subpath)
Creates a new Url that adds the specified subpath to an existing Url's file path. |
Url[] |
getChildren(Url url,
RegularExpression[] patterns,
int type)
Retrieves a list of children within a container, such as files within a directory. |
java.io.File |
getFileObject(Url url)
Describes a Url in terms of a java.io.File instance. |
java.io.InputStream |
getInputStream(Url url)
Creates an InputStream that reads from the specified Url. |
long |
getLastModified(Url url)
Reports the time at which the contents of this resource were last modified. |
java.lang.String |
getName(Url url)
Returns a short name for the Url. |
java.io.OutputStream |
getOutputStream(Url url,
boolean makeBackup)
Creates an OutputStream that writes to the specified Url. |
Url |
getParent(Url url)
Returns a Url with the last subpath from the supplied Url's file path removed. |
java.lang.String |
getProtocol()
|
java.lang.String |
getRelativePath(Url root,
Url target,
boolean onlyChildren)
Create a relative path from an root Url to specified target Url. |
Url |
getRelativeUrl(Url root,
java.lang.String relativePath)
Create a relative path from an root Url to specified target Url. |
boolean |
isDirectory(Url url)
Tests if the specified resource represents a container of other resources. |
boolean |
isReadOnly(Url url)
Tests if the specified resource is read only. |
boolean |
isValid(Url url)
Determines whether the state of a Url instance is valid. |
Field Detail |
public static final int TYPE_DIRECTORY
public static final int TYPE_FILE
public static final int TYPE_BOTH
Method Detail |
public java.lang.String getProtocol()
public java.io.InputStream getInputStream(Url url) throws java.io.IOException
java.io.FileNotFoundException
.url
- The resource to be read.public java.io.OutputStream getOutputStream(Url url, boolean makeBackup) throws java.io.IOException
The filesystem should automatically take care of any necessary details to make this possible, such as creating directories on a file-based filesystem. One exception to this rule is that a filesystem should not make a read only file read/write in order to accomplish this goal. BWS: What about read only directories?
url
- The resource to be written.makeBackup
- True if the filesystem should make a backup first.public boolean isReadOnly(Url url)
url
- The resource to be tested.public long getLastModified(Url url)
url
- The resource to be tested.public boolean exists(Url url)
url
- The resource to be tested.public void delete(Url url) throws java.io.IOException
url
- The resource to be deleted.public boolean isDirectory(Url url)
url
- The resource to be tested.public java.lang.String getName(Url url)
public Url[] getChildren(Url url, RegularExpression[] patterns, int type)
url
- The container resource.pattern
- An array of regular expressions constraining the set of
values that will be returned. Only children whose final path component
exactly matches at least one of the patterns will be represented in the
resulting array. Note that a null array matches all children and that
directories are not compared against the patterns, only files.type
- The constants TYPE_DIRECTORY
,
TYPE_FILE
, and TYPE_BOTH
can be used to control
the type of resources that are represented in the result array.public Url getChild(Url url, java.lang.String subpath)
url
- The existing Url.subpath
- The subpath to be added to the Url's file path.public Url getParent(Url url)
url
- The Url for which a parent is desired.public java.io.File getFileObject(Url url)
java.io.File
instance. Note
that this may not be appropriate for many filesystem types, and will
return null in these cases.url
- The Url in question.public Url getCanonicalUrl(Url url)
url
- The resource.public Url getRelativeUrl(Url root, java.lang.String relativePath)
root
- The Url root.relativePath
- The relative path from the root.public java.lang.String getRelativePath(Url root, Url target, boolean onlyChildren)
root
- The Url root.target
- The Url target.onlyChildren
- True if the target must be a descendant of the root,
false if absolute paths and paths with leading "../" entries should be
considered.public boolean isValid(Url url)
url
- The Url in question.public int fileHashCode(Url url)
fileEquals
.url
- The Url to produce a hash value based on.public boolean fileEquals(Url url, Url otherUrl)
url
- The first of the two Urls to be compared.otherUrl
- The second of the two Urls to be compared.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |