public class DecoratedFileObject extends Object implements FileObject
| Constructor and Description |
|---|
DecoratedFileObject(FileObject decoratedFileObject) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canRenameTo(FileObject newfile)
Queries the file if it is possible to rename it to newfile.
|
void |
close()
Closes this file, and its content.
|
int |
compareTo(FileObject fo) |
void |
copyFrom(FileObject srcFile,
FileSelector selector)
Copies another file, and all its descendants, 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 all descendants of this file that match a selector.
|
int |
deleteAll()
Deletes this file and all children.
|
boolean |
exists()
Determines if this file exists.
|
FileObject[] |
findFiles(FileSelector selector)
Finds the set of matching descendants of this file, in depthwise order.
|
void |
findFiles(FileSelector selector,
boolean depthwise,
List<FileObject> selected)
Finds the set of matching descendants of this file.
|
FileObject |
getChild(String name)
Returns a child of this file.
|
FileObject[] |
getChildren()
Lists the children of this file.
|
FileContent |
getContent()
Returns this file's content.
|
FileObject |
getDecoratedFileObject() |
FileOperations |
getFileOperations() |
FileSystem |
getFileSystem()
Returns the file system that contains this file.
|
FileName |
getName()
Returns the name of this file.
|
FileObject |
getParent()
Returns the folder that contains this file.
|
String |
getPublicURIString()
Returns the receiver as a URI String for public display, like, without a password.
|
FileType |
getType()
Returns this file's type.
|
URL |
getURL()
Returns a URL representing this file.
|
boolean |
isAttached()
Checks if the fileObject is attached.
|
boolean |
isContentOpen()
Checks if someone reads/write to this file.
|
boolean |
isExecutable()
Determines if this file is executable.
|
boolean |
isFile()
Checks if this file is a regular file.
|
boolean |
isFolder()
Checks if this file is a folder.
|
boolean |
isHidden()
Determines if this file is hidden.
|
boolean |
isReadable()
Determines if this file can be read.
|
boolean |
isWriteable()
Determines if this file can be written to.
|
Iterator<FileObject> |
iterator() |
void |
moveTo(FileObject destFile)
Move this file.
|
void |
refresh()
This will prepare the fileObject to get resynchronized with the underlying file system if required.
|
FileObject |
resolveFile(String path)
Finds a file, relative to this file.
|
FileObject |
resolveFile(String name,
NameScope scope)
Finds a file relative to this file.
|
boolean |
setExecutable(boolean executable,
boolean ownerOnly)
Sets the owner's (or everybody's) write permission.
|
boolean |
setReadable(boolean readable,
boolean ownerOnly)
Sets the owner's (or everybody's) read permission.
|
boolean |
setWritable(boolean writable,
boolean ownerOnly)
Sets the owner's (or everybody's) write permission.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic DecoratedFileObject(FileObject decoratedFileObject)
public boolean canRenameTo(FileObject newfile)
FileObjectcanRenameTo in interface FileObjectnewfile - the new file(-name)public void close()
throws FileSystemException
FileObjectThe file object can continue to be used after this method is called.
close in interface Closeableclose in interface AutoCloseableclose in interface FileObjectFileSystemException - On error closing the file.FileContent.close()public int compareTo(FileObject fo)
compareTo in interface Comparable<FileObject>public void copyFrom(FileObject srcFile, FileSelector selector) throws FileSystemException
FileObjectIf this file does not exist, it is created. Its parent folder is also created, if necessary. If this file does exist, it is deleted first.
This method is not transactional. If it fails and throws an exception, this file will potentially only be partially copied.
copyFrom in interface FileObjectsrcFile - The source file to copy.selector - The selector to use to select which files to copy.FileSystemException - If this file is read-only, or if the source file does not exist, or on error copying
the file.public void createFile()
throws FileSystemException
FileObjectcreateFile in interface FileObjectFileSystemException - If the file already exists with the wrong type, or the parent folder is read-only, or
on error creating this file or one of its ancestors.public void createFolder()
throws FileSystemException
FileObjectcreateFolder in interface FileObjectFileSystemException - If the folder already exists with the wrong type, or the parent folder is read-only,
or on error creating this folder or one of its ancestors.public boolean delete()
throws FileSystemException
FileObjectFileObject.delete(FileSelector) or FileObject.deleteAll() for that.delete in interface FileObjectFileSystemException - If this file is a non-empty folder, or if this file is read-only, or on error
deleteing this file.public int delete(FileSelector selector) throws FileSystemException
FileObjectThis method is not transactional. If it fails and throws an exception, this file will potentially only be partially deleted.
delete in interface FileObjectselector - The selector to use to select which files to delete.FileSystemException - If this file or one of its descendants is read-only, or on error deleting this file
or one of its descendants.public int deleteAll()
throws FileSystemException
FileObjectdeleteAll in interface FileObjectFileSystemException - if an error occurs.FileObject.delete(FileSelector),
Selectors.SELECT_ALLpublic boolean exists()
throws FileSystemException
FileObjectexists in interface FileObjecttrue if this file exists, false if not.FileSystemException - On error determining if this file exists.public FileObject[] findFiles(FileSelector selector) throws FileSystemException
FileObjectfindFiles in interface FileObjectselector - The selector to use to select matching files.FileSystemException - if an error occurs.public void findFiles(FileSelector selector, boolean depthwise, List<FileObject> selected) throws FileSystemException
FileObjectfindFiles in interface FileObjectselector - the selector used to determine if the file should be selecteddepthwise - controls the ordering in the list. e.g. deepest firstselected - container for selected files. list needs not to be empty.FileSystemException - if an error occurs.public FileObject getChild(String name) throws FileSystemException
FileObjectnull when the child does not exist. This
differs from FileObject.resolveFile(String, NameScope) which never returns null.getChild in interface FileObjectname - The name of the child.FileSystemException - If this file does not exist, or is not a folder, or on error determining this file's
children.public FileObject[] getChildren() throws FileSystemException
FileObjectgetChildren in interface FileObjectFileSystemException - If this file does not exist, or is not a folder, or on error listing this file's
children.public FileContent getContent() throws FileSystemException
FileObjectFileContent returned by this method can be used to read and write the
content of the file.
This method can be called if the file does not exist, and the returned FileContent can be used to create
the file by writing its content.
getContent in interface FileObjectFileSystemException - On error getting this file's content.public FileObject getDecoratedFileObject()
public FileOperations getFileOperations() throws FileSystemException
getFileOperations in interface FileObjectFileSystemException - if an error occurs.public FileSystem getFileSystem()
FileObjectgetFileSystem in interface FileObjectpublic String getPublicURIString()
FileObjectgetPublicURIString in interface FileObjectnull.public FileName getName()
FileObjectgetName in interface FileObjectpublic FileObject getParent() throws FileSystemException
FileObjectgetParent in interface FileObjectFileSystemException - On error finding the file's parent.public FileType getType() throws FileSystemException
FileObjectgetType in interface FileObjectFileType constants. Never returns null.FileSystemException - On error determining the file's type.public URL getURL() throws FileSystemException
FileObjectgetURL in interface FileObjectFileSystemException - if an error occurs.public boolean isAttached()
FileObjectisAttached in interface FileObjectpublic boolean isContentOpen()
FileObjectisContentOpen in interface FileObjectpublic boolean isExecutable()
throws FileSystemException
FileObjectisExecutable in interface FileObjecttrue if this file is executable, false if not.FileSystemException - On error determining if this file exists.public boolean isFile()
throws FileSystemException
FileObjectisFile in interface FileObjectFileSystemException - if an error occurs.FileObject.getType(),
FileType.FILEpublic boolean isFolder()
throws FileSystemException
FileObjectisFolder in interface FileObjectFileSystemException - if an error occurs.FileObject.getType(),
FileType.FOLDERpublic boolean isHidden()
throws FileSystemException
FileObjectisHidden in interface FileObjecttrue if this file is hidden, false if not.FileSystemException - On error determining if this file exists.public boolean isReadable()
throws FileSystemException
FileObjectisReadable in interface FileObjecttrue if this file is readable, false if not.FileSystemException - On error determining if this file exists.public boolean isWriteable()
throws FileSystemException
FileObjectisWriteable in interface FileObjecttrue if this file is writeable, false if not.FileSystemException - On error determining if this file exists.public Iterator<FileObject> iterator()
iterator in interface Iterable<FileObject>public void moveTo(FileObject destFile) throws FileSystemException
FileObjectIf the destFile exists, it is deleted first.
moveTo in interface FileObjectdestFile - the New filename.FileSystemException - If this file is read-only, or if the source file does not exist, or on error copying
the file.public void refresh()
throws FileSystemException
FileObjectrefresh in interface FileObjectFileSystemException - if an error occurs.public FileObject resolveFile(String path) throws FileSystemException
FileObjectresolveFile( path, NameScope.FILE_SYSTEM ).resolveFile in interface FileObjectpath - The path of the file to locate. Can either be a relative path or an absolute path.FileSystemException - On error parsing the path, or on error finding the file.public FileObject resolveFile(String name, NameScope scope) throws FileSystemException
FileObjectNameScope for a description of how names are resolved in the different scopes.resolveFile in interface FileObjectname - The name to resolve.scope - the NameScope for the file.FileSystemException - On error parsing the path, or on error finding the file.public boolean setExecutable(boolean executable,
boolean ownerOnly)
throws FileSystemException
FileObjectsetExecutable in interface FileObjectexecutable - True to allow read access, false to disallow.ownerOnly - If true, the permission applies only to the owner; otherwise, it applies to everybody.FileSystemException - On error determining if this file exists.public boolean setReadable(boolean readable,
boolean ownerOnly)
throws FileSystemException
FileObjectsetReadable in interface FileObjectreadable - True to allow read access, false to disallowownerOnly - If true, the permission applies only to the owner; otherwise, it applies to everybody.FileSystemException - On error determining if this file exists.public boolean setWritable(boolean writable,
boolean ownerOnly)
throws FileSystemException
FileObjectsetWritable in interface FileObjectwritable - True to allow read access, false to disallowownerOnly - If true, the permission applies only to the owner; otherwise, it applies to everybody.FileSystemException - On error determining if this file exists.Copyright © 2002–2017 The Apache Software Foundation. All rights reserved.