Class HttpFileObject<FS extends HttpFileSystem>
- java.lang.Object
-
- org.apache.commons.vfs2.provider.AbstractFileObject<FS>
-
- org.apache.commons.vfs2.provider.http.HttpFileObject<FS>
-
- Type Parameters:
FS
- AnHttpFileSystem
subclass
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Comparable<FileObject>
,java.lang.Iterable<FileObject>
,FileObject
public class HttpFileObject<FS extends HttpFileSystem> extends AbstractFileObject<FS>
A file object backed by Apache Commons HttpClient.TODO - status codes.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
HttpFileObject(AbstractFileName name, FS fileSystem)
protected
HttpFileObject(AbstractFileName name, FS fileSystem, HttpFileSystemConfigBuilder builder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 boolean
doIsWriteable()
Determines if this file can be written to.protected java.lang.String[]
doListChildren()
Lists the children of this file.protected java.lang.String
encodePath(java.lang.String decodedPath)
protected FileContentInfoFactory
getFileContentInfoFactory()
Creates the FileContentInfo factory.protected boolean
getFollowRedirect()
protected java.lang.String
getUrlCharset()
protected java.lang.String
getUserAgent()
protected void
setupMethod(org.apache.commons.httpclient.HttpMethod method)
Prepares a HttpMethod object.-
Methods inherited from class org.apache.commons.vfs2.provider.AbstractFileObject
canRenameTo, childrenChanged, close, compareTo, copyFrom, createFile, createFolder, delete, delete, deleteAll, doAttach, doCreateFileContent, doCreateFolder, doDelete, doGetAttributes, doGetCertificates, doGetOutputStream, doIsExecutable, doIsHidden, doIsReadable, doIsSameFile, doListChildrenResolved, doRemoveAttribute, doRename, doSetAttribute, doSetExecutable, doSetLastModifiedTime, doSetReadable, doSetWritable, endOutput, exists, finalize, findFiles, findFiles, getAbstractFileSystem, getChild, getChildren, getContent, getFileOperations, getFileSystem, getInputStream, getName, getOutputStream, getOutputStream, getParent, getPublicURIString, getRandomAccessContent, getType, getURL, handleChanged, handleCreate, handleDelete, holdObject, injectType, isAttached, isContentOpen, isExecutable, isFile, isFolder, isHidden, isReadable, isSameFile, isWriteable, iterator, listFiles, moveTo, notifyAllStreamsClosed, onChange, onChildrenChanged, refresh, resolveFile, resolveFile, setExecutable, setReadable, setWritable, toString
-
-
-
-
Constructor Detail
-
HttpFileObject
protected HttpFileObject(AbstractFileName name, FS fileSystem)
-
HttpFileObject
protected HttpFileObject(AbstractFileName name, FS fileSystem, HttpFileSystemConfigBuilder builder)
-
-
Method Detail
-
doDetach
protected void doDetach() throws java.lang.Exception
Detaches this file object from its file resource.- Overrides:
doDetach
in classAbstractFileObject<FS extends HttpFileSystem>
- 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 classAbstractFileObject<FS extends HttpFileSystem>
- Returns:
- The size of the file in bytes.
- 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 ifdoGetType()
returnsFileType.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 classAbstractFileObject<FS extends HttpFileSystem>
- Returns:
- An InputStream to read the file content.
- 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 classAbstractFileObject<FS extends HttpFileSystem>
- Returns:
- The last modification time.
- 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 ifAbstractFileObject.doGetType()
returnsFileType.FILE
.It is guaranteed that there are no open output streams for this file when this method is called.
- Overrides:
doGetRandomAccessContent
in classAbstractFileObject<FS extends HttpFileSystem>
- Parameters:
mode
- The mode to access the file.- Returns:
- The RandomAccessContext.
- 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 classAbstractFileObject<FS extends HttpFileSystem>
- Returns:
- the type of the file.
- Throws:
java.lang.Exception
- if an error occurs.
-
doIsWriteable
protected boolean doIsWriteable() throws java.lang.Exception
Description copied from class:AbstractFileObject
Determines if this file can be written to. Is only called ifAbstractFileObject.doGetType()
does not returnFileType.IMAGINARY
.This implementation always returns true.
- Overrides:
doIsWriteable
in classAbstractFileObject<FS extends HttpFileSystem>
- Returns:
- true if the file is writable.
- 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 classAbstractFileObject<FS extends HttpFileSystem>
- 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.
-
encodePath
protected java.lang.String encodePath(java.lang.String decodedPath) throws org.apache.commons.httpclient.URIException
- Throws:
org.apache.commons.httpclient.URIException
-
getFileContentInfoFactory
protected FileContentInfoFactory getFileContentInfoFactory()
Description copied from class:AbstractFileObject
Creates the FileContentInfo factory.- Overrides:
getFileContentInfoFactory
in classAbstractFileObject<FS extends HttpFileSystem>
- Returns:
- The FileContentInfoFactory.
-
getFollowRedirect
protected boolean getFollowRedirect()
-
getUserAgent
protected java.lang.String getUserAgent()
-
getUrlCharset
protected java.lang.String getUrlCharset()
-
setupMethod
protected void setupMethod(org.apache.commons.httpclient.HttpMethod method) throws FileSystemException, org.apache.commons.httpclient.URIException
Prepares a HttpMethod object.- Parameters:
method
- The object which gets prepared to access the file object.- Throws:
FileSystemException
- if an error occurs.org.apache.commons.httpclient.URIException
- if path cannot be represented.- Since:
- 2.0 (was package)
-
-