public abstract class AbstractFileResource<T extends FileResource<T>> extends AbstractResource<File> implements FileResource<T>
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractFileResource(ResourceFactory factory,
File file) |
| Modifier and Type | Method and Description |
|---|---|
abstract Resource<File> |
createFrom(File file)
Create a new
Resource instance for the target file. |
boolean |
createNewFile()
Create the file in the underlying resource system.
|
T |
createTempResource()
Create a temporary
FileResource |
boolean |
delete()
|
boolean |
delete(boolean recursive)
Delete this resource, return
true if successful, false if not. |
void |
deleteOnExit()
Requests that the file or directory denoted by this resource be deleted when the virtual machine terminates.
|
boolean |
exists()
|
Resource<?> |
getChild(String name)
Get a child of this resource.
|
protected FileOperations |
getFileOperations() |
String |
getFullyQualifiedName()
Return the fully qualified name of the resource (if applicable).
|
long |
getLastModified()
Get the last modified time-stamp of this resource.
|
String |
getName()
Return the common name of the
Resource. |
DirectoryResource |
getParent()
Get the parent of the current resource.
|
InputStream |
getResourceInputStream()
Get the
InputStream represented by this Resource. |
OutputStream |
getResourceOutputStream()
Returns the
OutputStream for this WriteableResource |
long |
getSize()
Returns the size of the file denoted by this abstract pathname
|
File |
getUnderlyingResourceObject()
Get the underlying object represented by this
Resource. |
boolean |
isDirectory()
Return
true if this FileResource exists and is actually a directory, otherwise return false; |
boolean |
isExecutable()
Returns if a file is executable
|
boolean |
isReadable()
Returns if a file is readable
|
boolean |
isStale()
Returns
true if the underlying resource has been modified on the file system since it was initially
loaded. |
boolean |
isWritable()
Returns if a file is writable
|
boolean |
mkdir()
Create a new single directory for this resource.
|
boolean |
mkdirs()
Create all directories required for this resource to exist.
|
ResourceMonitor |
monitor()
Monitors this FileResource
|
ResourceMonitor |
monitor(ResourceFilter filter)
Monitors this FileResource using the given filter
|
void |
refresh()
Re-read the file-system meta-data for this resource (such as last modified time-stamp, and permissions.)
|
boolean |
renameTo(FileResource<?> target)
Rename this
Resource to the given FileResource |
boolean |
renameTo(String pathspec)
Rename this
Resource to the given path. |
T |
setContents(char[] data)
Set the contents of this
WriteableResource to the given character array using UTF-8 encoding. |
T |
setContents(char[] data,
Charset charset)
Set the contents of this
WriteableResource to the given character array using the specified encoding. |
T |
setContents(InputStream data)
Set the contents of this
WriteableResource to the contents of the given InputStream. |
T |
setContents(String data)
Set the contents of this
WriteableResource to the given String using UTF-8 encoding. |
T |
setContents(String data,
Charset charset)
Set the contents of this
WriteableResource to the given String using the specified encoding. |
void |
setLastModified(long time)
Set the last modified time-stamp of this resource.
|
String |
toString() |
doListResources, equals, getContents, getContents, getResourceFactory, hashCode, listResources, listResources, reify, resolveChildren, setParent, supportsgetFacet, getFacets, getFacets, hasAllFacets, hasAllFacets, hasFacet, install, register, uninstall, unregisterclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetContents, getContents, getResourceFactory, listResources, listResources, reify, resolveChildrengetFacet, getFacets, getFacets, hasAllFacets, hasAllFacets, hasFacet, supportsprotected AbstractFileResource(ResourceFactory factory, File file)
public String getName()
ResourceResource. If it's a file, for instance, just the file name.public File getUnderlyingResourceObject()
ResourceResource.getUnderlyingResourceObject in interface Resource<File>public InputStream getResourceInputStream()
ResourceInputStream represented by this Resource.getResourceInputStream in interface Resource<File>public DirectoryResource getParent()
Resourcenull if the current resource is the filesystem root.getParent in interface FileResource<T extends FileResource<T>>getParent in interface Resource<File>getParent in class AbstractResource<File>Resource parent.public Resource<?> getChild(String name)
Resourcenull if no child by the given name can be found.public abstract Resource<File> createFrom(File file)
Resource instance for the target file. The new Resource should be of the same type as
this.createFrom in interface Resource<File>file - The file to create the resource instance from.public boolean exists()
Resourcepublic boolean isDirectory()
FileResourcetrue if this FileResource exists and is actually a directory, otherwise return false;isDirectory in interface FileResource<T extends FileResource<T>>public boolean isStale()
FileResourcetrue if the underlying resource has been modified on the file system since it was initially
loaded.isStale in interface FileResource<T extends FileResource<T>>public void refresh()
FileResourcerefresh in interface FileResource<T extends FileResource<T>>public boolean mkdir()
FileResourceFileResource.mkdirs()mkdir in interface FileResource<T extends FileResource<T>>public boolean mkdirs()
FileResourcemkdirs in interface FileResource<T extends FileResource<T>>public boolean delete()
Resourcepublic boolean delete(boolean recursive)
Resourcetrue if successful, false if not.delete in interface Resource<File>recursive - if false and this resource both supports recursive deletion and contains children, deletion will
not occur; otherwise, if true, deletion will propagate to all child resources. Implementations may
choose simply to delegate to Resource.delete()public void deleteOnExit()
FileResourceOnce deletion has been requested, it is not possible to cancel the request. This method should therefore be used with care.
deleteOnExit in interface FileResource<T extends FileResource<T>>public T setContents(String data)
WriteableResourceWriteableResource to the given String using UTF-8 encoding.setContents in interface WriteableResource<FileResource<T extends FileResource<T>>,File>public T setContents(String data, Charset charset)
WriteableResourceWriteableResource to the given String using the specified encoding.setContents in interface WriteableResource<FileResource<T extends FileResource<T>>,File>public T setContents(char[] data, Charset charset)
WriteableResourceWriteableResource to the given character array using the specified encoding.setContents in interface WriteableResource<FileResource<T extends FileResource<T>>,File>public T setContents(char[] data)
WriteableResourceWriteableResource to the given character array using UTF-8 encoding.setContents in interface WriteableResource<FileResource<T extends FileResource<T>>,File>public T setContents(InputStream data)
WriteableResourceWriteableResource to the contents of the given InputStream.setContents in interface WriteableResource<FileResource<T extends FileResource<T>>,File>public boolean createNewFile()
FileResourcecreateNewFile in interface FileResource<T extends FileResource<T>>public T createTempResource()
FileResourceFileResourcecreateTempResource in interface FileResource<T extends FileResource<T>>public boolean renameTo(String pathspec)
FileResourceResource to the given path.renameTo in interface FileResource<T extends FileResource<T>>public boolean renameTo(FileResource<?> target)
FileResourceResource to the given FileResourcerenameTo in interface FileResource<T extends FileResource<T>>public long getSize()
FileResourcegetSize in interface FileResource<T extends FileResource<T>>public boolean isExecutable()
FileResourceisExecutable in interface FileResource<T extends FileResource<T>>public boolean isReadable()
FileResourceisReadable in interface FileResource<T extends FileResource<T>>public boolean isWritable()
FileResourceisWritable in interface FileResource<T extends FileResource<T>>public String getFullyQualifiedName()
ResourceFile resource, this
would normally be the full path name.getFullyQualifiedName in interface Resource<File>getFullyQualifiedName in class AbstractResource<File>public ResourceMonitor monitor()
FileResourcemonitor in interface FileResource<T extends FileResource<T>>public ResourceMonitor monitor(ResourceFilter filter)
FileResourcemonitor in interface FileResource<T extends FileResource<T>>protected FileOperations getFileOperations()
public long getLastModified()
FileResourcegetLastModified in interface FileResource<T extends FileResource<T>>public void setLastModified(long time)
FileResourcesetLastModified in interface FileResource<T extends FileResource<T>>public OutputStream getResourceOutputStream()
WriteableResourceOutputStream for this WriteableResourcegetResourceOutputStream in interface WriteableResource<FileResource<T extends FileResource<T>>,File>Copyright © 2015 JBoss by Red Hat. All rights reserved.