Class Http4FileObject<FS extends Http4FileSystem>
java.lang.Object
org.apache.commons.vfs2.provider.AbstractFileObject<FS>
org.apache.commons.vfs2.provider.http4.Http4FileObject<FS>
- Type Parameters:
FS- AnHttp4FileSystemsubclass
- All Implemented Interfaces:
Closeable, AutoCloseable, Comparable<FileObject>, Iterable<FileObject>, FileObject
A file object backed by Apache HttpComponents HttpClient.
- Since:
- 2.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final URIInternal URI mapped to thisFileObject.private org.apache.http.HttpResponseThe last executed HEADHttpResponseobject.private final StringURL charset string.Fields inherited from class AbstractFileObject
DEFAULT_BUFFER_SIZEFields inherited from interface FileObject
EMPTY_ARRAY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHttp4FileObject(AbstractFileName name, FS fileSystem) ConstructHttp4FileObject.protectedHttp4FileObject(AbstractFileName name, FS fileSystem, Http4FileSystemConfigBuilder builder) ConstructHttp4FileObject. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoDetach()Detaches this file object from its file resource.protected longReturns the size of the file content (in bytes).protected InputStreamdoGetInputStream(int bufferSize) Creates an input stream to read the file content from.protected longReturns the last modified time of this file.protected RandomAccessContentCreates access to the file for random i/o.protected FileTypeDetermines the type of this file.protected booleanDetermines if this file can be written to.protected String[]Lists the children of this file.protected org.apache.http.HttpResponseexecuteHttpUriRequest(org.apache.http.client.methods.HttpUriRequest httpRequest) Execute the request using the givenhttpRequestand return aHttpResponsefrom the execution.protected FileContentInfoFactoryCreates the FileContentInfo factory.protected URIReturn the internalURIobject mapped to this file object.(package private) org.apache.http.HttpResponseReturn the last executed HEADHttpResponseobject.protected StringReturn URL charset string.Methods inherited from class AbstractFileObject
canRenameTo, childrenChanged, close, compareTo, copyFrom, createFile, createFolder, delete, delete, deleteAll, doAttach, doCreateFileContent, doCreateFolder, doDelete, doGetAttributes, doGetCertificates, doGetInputStream, doGetOutputStream, doIsExecutable, doIsHidden, doIsReadable, doIsSameFile, doIsSymbolicLink, doListChildrenResolved, doRemoveAttribute, doRename, doSetAttribute, doSetExecutable, doSetLastModifiedTime, doSetReadable, doSetWritable, endOutput, exists, finalize, findFiles, findFiles, getAbstractFileSystem, getChild, getChildren, getContent, getFileOperations, getFileSystem, getInputStream, getInputStream, getName, getOutputStream, getOutputStream, getParent, getPublicURIString, getRandomAccessContent, getType, getURL, handleChanged, handleCreate, handleDelete, holdObject, injectType, isAttached, isContentOpen, isExecutable, isFile, isFolder, isHidden, isReadable, isSameFile, isSymbolicLink, isWriteable, iterator, listFiles, moveTo, notifyAllStreamsClosed, onChange, onChildrenChanged, refresh, resolveFile, resolveFile, setExecutable, setReadable, setWritable, toStringMethods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface FileObject
getPath, getURIMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
urlCharset
URL charset string. -
internalURI
Internal URI mapped to thisFileObject. For example, the internal URI ofhttp4://example.com/a.txtishttp://example.com/a.txt. -
lastHeadResponse
private org.apache.http.HttpResponse lastHeadResponseThe last executed HEADHttpResponseobject.
-
-
Constructor Details
-
Http4FileObject
ConstructHttp4FileObject.- Parameters:
name- file namefileSystem- file system- Throws:
FileSystemException- if any error occurs
-
Http4FileObject
protected Http4FileObject(AbstractFileName name, FS fileSystem, Http4FileSystemConfigBuilder builder) throws FileSystemException ConstructHttp4FileObject.- Parameters:
name- file namefileSystem- file systembuilder-Http4FileSystemConfigBuilderobject- Throws:
FileSystemException- if any error occurs
-
-
Method Details
-
doDetach
Description copied from class:AbstractFileObjectDetaches this file object from its file resource.Called when this file is closed. Note that the file object may be reused later, so should be able to be reattached.
This implementation does nothing.
- Overrides:
doDetachin classAbstractFileObject<FS extends Http4FileSystem>- Throws:
Exception- if an error occurs.
-
doGetContentSize
Description copied from class:AbstractFileObjectReturns the size of the file content (in bytes). Is only called ifAbstractFileObject.doGetType()returnsFileType.FILE.- Specified by:
doGetContentSizein classAbstractFileObject<FS extends Http4FileSystem>- Returns:
- The size of the file in bytes.
- Throws:
Exception- if an error occurs.
-
doGetInputStream
Description copied from class:AbstractFileObjectCreates an input stream to read the file content from. 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.
The returned stream does not have to be buffered.
- Overrides:
doGetInputStreamin classAbstractFileObject<FS extends Http4FileSystem>- Parameters:
bufferSize- Buffer size hint.- Returns:
- An InputStream to read the file content.
- Throws:
Exception- if an error occurs.
-
doGetLastModifiedTime
Description copied from class:AbstractFileObjectReturns the last modified time of this file. Is only called ifAbstractFileObject.doGetType()does not returnThis implementation throws an exception.
- Overrides:
doGetLastModifiedTimein classAbstractFileObject<FS extends Http4FileSystem>- Returns:
- The last modification time.
- Throws:
Exception- if an error occurs.
-
doGetRandomAccessContent
Description copied from class:AbstractFileObjectCreates 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:
doGetRandomAccessContentin classAbstractFileObject<FS extends Http4FileSystem>- Parameters:
mode- The mode to access the file.- Returns:
- The RandomAccessContext.
- Throws:
Exception- if an error occurs.
-
doGetType
Description copied from class:AbstractFileObjectDetermines 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:
doGetTypein classAbstractFileObject<FS extends Http4FileSystem>- Returns:
- the type of the file.
- Throws:
Exception- if an error occurs.
-
doIsWriteable
Description copied from class:AbstractFileObjectDetermines if this file can be written to. Is only called ifAbstractFileObject.doGetType()does not returnFileType.IMAGINARY.This implementation always returns true.
- Overrides:
doIsWriteablein classAbstractFileObject<FS extends Http4FileSystem>- Returns:
- true if the file is writable.
- Throws:
Exception- if an error occurs.
-
doListChildren
Description copied from class:AbstractFileObjectLists the children of this file. Is only called ifAbstractFileObject.doGetType()returnsFileType.FOLDER. The return value of this method is cached, so the implementation can be expensive.- Specified by:
doListChildrenin classAbstractFileObject<FS extends Http4FileSystem>- 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:
Exception- if an error occurs.
-
executeHttpUriRequest
protected org.apache.http.HttpResponse executeHttpUriRequest(org.apache.http.client.methods.HttpUriRequest httpRequest) throws IOException Execute the request using the givenhttpRequestand return aHttpResponsefrom the execution.- Parameters:
httpRequest-HttpUriRequestobject- Returns:
HttpResponsefrom the execution- Throws:
IOException- if IO error occurs- Since:
- 2.5.0
-
getFileContentInfoFactory
Description copied from class:AbstractFileObjectCreates the FileContentInfo factory.- Overrides:
getFileContentInfoFactoryin classAbstractFileObject<FS extends Http4FileSystem>- Returns:
- The FileContentInfoFactory.
-
getInternalURI
Return the internalURIobject mapped to this file object.- Returns:
- the internal
URIobject mapped to this file object
-
getLastHeadResponse
Return the last executed HEADHttpResponseobject.- Returns:
- the last executed HEAD
HttpResponseobject - Throws:
IOException- if IO error occurs
-
getUrlCharset
-