com.caucho.vfs
Class HttpPath

java.lang.Object
  |
  +--com.caucho.vfs.Path
        |
        +--com.caucho.vfs.FilesystemPath
              |
              +--com.caucho.vfs.HttpPath

public class HttpPath
extends FilesystemPath

The HTTP scheme. Currently it supports GET and POST.

TODO: support WEBDAV, enabling the full Path API.


Field Summary
protected static LruCache cache
           
protected  com.caucho.vfs.HttpPath.CacheEntry cacheEntry
           
protected  java.lang.String host
           
protected static L10N L
           
protected  int port
           
protected  java.lang.String query
           
 
Fields inherited from class com.caucho.vfs.FilesystemPath
bindRoot, pathname, root, separatorChar, userPath
 
Fields inherited from class com.caucho.vfs.Path
schemeMap
 
Method Summary
 boolean canRead()
          Returns true if the file is readable.
 boolean equals(java.lang.Object o)
          Overrides equals to test for equality with an HTTP path.
 boolean exists()
          Returns true if the file exists.
protected  Path fsWalk(java.lang.String userPath, java.util.Map attributes, java.lang.String uri)
          Scans the path portion of the URI, i.e.
protected  com.caucho.vfs.HttpPath.CacheEntry getCache()
           
 java.lang.String getHost()
          Returns the host part of the url.
 long getLastModified()
          Returns the last modified time.
 long getLength()
          Returns the file's length
 int getPort()
          Returns the port part of the url.
 java.lang.String getQuery()
          Returns the query string.
 java.lang.String getScheme()
          Returns the scheme, http.
 java.lang.String getURL()
          Returns a full URL for the path.
 java.lang.String getUserPath()
          Returns the user's path.
 int hashCode()
          Returns a hashCode for the path.
 boolean isDirectory()
          Returns the last modified time.
 boolean isFile()
          Returns true if the file exists.
 Path lookup(java.lang.String userPath, java.util.Map newAttributes)
          Overrides the default lookup to parse the host and port before parsing the path.
 StreamImpl openReadImpl()
          Returns a read stream for a GET request.
 StreamImpl openReadWriteImpl()
          Returns a read/write pair for a POST request.
protected  Path schemeWalk(java.lang.String userPath, java.util.Map attributes, java.lang.String uri, int offset)
          Walk down the path starting from the portion immediately following the scheme.
 java.lang.String toString()
          Returns the string form of the http path.
 
Methods inherited from class com.caucho.vfs.FilesystemPath
bind, copy, createRoot, getFullPath, getParent, getPath, getTail, normalizePath, normalizePath, setUserPath
 
Methods inherited from class com.caucho.vfs.Path
canWrite, createNewFile, createRoot, createTempFile, getAttribute, getAttributeNames, getContentType, getNativePath, getObject, getResources, getResources, getValue, isObject, iterator, list, lookup, lookupNative, lookupNative, mkdir, mkdirs, openAppend, openAppendImpl, openRead, openReadWrite, openReadWrite, 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

L

protected static L10N L

cache

protected static LruCache cache

host

protected java.lang.String host

port

protected int port

query

protected java.lang.String query

cacheEntry

protected com.caucho.vfs.HttpPath.CacheEntry cacheEntry
Method Detail

lookup

public Path lookup(java.lang.String userPath,
                   java.util.Map newAttributes)
Overrides the default lookup to parse the host and port before parsing the path.
Overrides:
lookup in class Path
Parameters:
userPath - the path passed in by the user
newAttributes - attributes passed by the user
Returns:
the final path.

schemeWalk

protected Path schemeWalk(java.lang.String userPath,
                          java.util.Map attributes,
                          java.lang.String uri,
                          int offset)
Walk down the path starting from the portion immediately following the scheme. i.e. schemeWalk is responsible for parsing the host and port from the URL.
Overrides:
schemeWalk in class FilesystemPath
Parameters:
userPath - the user's passed in path
attributes - the attributes for the new path
uri - the normalized full uri
offset - offset into the uri to start processing, i.e. after the scheme.
Returns:
the looked-up path.

fsWalk

protected Path fsWalk(java.lang.String userPath,
                      java.util.Map attributes,
                      java.lang.String uri)
Scans the path portion of the URI, i.e. everything after the host and port.
Overrides:
fsWalk in class FilesystemPath
Parameters:
userPath - the user's supplied path
attributes - the attributes for the new path
uri - the full uri for the new path.
Returns:
the found path.

getScheme

public java.lang.String getScheme()
Returns the scheme, http.
Overrides:
getScheme in class Path

getURL

public java.lang.String getURL()
Returns a full URL for the path.
Overrides:
getURL in class FilesystemPath

getHost

public java.lang.String getHost()
Returns the host part of the url.
Overrides:
getHost in class Path

getPort

public int getPort()
Returns the port part of the url.
Overrides:
getPort in class Path

getUserPath

public java.lang.String getUserPath()
Returns the user's path.
Overrides:
getUserPath in class FilesystemPath

getQuery

public java.lang.String getQuery()
Returns the query string.
Overrides:
getQuery in class Path

getLastModified

public long getLastModified()
Returns the last modified time.
Overrides:
getLastModified in class Path
Following copied from class: com.caucho.vfs.Path
Returns:
0 for non-files.

getLength

public long getLength()
Returns the file's length
Overrides:
getLength in class Path
Following copied from class: com.caucho.vfs.Path
Returns:
0 for non-files

exists

public boolean exists()
Returns true if the file exists.
Overrides:
exists in class Path

isFile

public boolean isFile()
Returns true if the file exists.
Overrides:
isFile in class Path

canRead

public boolean canRead()
Returns true if the file is readable.
Overrides:
canRead in class Path

isDirectory

public boolean isDirectory()
Returns the last modified time.
Overrides:
isDirectory in class Path

getCache

protected com.caucho.vfs.HttpPath.CacheEntry getCache()

openReadImpl

public StreamImpl openReadImpl()
                        throws java.io.IOException
Returns a read stream for a GET request.
Overrides:
openReadImpl in class Path

openReadWriteImpl

public StreamImpl openReadWriteImpl()
                             throws java.io.IOException
Returns a read/write pair for a POST request.
Overrides:
openReadWriteImpl in class Path

toString

public java.lang.String toString()
Returns the string form of the http path.
Overrides:
toString in class FilesystemPath

hashCode

public int hashCode()
Returns a hashCode for the path.
Overrides:
hashCode in class FilesystemPath

equals

public boolean equals(java.lang.Object o)
Overrides equals to test for equality with an HTTP path.
Overrides:
equals in class FilesystemPath