|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.caucho.vfs.Path
A virtual filesystem path, essentially represented by a URL. Its API resembles a combination of the JDK File object and the URL object.
Paths are, in general, given with the canonical file separator of forward slash, '/'. The filesystems will take care of any necessary translation.
Currently available filesystems:
Field Summary | |
protected static L10N |
L
|
protected SchemeMap |
schemeMap
|
Constructor Summary | |
protected |
Path(Path root)
Creates a new Path object. |
Method Summary | |
void |
bind(Path context)
Binds the context to the current path. |
boolean |
canRead()
Tests if the file can be read. |
boolean |
canWrite()
Tests if the file can be written. |
boolean |
createNewFile()
Creates the file named by this Path and returns true if the file is new. |
Path |
createRoot()
Creates a restricted root, like the Unix chroot call. |
Path |
createRoot(SchemeMap schemeMap)
|
Path |
createTempFile(java.lang.String prefix,
java.lang.String suffix)
Creates a unique temporary file as a child of this directory. |
boolean |
equals(java.lang.Object o)
|
boolean |
exists()
Tests if the file exists. |
java.lang.Object |
getAttribute(java.lang.String name)
Gets an attribute of the object. |
java.util.Iterator |
getAttributeNames()
Returns a iterator of all attribute names set for this object. |
java.lang.String |
getContentType()
Returns the mime-type of the file. |
java.lang.String |
getFullPath()
Returns the full path, including the restricted root. |
java.lang.String |
getHost()
Returns the hostname |
long |
getLastModified()
Returns the last modified time of the file. |
long |
getLength()
Returns the length of the file in bytes. |
java.lang.String |
getNativePath()
Returns the native representation of the path. |
java.lang.Object |
getObject()
Returns the object at this path. |
Path |
getParent()
Returns the parent path. |
abstract java.lang.String |
getPath()
Returns the path. |
int |
getPort()
Returns the port. |
java.lang.String |
getQuery()
Returns the query string of the path. |
abstract java.lang.String |
getScheme()
Returns the url scheme |
java.lang.String |
getTail()
Returns the last segment of the path. |
java.lang.String |
getURL()
Returns the full url for the given path. |
java.lang.String |
getUserPath()
Returns the last string used as a lookup, if available. |
java.lang.Object |
getValue()
Gets the object at the path. |
boolean |
isDirectory()
Tests if the path refers to a directory. |
boolean |
isFile()
Tests if the path refers to a file. |
boolean |
isObject()
Tests if the path refers to an object. |
java.util.Iterator |
iterator()
Returns a jdk1.2 Iterator for the contents of this directory. |
java.lang.String[] |
list()
|
Path |
lookup(java.lang.String name)
Looks up a new path based on the old path. |
Path |
lookup(java.lang.String userPath,
java.util.Map newAttributes)
Returns a new path relative to the current one. |
Path |
lookupNative(java.lang.String name)
Looks up a path using the local filesystem conventions. |
Path |
lookupNative(java.lang.String name,
java.util.Map attributes)
Looks up a native path, adding attributes. |
boolean |
mkdir()
Creates the directory named by this path. |
boolean |
mkdirs()
Creates the directory named by this path and any parent directories. |
WriteStream |
openAppend()
Opens a resin stream for appending. |
protected StreamImpl |
openAppendImpl()
|
ReadStream |
openRead()
Opens a resin ReadStream for reading. |
protected StreamImpl |
openReadImpl()
|
ReadWritePair |
openReadWrite()
Opens a resin ReadWritePair for reading and writing. |
protected StreamImpl |
openReadWriteImpl()
|
WriteStream |
openWrite()
Opens a resin WriteStream for writing. |
protected StreamImpl |
openWriteImpl()
|
boolean |
remove()
Removes the file or directory named by this path. |
void |
removeAttribute(java.lang.String name)
Remove an attribute. |
boolean |
renameTo(Path path)
Renames the file or directory to the name given by the path. |
boolean |
renameTo(java.lang.String path)
Renames the file or directory to the name given by the path. |
protected java.lang.String |
scanScheme(java.lang.String uri)
Returns the scheme portion of a uri. |
protected abstract Path |
schemeWalk(java.lang.String userPath,
java.util.Map newAttributes,
java.lang.String newPath,
int offset)
Path-specific lookup. |
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets an attribute of the path. |
void |
setLastModified(long time)
|
void |
setObject(java.lang.Object obj)
Sets the object at this path. |
void |
setUserPath(java.lang.String userPath)
Sets the user path. |
void |
setValue(java.lang.Object obj)
Sets the object at the path. |
java.lang.String |
toString()
|
void |
unbind()
unbinds a link. |
void |
writeToStream(java.io.OutputStream os)
Utility to write the contents of this path to the destination stream. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static L10N L
protected SchemeMap schemeMap
Constructor Detail |
protected Path(Path root)
root
- the new Path root.Method Detail |
public final Path lookup(java.lang.String name)
name
- relative url to the new pathpublic Path lookup(java.lang.String userPath, java.util.Map newAttributes)
Path only handles scheme:xxx. Subclasses of Path will specialize the xxx.
userPath
- relative or absolute path, essentially any url.newAttributes
- attributes for the new path.public final Path lookupNative(java.lang.String name)
name
- relative url using local filesystem separators.public Path lookupNative(java.lang.String name, java.util.Map attributes)
public Path getParent()
protected java.lang.String scanScheme(java.lang.String uri)
protected abstract Path schemeWalk(java.lang.String userPath, java.util.Map newAttributes, java.lang.String newPath, int offset)
userPath
- the user's lookup() path.newAttributes
- the attributes for the new path.newPath
- the lookup() pathoffset
- offset into newPath to start lookup.public java.lang.String getURL()
public abstract java.lang.String getScheme()
public java.lang.String getHost()
public int getPort()
public abstract java.lang.String getPath()
public java.lang.String getTail()
e.g. for http://www.caucho.com/products/index.html, getTail() returns 'index.html'
public java.lang.String getQuery()
public java.lang.String getNativePath()
public java.lang.String getUserPath()
Path path = Pwd.lookup("/some/dir").lookup("../test.html");
System.out.println(path.getUserPath());
public void setUserPath(java.lang.String userPath)
public java.lang.String getFullPath()
For the following, path.getPath() returns '/file.html', while
path.getFullPath() returns '/chroot/file.html'.
Path chroot = Pwd.lookup("/chroot").createRoot();
Path path = chroot.lookup("/file.html");
public boolean exists()
public java.lang.String getContentType()
Mime-type ignorant filesystems return 'application/octet-stream'
public boolean isDirectory()
public boolean isFile()
public boolean isObject()
public long getLength()
public long getLastModified()
public void setLastModified(long time)
public boolean canRead()
public boolean canWrite()
public java.lang.String[] list() throws java.io.IOException
public java.util.Iterator iterator() throws java.io.IOException
public boolean mkdir() throws java.io.IOException
public boolean mkdirs() throws java.io.IOException
public boolean remove() throws java.io.IOException
public boolean renameTo(Path path) throws java.io.IOException
public final boolean renameTo(java.lang.String path) throws java.io.IOException
public Path createRoot()
createRoot is useful for restricting JavaScript scripts without resorting to the dreadfully slow security manager.
public Path createRoot(SchemeMap schemeMap)
public void bind(Path context)
public void unbind()
public java.lang.Object getValue() throws java.lang.Exception
A bean filesystem or a mime-type aware filesystem could deserialize the contents of the file.
public void setValue(java.lang.Object obj) throws java.lang.Exception
Normal filesystems will generally do nothing. However, a bean filesystem or a mime-type aware filesystem could serialize the object and store it.
public java.lang.Object getAttribute(java.lang.String name) throws java.io.IOException
public void setAttribute(java.lang.String name, java.lang.Object value) throws java.io.IOException
public void removeAttribute(java.lang.String name) throws java.io.IOException
public java.util.Iterator getAttributeNames() throws java.io.IOException
public final ReadStream openRead() throws java.io.IOException
public final WriteStream openWrite() throws java.io.IOException
public ReadWritePair openReadWrite() throws java.io.IOException
A chat channel, for example, would open its socket using this interface.
public WriteStream openAppend() throws java.io.IOException
public boolean createNewFile() throws java.io.IOException
public Path createTempFile(java.lang.String prefix, java.lang.String suffix) throws java.io.IOException
prefix
- filename prefixsuffix
- filename suffix, defaults to .tmppublic void writeToStream(java.io.OutputStream os) throws java.io.IOException
os
- destination stream.public java.lang.Object getObject() throws java.io.IOException
public void setObject(java.lang.Object obj) throws java.io.IOException
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
protected StreamImpl openReadImpl() throws java.io.IOException
protected StreamImpl openWriteImpl() throws java.io.IOException
protected StreamImpl openReadWriteImpl() throws java.io.IOException
protected StreamImpl openAppendImpl() throws java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |