com.caucho.vfs
Class FilesystemPath

java.lang.Object
  |
  +--com.caucho.vfs.Path
        |
        +--com.caucho.vfs.FilesystemPath
Direct Known Subclasses:
CachePath, FilePath, HttpPath, JarPath, JndiPath, MemoryPath, MergePath

public abstract class FilesystemPath
extends Path

Abstract FilesystemPath, the parent of hierarchical Paths like FilePath or HttpPath.


Field Summary
protected  com.caucho.vfs.BindPath bindRoot
           
protected  java.lang.String pathname
           
protected  FilesystemPath root
           
protected  char separatorChar
           
protected  java.lang.String userPath
           
 
Fields inherited from class com.caucho.vfs.Path
L, schemeMap
 
Constructor Summary
protected FilesystemPath(FilesystemPath root, java.lang.String userPath, java.lang.String pathname)
          Create a new filesystemPath
 
Method Summary
 void bind(Path context)
          Binds the context to the current path.
 Path copy()
           
 Path createRoot(SchemeMap schemeMap)
          Essentially chroot
 boolean equals(java.lang.Object b)
           
protected abstract  Path fsWalk(java.lang.String userPath, java.util.Map newAttributes, java.lang.String newPath)
          Lookup a path relative to the current filesystem's root.
 java.lang.String getFullPath()
          For chrooted filesystems return the real system path.
 Path getParent()
          Return the parent Path
 java.lang.String getPath()
          Returns the path portion of the URL.
 java.lang.String getTail()
          Returns the last segment of the path.
 java.lang.String getURL()
          Returns the URL for this filesystem path.
 java.lang.String getUserPath()
          Returns the last string used as a lookup, if available.
 int hashCode()
           
protected static void normalizePath(CharBuffer cb, java.lang.String oldPath, java.lang.String newPath, int offset, char separatorChar)
          Normalizes a filesystemPath path.
protected static java.lang.String normalizePath(java.lang.String oldPath, java.lang.String newPath, int offset, char separatorChar)
          wrapper for the real normalize path routine to use CharBuffer.
protected  Path schemeWalk(java.lang.String userPath, java.util.Map attributes, java.lang.String filePath, int offset)
          schemeWalk is called by Path for a scheme lookup like file:/tmp/foo
 void setUserPath(java.lang.String path)
          Sets the user path.
 java.lang.String toString()
           
 
Methods inherited from class com.caucho.vfs.Path
canRead, canWrite, createNewFile, createRoot, createTempFile, exists, getAttribute, getAttributeNames, getContentType, getHost, getLastModified, getLength, getNativePath, getObject, getPort, getQuery, getScheme, getValue, isDirectory, isFile, isObject, iterator, list, lookup, lookup, lookupNative, lookupNative, mkdir, mkdirs, openAppend, openAppendImpl, openRead, openReadImpl, openReadWrite, openReadWriteImpl, openWrite, openWriteImpl, remove, removeAttribute, renameTo, renameTo, scanScheme, setAttribute, setLastModified, setObject, setValue, unbind, writeToStream
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

root

protected FilesystemPath root

bindRoot

protected com.caucho.vfs.BindPath bindRoot

pathname

protected java.lang.String pathname

userPath

protected java.lang.String userPath

separatorChar

protected char separatorChar
Constructor Detail

FilesystemPath

protected FilesystemPath(FilesystemPath root,
                         java.lang.String userPath,
                         java.lang.String pathname)
Create a new filesystemPath
Parameters:
root - Root of url space
userPath - the user's path
pathname - Canonical path
Method Detail

getParent

public Path getParent()
Return the parent Path
Overrides:
getParent in class Path

schemeWalk

protected Path schemeWalk(java.lang.String userPath,
                          java.util.Map attributes,
                          java.lang.String filePath,
                          int offset)
schemeWalk is called by Path for a scheme lookup like file:/tmp/foo
Overrides:
schemeWalk in class Path
Parameters:
userPath - the user's lookup() path
attributes - the user's attributes
filePath - the actual lookup() path
offset - offset into filePath

fsWalk

protected abstract Path fsWalk(java.lang.String userPath,
                               java.util.Map newAttributes,
                               java.lang.String newPath)
Lookup a path relative to the current filesystem's root. Filesystems will specialize fsWalk.
Parameters:
userPath - the exact string passed by the user's lookup()
newAttributes - the user's new attributes
newPath - the normalized real path
Returns:
the matching path

normalizePath

protected static java.lang.String normalizePath(java.lang.String oldPath,
                                                java.lang.String newPath,
                                                int offset,
                                                char separatorChar)
wrapper for the real normalize path routine to use CharBuffer.
Parameters:
oldPath - The parent Path's path
newPath - The user's new path
offset - Offset into the user path
Returns:
the normalized path

normalizePath

protected static void normalizePath(CharBuffer cb,
                                    java.lang.String oldPath,
                                    java.lang.String newPath,
                                    int offset,
                                    char separatorChar)
Normalizes a filesystemPath path.
Parameters:
cb - charBuffer holding the normalized result
oldPath - the parent path
newPath - the relative path
offset - where in the child path to start

getURL

public java.lang.String getURL()
Returns the URL for this filesystem path.
Overrides:
getURL in class Path

getPath

public java.lang.String getPath()
Returns the path portion of the URL.
Overrides:
getPath in class Path

getUserPath

public java.lang.String getUserPath()
Description copied from class: Path
Returns the last string used as a lookup, if available. This allows parsers to give intelligent error messages, with the user's path instead of the whole path. The following will print '../test.html':
 Path path = Pwd.lookup("/some/dir").lookup("../test.html");
 System.out.println(path.getUserPath());
 
Overrides:
getUserPath in class Path

setUserPath

public void setUserPath(java.lang.String path)
Description copied from class: Path
Sets the user path. Useful for temporary files caching another URL.
Overrides:
setUserPath in class Path

getFullPath

public java.lang.String getFullPath()
For chrooted filesystems return the real system path.
Overrides:
getFullPath in class Path

getTail

public java.lang.String getTail()
Description copied from class: Path
Returns the last segment of the path.

e.g. for http://www.caucho.com/products/index.html, getTail() returns 'index.html'

Overrides:
getTail in class Path

createRoot

public Path createRoot(SchemeMap schemeMap)
Essentially chroot
Overrides:
createRoot in class Path

bind

public void bind(Path context)
Description copied from class: Path
Binds the context to the current path. Later lookups will return the new context instead of the current path. Essentially, this is a software symbolic link.
Overrides:
bind in class Path

copy

public Path copy()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object b)
Overrides:
equals in class Path

toString

public java.lang.String toString()
Overrides:
toString in class Path