|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.vfs.provider.AbstractFileObject
public abstract class AbstractFileObject
A partial file object implementation.
Constructor Summary | |
---|---|
protected |
AbstractFileObject(FileName name,
AbstractFileSystem fs)
|
Method Summary | |
---|---|
boolean |
canRenameTo(FileObject newfile)
Queries the object if a simple rename to the filename of newfile
is possible. |
protected void |
childrenChanged()
Deprecated. use childrenChanged(FileName,FileType) |
protected void |
childrenChanged(FileName childName,
FileType newType)
Notifies the file that its children have changed. |
void |
close()
Closes this file, and its content. |
void |
copyFrom(FileObject file,
FileSelector selector)
Copies another file to this file. |
void |
createFile()
Creates this file, if it does not exist. |
void |
createFolder()
Creates this folder, if it does not exist. |
boolean |
delete()
Deletes this file. |
int |
delete(FileSelector selector)
Deletes this file, and all children. |
protected void |
doAttach()
Attaches this file object to its file resource. |
protected FileContent |
doCreateFileContent()
Create a FileContent implementation. |
protected void |
doCreateFolder()
Creates this file as a folder. |
protected void |
doDelete()
Deletes the file. |
protected void |
doDetach()
Detaches this file object from its file resource. |
protected Map |
doGetAttributes()
Returns the attributes of this file. |
protected Certificate[] |
doGetCertificates()
Returns the certificates used to sign this file. |
protected abstract long |
doGetContentSize()
Returns the size of the file content (in bytes). |
protected abstract InputStream |
doGetInputStream()
Creates an input stream to read the file content from. |
protected long |
doGetLastModifiedTime()
Returns the last modified time of this file. |
protected OutputStream |
doGetOutputStream(boolean bAppend)
Creates an output stream to write the file content to. |
protected RandomAccessContent |
doGetRandomAccessContent(RandomAccessMode mode)
Creates access to the file for random i/o. |
protected abstract 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 |
doIsSameFile(FileObject destFile)
Checks if this fileObject is the same file as destFile just with a different
name.E.g. |
protected boolean |
doIsWriteable()
Determines if this file can be written to. |
protected abstract String[] |
doListChildren()
Lists the children of this file. |
protected FileObject[] |
doListChildrenResolved()
Lists the children of this file. |
protected void |
doRemoveAttribute(String atttrName)
Removes an attribute of this file. |
protected void |
doRename(FileObject newfile)
Renames the file. |
protected void |
doSetAttribute(String atttrName,
Object value)
Sets an attribute of this file. |
protected void |
doSetLastModifiedTime(long modtime)
Deprecated. use doSetLastModTime(long) |
protected boolean |
doSetLastModTime(long modtime)
Sets the last modified time of this file. |
protected void |
endOutput()
Called when the ouput stream for this file is closed. |
boolean |
exists()
Determines if the file exists. |
protected void |
finalize()
|
FileObject[] |
findFiles(FileSelector selector)
Finds the set of matching descendents of this file, in depthwise order. |
void |
findFiles(FileSelector selector,
boolean depthwise,
List selected)
Traverses the descendents of this file, and builds a list of selected files. |
FileObject |
getChild(String name)
Returns a child of this file. |
FileObject[] |
getChildren()
Returns the children of the file. |
FileContent |
getContent()
Returns the file's content. |
protected FileContentInfoFactory |
getFileContentInfoFactory()
create the filecontentinfo implementation |
FileOperations |
getFileOperations()
|
FileSystem |
getFileSystem()
Returns the file system this file belongs to. |
InputStream |
getInputStream()
Returns an input stream to use to read the content of the file. |
FileName |
getName()
Returns the name of the file. |
OutputStream |
getOutputStream()
Prepares this file for writing. |
OutputStream |
getOutputStream(boolean bAppend)
Prepares this file for writing. |
FileObject |
getParent()
Returns the parent of the file. |
RandomAccessContent |
getRandomAccessContent(RandomAccessMode mode)
Returns an input/output stream to use to read and write the content of the file in and random manner. |
FileType |
getType()
Returns the file's type. |
URL |
getURL()
Returns a URL representation of the file. |
protected void |
handleChanged()
Called when this file is changed. This will only happen if you monitor the file using FileMonitor . |
protected void |
handleCreate(FileType newType)
Called when this file is created. |
protected void |
handleDelete()
Called when this file is deleted. |
void |
holdObject(Object strongRef)
This method is meant to add an object where this object holds a strong reference then. |
protected void |
injectType(FileType fileType)
|
boolean |
isAttached()
Check if the internal state is "attached". |
boolean |
isContentOpen()
Check if the content stream is open. |
boolean |
isHidden()
Determines if this file can be read. |
boolean |
isReadable()
Determines if this file can be read. |
protected boolean |
isSameFile(FileObject destFile)
Checks if this fileObject is the same file as destFile just with a different
name.E.g. |
boolean |
isWriteable()
Determines if this file can be written to. |
void |
moveTo(FileObject destFile)
Moves (rename) the file to another one. |
protected void |
notifyAllStreamsClosed()
will be called after this file-object closed all its streams. |
protected void |
onChange()
Called when the type or content of this file changes. |
protected void |
onChildrenChanged(FileName child,
FileType newType)
Called when the children of this file change. |
void |
refresh()
This will prepare the fileObject to get resynchronized with the underlaying filesystem if required. |
FileObject |
resolveFile(String path)
Finds a file, relative to this file. |
FileObject |
resolveFile(String name,
NameScope scope)
Returns a child by name. |
String |
toString()
Returns the URI of the file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected AbstractFileObject(FileName name, AbstractFileSystem fs)
Method Detail |
---|
protected void doAttach() throws Exception
Exception
protected void doDetach() throws Exception
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.
Exception
protected abstract FileType doGetType() throws Exception
Exception
protected boolean doIsHidden() throws Exception
doGetType()
does not return FileType.IMAGINARY
.
This implementation always returns false.
Exception
protected boolean doIsReadable() throws Exception
doGetType()
does not return FileType.IMAGINARY
.
This implementation always returns true.
Exception
protected boolean doIsWriteable() throws Exception
doGetType()
does not return FileType.IMAGINARY
.
This implementation always returns true.
Exception
protected abstract String[] doListChildren() throws Exception
doGetType()
returns FileType.FOLDER
. The return value of this method
is cached, so the implementation can be expensive.
Exception
protected FileObject[] doListChildrenResolved() throws Exception
doGetType()
returns FileType.FOLDER
. The return value of this method
is cached, so the implementation can be expensive.doListChildren
you could return FileObject's to e.g. reinitialize the
type of the file.
Exception
protected void doDelete() throws Exception
doGetType()
does not return FileType.IMAGINARY
.
doIsWriteable()
returns true.
Exception
protected void doRename(FileObject newfile) throws Exception
doIsWriteable()
returns true.
Exception
protected void doCreateFolder() throws Exception
doGetType()
returns FileType.IMAGINARY
.
Exception
protected void onChildrenChanged(FileName child, FileType newType) throws Exception
Exception
protected void onChange() throws Exception
Exception
protected long doGetLastModifiedTime() throws Exception
doGetType()
does not return FileType.IMAGINARY
.
This implementation throws an exception.
Exception
protected boolean doSetLastModTime(long modtime) throws Exception
doGetType()
does not return FileType.IMAGINARY
.
This implementation throws an exception.
Exception
protected void doSetLastModifiedTime(long modtime) throws Exception
doSetLastModTime(long)
doGetType()
does not return FileType.IMAGINARY
.
This implementation throws an exception.
Exception
protected Map doGetAttributes() throws Exception
doGetType()
does not return FileType.IMAGINARY
.
This implementation always returns an empty map.
Exception
protected void doSetAttribute(String atttrName, Object value) throws Exception
doGetType()
does not return FileType.IMAGINARY
.
This implementation throws an exception.
Exception
protected void doRemoveAttribute(String atttrName) throws Exception
doGetType()
does not return FileType.IMAGINARY
.
This implementation throws an exception.
Exception
protected Certificate[] doGetCertificates() throws Exception
doGetType()
does not return FileType.IMAGINARY
.
This implementation always returns null.
Exception
protected abstract long doGetContentSize() throws Exception
doGetType()
returns FileType.FILE
.
Exception
protected abstract InputStream doGetInputStream() throws Exception
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.
Exception
protected RandomAccessContent doGetRandomAccessContent(RandomAccessMode mode) throws Exception
doGetType()
returns FileType.FILE
.
It is guaranteed that there are no open output streams for this file when this method is called.
Exception
protected OutputStream doGetOutputStream(boolean bAppend) throws Exception
doIsWriteable()
returns true.
doGetType()
returns FileType.FILE
, or
doGetType()
returns FileType.IMAGINARY
, and the file's
parent exists and is a folder.
It is guaranteed that there are no open stream (input or output) for this file when this method is called.
The returned stream does not have to be buffered.
This implementation throws an exception.
Exception
public String toString()
toString
in class Object
public FileName getName()
getName
in interface FileObject
public FileSystem getFileSystem()
getFileSystem
in interface FileObject
public URL getURL() throws FileSystemException
getURL
in interface FileObject
FileSystemException
- if an error occurs.public boolean exists() throws FileSystemException
exists
in interface FileObject
FileSystemException
- if an error occurs.public FileType getType() throws FileSystemException
getType
in interface FileObject
FileSystemException
- if an error occurs.public boolean isHidden() throws FileSystemException
isHidden
in interface FileObject
FileSystemException
- if an error occurs.public boolean isReadable() throws FileSystemException
isReadable
in interface FileObject
FileSystemException
- if an error occurs.public boolean isWriteable() throws FileSystemException
isWriteable
in interface FileObject
FileSystemException
- if an error occurs.public FileObject getParent() throws FileSystemException
getParent
in interface FileObject
FileSystemException
- if an error occurs.public FileObject[] getChildren() throws FileSystemException
getChildren
in interface FileObject
FileSystemException
- if an error occurs.public FileObject getChild(String name) throws FileSystemException
getChild
in interface FileObject
name
- The name of the child to locate.
FileSystemException
- if an error occurs.public FileObject resolveFile(String name, NameScope scope) throws FileSystemException
resolveFile
in interface FileObject
name
- The name of the child to locate.scope
- the NameScope.
FileSystemException
- if an error occurs.public FileObject resolveFile(String path) throws FileSystemException
resolveFile
in interface FileObject
path
- The path of the file to locate. Can either be a relative
path, which is resolved relative to this file, or an
absolute path, which is resolved relative to the file system
that contains this file.
FileSystemException
- if an error occurs.public boolean delete() throws FileSystemException
delete
in interface FileObject
FileSystemException
- if an error occurs.public int delete(FileSelector selector) throws FileSystemException
delete
in interface FileObject
selector
- The FileSelector.
FileSystemException
- if an error occurs.public void createFile() throws FileSystemException
createFile
in interface FileObject
FileSystemException
- if an error occurs.public void createFolder() throws FileSystemException
createFolder
in interface FileObject
FileSystemException
- if an error occurs.public void copyFrom(FileObject file, FileSelector selector) throws FileSystemException
copyFrom
in interface FileObject
file
- The FileObject to copy.selector
- The FileSelector.
FileSystemException
- if an error occurs.public void moveTo(FileObject destFile) throws FileSystemException
moveTo
in interface FileObject
destFile
- The target FileObject.
FileSystemException
- if an error occurs.protected boolean isSameFile(FileObject destFile) throws FileSystemException
destFile
just with a different
name.
FileSystemException
protected boolean doIsSameFile(FileObject destFile) throws FileSystemException
destFile
just with a different
name.
FileSystemException
public boolean canRenameTo(FileObject newfile)
newfile
is possible.
canRenameTo
in interface FileObject
newfile
- the new filename
public FileObject[] findFiles(FileSelector selector) throws FileSystemException
findFiles
in interface FileObject
selector
- The FileSelector.
FileSystemException
- if an error occurs.public FileContent getContent() throws FileSystemException
getContent
in interface FileObject
FileSystemException
- if an error occurs.protected FileContent doCreateFileContent() throws FileSystemException
FileSystemException
public void refresh() throws FileSystemException
refresh
in interface FileObject
FileSystemException
- if an error occurs.public void close() throws FileSystemException
close
in interface FileObject
FileSystemException
- if an error occurs.FileContent.close()
public InputStream getInputStream() throws FileSystemException
FileSystemException
- if an error occurs.public RandomAccessContent getRandomAccessContent(RandomAccessMode mode) throws FileSystemException
mode
- The RandomAccessMode.
FileSystemException
- if an error occurs.public OutputStream getOutputStream() throws FileSystemException
FileSystemException
- if an error occurs.public OutputStream getOutputStream(boolean bAppend) throws FileSystemException
bAppend
- true when append to the file.FileSystemException
- if an error occurs.protected void endOutput() throws Exception
Exception
protected void handleCreate(FileType newType) throws Exception
Exception
protected void handleDelete() throws Exception
Exception
protected void handleChanged() throws Exception
FileMonitor
.
Exception
protected void childrenChanged() throws Exception
childrenChanged(FileName,FileType)
Exception
protected void childrenChanged(FileName childName, FileType newType) throws Exception
Exception
public void findFiles(FileSelector selector, boolean depthwise, List selected) throws FileSystemException
findFiles
in interface FileObject
selector
- The FileSelector.depthwise
- if true files are added after their descendants, before otherwise.selected
- A List of the located FileObjects.
FileSystemException
- if an error occurs.public boolean isContentOpen()
isContentOpen
in interface FileObject
public boolean isAttached()
isAttached
in interface FileObject
protected FileContentInfoFactory getFileContentInfoFactory()
protected void injectType(FileType fileType)
public void holdObject(Object strongRef)
strongRef
- The Object to add.protected void notifyAllStreamsClosed()
public FileOperations getFileOperations() throws FileSystemException
getFileOperations
in interface FileObject
FileSystemException
- if an error occurs.protected void finalize() throws Throwable
finalize
in class Object
Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |