org.apache.commons.vfs2.provider.http
Class HttpFileObject

java.lang.Object
  extended by org.apache.commons.vfs2.provider.AbstractFileObject
      extended by org.apache.commons.vfs2.provider.http.HttpFileObject
All Implemented Interfaces:
FileObject
Direct Known Subclasses:
WebdavFileObject

public class HttpFileObject
extends AbstractFileObject

A file object backed by commons httpclient.

Author:
Commons VFS team

Constructor Summary
protected HttpFileObject(AbstractFileName name, HttpFileSystem fileSystem)
           
 
Method Summary
protected  void doDetach()
          Detaches this file object from its file resource.
protected  long doGetContentSize()
          Returns the size of the file content (in bytes).
protected  java.io.InputStream doGetInputStream()
          Creates an input stream to read the file content from.
protected  long doGetLastModifiedTime()
          Returns the last modified time of this file.
protected  RandomAccessContent doGetRandomAccessContent(RandomAccessMode mode)
          Creates access to the file for random i/o.
protected  FileType doGetType()
          Determines the type of this file.
protected  java.lang.String[] doListChildren()
          Lists the children of this file.
protected  java.lang.String encodePath(java.lang.String decodedPath)
           
protected  FileContentInfoFactory getFileContentInfoFactory()
          create the filecontentinfo implementation.
protected  void setupMethod(HttpMethod method)
          Prepares a Method object.
 
Methods inherited from class org.apache.commons.vfs2.provider.AbstractFileObject
canRenameTo, childrenChanged, close, copyFrom, createFile, createFolder, delete, delete, doAttach, doCreateFileContent, doCreateFolder, doDelete, doGetAttributes, doGetCertificates, doGetOutputStream, doIsHidden, doIsReadable, doIsSameFile, doIsWriteable, doListChildrenResolved, doRemoveAttribute, doRename, doSetAttribute, doSetLastModifiedTime, endOutput, exists, finalize, findFiles, findFiles, getChild, getChildren, getContent, getFileOperations, getFileSystem, getInputStream, getName, getOutputStream, getOutputStream, getParent, getRandomAccessContent, getType, getURL, handleChanged, handleCreate, handleDelete, holdObject, injectType, isAttached, isContentOpen, isHidden, isReadable, isSameFile, isWriteable, moveTo, notifyAllStreamsClosed, onChange, onChildrenChanged, refresh, resolveFile, resolveFile, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HttpFileObject

protected HttpFileObject(AbstractFileName name,
                         HttpFileSystem fileSystem)
Method Detail

doDetach

protected void doDetach()
                 throws java.lang.Exception
Detaches this file object from its file resource.

Overrides:
doDetach in class AbstractFileObject
Throws:
java.lang.Exception - if an error occurs.

doGetType

protected FileType doGetType()
                      throws java.lang.Exception
Determines the type of this file. Must not return null. The return value of this method is cached, so the implementation can be expensive.

Specified by:
doGetType in class AbstractFileObject
Returns:
the type of the file.
Throws:
java.lang.Exception - if an error occurs.

doListChildren

protected java.lang.String[] doListChildren()
                                     throws java.lang.Exception
Lists the children of this file.

Specified by:
doListChildren in class AbstractFileObject
Returns:
a possible empty String array if the file is a directory or null or an exception if the file is not a directory or can't be read.
Throws:
java.lang.Exception - if an error occurs.

doGetContentSize

protected long doGetContentSize()
                         throws java.lang.Exception
Returns the size of the file content (in bytes).

Specified by:
doGetContentSize in class AbstractFileObject
Returns:
The size of the file in bytes.
Throws:
java.lang.Exception - if an error occurs.

doGetLastModifiedTime

protected long doGetLastModifiedTime()
                              throws java.lang.Exception
Returns the last modified time of this file.

This implementation throws an exception.

Overrides:
doGetLastModifiedTime in class AbstractFileObject
Returns:
The last modification time.
Throws:
java.lang.Exception - if an error occurs.

doGetInputStream

protected java.io.InputStream doGetInputStream()
                                        throws java.lang.Exception
Creates an input stream to read the file content from. Is only called if doGetType() returns FileType.FILE.

It is guaranteed that there are no open output streams for this file when this method is called.

The returned stream does not have to be buffered.

Specified by:
doGetInputStream in class AbstractFileObject
Returns:
An InputStream to read the file content.
Throws:
java.lang.Exception - if an error occurs.

doGetRandomAccessContent

protected RandomAccessContent doGetRandomAccessContent(RandomAccessMode mode)
                                                throws java.lang.Exception
Description copied from class: AbstractFileObject
Creates access to the file for random i/o. Is only called if AbstractFileObject.doGetType() returns FileType.FILE.

It is guaranteed that there are no open output streams for this file when this method is called.

Overrides:
doGetRandomAccessContent in class AbstractFileObject
Parameters:
mode - The mode to access the file.
Returns:
The RandomAccessContext.
Throws:
java.lang.Exception - if an error occurs.

setupMethod

protected void setupMethod(HttpMethod method)
                    throws FileSystemException,
                           URIException
Prepares a Method object.

Throws:
FileSystemException
URIException
Since:
2.0 (was package)

encodePath

protected java.lang.String encodePath(java.lang.String decodedPath)
                               throws URIException
Throws:
URIException

getFileContentInfoFactory

protected FileContentInfoFactory getFileContentInfoFactory()
Description copied from class: AbstractFileObject
create the filecontentinfo implementation.

Overrides:
getFileContentInfoFactory in class AbstractFileObject
Returns:
The FileContentInfoFactory.