public class HdfsFileObject extends AbstractFileObject<HdfsFileSystem>
Modifier | Constructor and Description |
---|---|
protected |
HdfsFileObject(AbstractFileName name,
HdfsFileSystem fs,
FileSystem hdfs,
Path p)
Constructs a new HDFS FileObject
|
Modifier and Type | Method and Description |
---|---|
boolean |
canRenameTo(FileObject newfile)
Queries the object if a simple rename to the filename of
newfile
is possible. |
protected void |
doAttach()
Attaches this file object to its file resource.
|
protected Map<String,Object> |
doGetAttributes()
Returns the attributes of this file.
|
protected long |
doGetContentSize()
Returns the size of the file content (in bytes).
|
protected 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 |
doIsHidden()
Determines if this file is hidden.
|
protected boolean |
doIsReadable()
Determines if this file can be read.
|
protected boolean |
doIsWriteable()
Determines if this file can be written to.
|
protected String[] |
doListChildren()
Lists the children of this file.
|
protected FileObject[] |
doListChildrenResolved()
Lists the children of this file.
|
protected void |
doRemoveAttribute(String attrName)
Removes an attribute of this file.
|
protected void |
doSetAttribute(String attrName,
Object value)
Sets an attribute of this file.
|
protected boolean |
doSetLastModifiedTime(long modtime)
Sets the last modified time of this file.
|
boolean |
exists()
Determines if the file exists.
|
childrenChanged, close, compareTo, copyFrom, createFile, createFolder, delete, delete, deleteAll, doCreateFileContent, doCreateFolder, doDelete, doDetach, doGetCertificates, doGetOutputStream, doIsExecutable, doIsSameFile, doRename, doSetExecutable, doSetReadable, doSetWritable, endOutput, finalize, findFiles, findFiles, getAbstractFileSystem, getChild, getChildren, getContent, getFileContentInfoFactory, 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
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
protected HdfsFileObject(AbstractFileName name, HdfsFileSystem fs, FileSystem hdfs, Path p)
name
- FileNamefs
- HdfsFileSystem instancehdfs
- Hadoop FileSystem instancep
- Path to the file in HDFSpublic boolean canRenameTo(FileObject newfile)
AbstractFileObject
newfile
is possible.canRenameTo
in interface FileObject
canRenameTo
in class AbstractFileObject<HdfsFileSystem>
newfile
- the new filenameAbstractFileObject.canRenameTo(org.apache.commons.vfs2.FileObject)
protected void doAttach() throws Exception
AbstractFileObject
This method is called before any of the doBlah() or onBlah() methods. Sub-classes can use this method to perform lazy initialisation.
This implementation does nothing.
doAttach
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doAttach()
protected Map<String,Object> doGetAttributes() throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
does not return FileType.IMAGINARY
.
This implementation always returns an empty map.
doGetAttributes
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doGetAttributes()
protected long doGetContentSize() throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
returns FileType.FILE
.doGetContentSize
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doGetContentSize()
protected InputStream doGetInputStream() throws Exception
AbstractFileObject
AbstractFileObject.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.
doGetInputStream
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doGetInputStream()
protected long doGetLastModifiedTime() throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
does not return FileType.IMAGINARY
.
This implementation throws an exception.
doGetLastModifiedTime
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doGetLastModifiedTime()
protected RandomAccessContent doGetRandomAccessContent(RandomAccessMode mode) throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
returns FileType.FILE
.
It is guaranteed that there are no open output streams for this file when this method is called.
doGetRandomAccessContent
in class AbstractFileObject<HdfsFileSystem>
mode
- The mode to access the file.Exception
- if an error occurs.(org.apache.commons.vfs2.util.RandomAccessMode)
protected FileType doGetType() throws Exception
AbstractFileObject
doGetType
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doGetType()
protected boolean doIsHidden() throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
does not return FileType.IMAGINARY
.
This implementation always returns false.
doIsHidden
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doIsHidden()
protected boolean doIsReadable() throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
does not return FileType.IMAGINARY
.
This implementation always returns true.
doIsReadable
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doIsReadable()
protected boolean doIsWriteable() throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
does not return FileType.IMAGINARY
.
This implementation always returns true.
doIsWriteable
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doIsWriteable()
protected String[] doListChildren() throws Exception
AbstractFileObject
AbstractFileObject.doGetType()
returns FileType.FOLDER
. The return value of this method
is cached, so the implementation can be expensive.doListChildren
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doListChildren()
protected FileObject[] doListChildrenResolved() throws Exception
AbstractFileObject
Is only called if AbstractFileObject.doGetType()
returns FileType.FOLDER
.
The return value of this method is cached, so the implementation can be expensive.
Other than doListChildren
you could return FileObject's to e.g. reinitialize the
type of the file.
(Introduced for Webdav: "permission denied on resource" during getType())
doListChildrenResolved
in class AbstractFileObject<HdfsFileSystem>
Exception
- if an error occurs.AbstractFileObject.doListChildrenResolved()
protected void doRemoveAttribute(String attrName) throws Exception
AbstractFileObject
Is only called if AbstractFileObject.doGetType()
does not return FileType.IMAGINARY
.
This implementation throws an exception.
doRemoveAttribute
in class AbstractFileObject<HdfsFileSystem>
attrName
- The name of the attribute to remove.Exception
- if an error occurs.AbstractFileObject.doRemoveAttribute(java.lang.String)
protected void doSetAttribute(String attrName, Object value) throws Exception
AbstractFileObject
Is only called if AbstractFileObject.doGetType()
does not return FileType.IMAGINARY
.
This implementation throws an exception.
doSetAttribute
in class AbstractFileObject<HdfsFileSystem>
attrName
- The attribute name.value
- The value to be associated with the attribute name.Exception
- if an error occurs.AbstractFileObject.doSetAttribute(java.lang.String, java.lang.Object)
protected boolean doSetLastModifiedTime(long modtime) throws Exception
AbstractFileObject
Is only called if AbstractFileObject.doGetType()
does not return FileType.IMAGINARY
.
This implementation throws an exception.
doSetLastModifiedTime
in class AbstractFileObject<HdfsFileSystem>
modtime
- The last modification time.Exception
- Any Exception thrown is wrapped in FileSystemException.AbstractFileObject.doSetLastModifiedTime(long)
public boolean exists() throws FileSystemException
AbstractFileObject
exists
in interface FileObject
exists
in class AbstractFileObject<HdfsFileSystem>
FileSystemException
- if an error occurs.AbstractFileObject.exists()
Copyright © 2002–2016. All rights reserved.