Class TarFileObject
- java.lang.Object
-
- org.apache.commons.vfs2.provider.AbstractFileObject<TarFileSystem>
-
- org.apache.commons.vfs2.provider.tar.TarFileObject
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Comparable<FileObject>
,java.lang.Iterable<FileObject>
,FileObject
public class TarFileObject extends AbstractFileObject<TarFileSystem>
A file in a Tar file system.
-
-
Field Summary
-
Fields inherited from class org.apache.commons.vfs2.provider.AbstractFileObject
DEFAULT_BUFFER_SIZE
-
Fields inherited from interface org.apache.commons.vfs2.FileObject
EMPTY_ARRAY
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TarFileObject(AbstractFileName fileName, org.apache.commons.compress.archivers.tar.TarArchiveEntry entry, TarFileSystem fileSystem, boolean tarExists)
Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
attachChild(FileName childName)
Attaches a child.protected long
doGetContentSize()
Returns the size of the file content (in bytes).protected java.io.InputStream
doGetInputStream(int bufferSize)
Creates an input stream to read the file content from.protected long
doGetLastModifiedTime()
Returns the last modified time of this file.protected FileType
doGetType()
Returns the file's type.protected java.lang.String[]
doListChildren()
Lists the children of the file.boolean
isWriteable()
Determines if this file can be written to.protected void
setTarEntry(org.apache.commons.compress.archivers.tar.TarArchiveEntry entry)
Sets the details for this file 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, doDetach, doGetAttributes, doGetCertificates, doGetInputStream, doGetOutputStream, doGetRandomAccessContent, doIsExecutable, doIsHidden, doIsReadable, doIsSameFile, doIsSymbolicLink, doIsWriteable, doListChildrenResolved, doRemoveAttribute, doRename, doSetAttribute, doSetExecutable, doSetLastModifiedTime, doSetReadable, doSetWritable, endOutput, exists, finalize, findFiles, findFiles, getAbstractFileSystem, getChild, getChildren, getContent, getFileContentInfoFactory, 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, iterator, listFiles, moveTo, notifyAllStreamsClosed, onChange, onChildrenChanged, refresh, resolveFile, resolveFile, setExecutable, setReadable, setWritable, toString
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.commons.vfs2.FileObject
getPath, getURI
-
-
-
-
Constructor Detail
-
TarFileObject
protected TarFileObject(AbstractFileName fileName, org.apache.commons.compress.archivers.tar.TarArchiveEntry entry, TarFileSystem fileSystem, boolean tarExists)
Constructs a new instance.- Parameters:
fileName
- the file name.entry
- the archive entry.fileSystem
- the file system.tarExists
- whether the tar file exists.
-
-
Method Detail
-
attachChild
protected void attachChild(FileName childName)
Attaches a child.- Parameters:
childName
- Name of child to remember.
-
doGetContentSize
protected long doGetContentSize()
Returns the size of the file content (in bytes). Is only called ifdoGetType()
returnsFileType.FILE
.- Specified by:
doGetContentSize
in classAbstractFileObject<TarFileSystem>
- Returns:
- The size of the file in bytes.
-
doGetInputStream
protected java.io.InputStream doGetInputStream(int bufferSize) throws java.lang.Exception
Creates an input stream to read the file content from. Is only called ifdoGetType()
returnsFileType.FILE
. The input stream returned by this method is guaranteed to be closed before this method is called again.- Overrides:
doGetInputStream
in classAbstractFileObject<TarFileSystem>
- Parameters:
bufferSize
- Buffer size hint.- 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.- Overrides:
doGetLastModifiedTime
in classAbstractFileObject<TarFileSystem>
- Returns:
- The last modification time.
- Throws:
java.lang.Exception
- if an error occurs.
-
doGetType
protected FileType doGetType()
Returns the file's type.- Specified by:
doGetType
in classAbstractFileObject<TarFileSystem>
- Returns:
- the type of the file.
-
doListChildren
protected java.lang.String[] doListChildren()
Lists the children of the file.- Specified by:
doListChildren
in classAbstractFileObject<TarFileSystem>
- 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.
-
isWriteable
public boolean isWriteable() throws FileSystemException
Determines if this file can be written to.- Specified by:
isWriteable
in interfaceFileObject
- Overrides:
isWriteable
in classAbstractFileObject<TarFileSystem>
- Returns:
true
if this file is writable,false
if not.- Throws:
FileSystemException
- if an error occurs.
-
setTarEntry
protected void setTarEntry(org.apache.commons.compress.archivers.tar.TarArchiveEntry entry)
Sets the details for this file object. Consider this method package private. TODO Might be made package private in the next major version.- Parameters:
entry
- Tar archive entry.
-
-