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, supports
getFacet, getFacets, getFacets, hasAllFacets, hasAllFacets, hasFacet, install, register, uninstall, unregister
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getContents, getContents, getResourceFactory, listResources, listResources, reify, resolveChildren
getFacet, getFacets, getFacets, hasAllFacets, hasAllFacets, hasFacet, supports
protected AbstractFileResource(ResourceFactory factory, File file)
public String getName()
Resource
Resource
. If it's a file, for instance, just the file name.public File getUnderlyingResourceObject()
Resource
Resource
.getUnderlyingResourceObject
in interface Resource<File>
public InputStream getResourceInputStream()
Resource
InputStream
represented by this Resource
.getResourceInputStream
in interface Resource<File>
public DirectoryResource getParent()
Resource
null
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)
Resource
null
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()
Resource
public boolean isDirectory()
FileResource
true
if this FileResource
exists and is actually a directory, otherwise return false;isDirectory
in interface FileResource<T extends FileResource<T>>
public boolean isStale()
FileResource
true
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()
FileResource
refresh
in interface FileResource<T extends FileResource<T>>
public boolean mkdir()
FileResource
FileResource.mkdirs()
mkdir
in interface FileResource<T extends FileResource<T>>
public boolean mkdirs()
FileResource
mkdirs
in interface FileResource<T extends FileResource<T>>
public boolean delete()
Resource
public boolean delete(boolean recursive)
Resource
true
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()
FileResource
Once 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)
WriteableResource
WriteableResource
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)
WriteableResource
WriteableResource
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)
WriteableResource
WriteableResource
to the given character array using the specified encoding.setContents
in interface WriteableResource<FileResource<T extends FileResource<T>>,File>
public T setContents(char[] data)
WriteableResource
WriteableResource
to the given character array using UTF-8 encoding.setContents
in interface WriteableResource<FileResource<T extends FileResource<T>>,File>
public T setContents(InputStream data)
WriteableResource
WriteableResource
to the contents of the given InputStream
.setContents
in interface WriteableResource<FileResource<T extends FileResource<T>>,File>
public boolean createNewFile()
FileResource
createNewFile
in interface FileResource<T extends FileResource<T>>
public T createTempResource()
FileResource
FileResource
createTempResource
in interface FileResource<T extends FileResource<T>>
public boolean renameTo(String pathspec)
FileResource
Resource
to the given path.renameTo
in interface FileResource<T extends FileResource<T>>
public boolean renameTo(FileResource<?> target)
FileResource
Resource
to the given FileResource
renameTo
in interface FileResource<T extends FileResource<T>>
public long getSize()
FileResource
getSize
in interface FileResource<T extends FileResource<T>>
public boolean isExecutable()
FileResource
isExecutable
in interface FileResource<T extends FileResource<T>>
public boolean isReadable()
FileResource
isReadable
in interface FileResource<T extends FileResource<T>>
public boolean isWritable()
FileResource
isWritable
in interface FileResource<T extends FileResource<T>>
public String getFullyQualifiedName()
Resource
File
resource, this
would normally be the full path name.getFullyQualifiedName
in interface Resource<File>
getFullyQualifiedName
in class AbstractResource<File>
public ResourceMonitor monitor()
FileResource
monitor
in interface FileResource<T extends FileResource<T>>
public ResourceMonitor monitor(ResourceFilter filter)
FileResource
monitor
in interface FileResource<T extends FileResource<T>>
protected FileOperations getFileOperations()
public long getLastModified()
FileResource
getLastModified
in interface FileResource<T extends FileResource<T>>
public void setLastModified(long time)
FileResource
setLastModified
in interface FileResource<T extends FileResource<T>>
public OutputStream getResourceOutputStream()
WriteableResource
OutputStream
for this WriteableResource
getResourceOutputStream
in interface WriteableResource<FileResource<T extends FileResource<T>>,File>
Copyright © 2015 JBoss by Red Hat. All rights reserved.