public abstract class AbstractFileResource<T extends FileResource<T>> extends AbstractResource<File> implements FileResource<T>
| Modifier and Type | Field and Description |
|---|---|
protected File |
file |
protected long |
lastModification |
parent, resourceFactory| 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.
|
String |
getContents()
Get the entire contents of this
FileResource, returned as a String using UTF-8 encoding. |
String |
getContents(Charset charset)
Get the entire contents of this
FileResource, returned as a String using the specified encoding. |
String |
getFullyQualifiedName()
Return the fully qualified name of the resource (if applicable).
|
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. |
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
|
void |
markUpToDate()
Re-read the last modified timestamp for this resource.
|
boolean |
mkdir()
Create a new single directory for this resource.
|
boolean |
mkdirs()
Create all directories required for this resource to exist.
|
<R extends Resource<?>> |
reify(Class<R> type)
Ask this
Resource if it is actually a resource of the given type; if it is, return a new reference to the
resource as the given type, otherwise return null. |
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
FileResource to the given character array using UTF-8 encoding. |
T |
setContents(char[] data,
Charset charset)
Set the contents of this
FileResource to the given character array using the specified encoding. |
T |
setContents(InputStream data)
Set the contents of this
FileResource to the contents of the given InputStream. |
T |
setContents(String data)
Set the contents of this
FileResource to the given String using UTF-8 encoding. |
T |
setContents(String data,
Charset charset)
Set the contents of this
FileResource to the given String using the specified encoding. |
String |
toString() |
doListResources, equals, getResourceFactory, hashCode, listResources, listResources, supportsgetFacet, getFacets, getFacets, hasAllFacets, hasAllFacets, hasFacet, install, register, uninstall, unregisterclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetResourceFactory, listResources, listResourcesprotected File file
protected long lastModification
protected 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()
FileResourceFileResource exists and is actually a directory, otherwise return false;isDirectory in interface FileResource<T extends FileResource<T>>public boolean isStale()
FileResourceisStale in interface FileResource<T extends FileResource<T>>public void markUpToDate()
FileResourcemarkUpToDate 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 String getContents()
FileResourceFileResource, returned as a String using UTF-8 encoding.getContents in interface FileResource<T extends FileResource<T>>public String getContents(Charset charset)
FileResourceFileResource, returned as a String using the specified encoding.getContents in interface FileResource<T extends FileResource<T>>public T setContents(String data)
FileResourceFileResource to the given String using UTF-8 encoding.setContents in interface FileResource<T extends FileResource<T>>public T setContents(String data, Charset charset)
FileResourceFileResource to the given String using the specified encoding.setContents in interface FileResource<T extends FileResource<T>>public T setContents(char[] data, Charset charset)
FileResourceFileResource to the given character array using the specified encoding.setContents in interface FileResource<T extends FileResource<T>>public T setContents(char[] data)
FileResourceFileResource to the given character array using UTF-8 encoding.setContents in interface FileResource<T extends FileResource<T>>public T setContents(InputStream data)
FileResourceFileResource to the contents of the given InputStream.setContents in interface FileResource<T extends FileResource<T>>public boolean createNewFile()
FileResourcecreateNewFile in interface FileResource<T extends FileResource<T>>public T createTempResource()
FileResourceFileResourcecreateTempResource in interface FileResource<T extends FileResource<T>>public <R extends Resource<?>> R reify(Class<R> type)
ResourceResource if it is actually a resource of the given type; if it is, return a new reference to the
resource as the given type, otherwise return null.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>Copyright © 2013 JBoss by Red Hat. All Rights Reserved.