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()
Delete this file, non-recursively.
|
boolean |
delete(boolean recursive)
Delete this
Resource, and all child resources. |
void |
deleteOnExit()
Requests that the file or directory denoted by this resource be deleted when the virtual machine terminates.
|
boolean |
exists()
Return true if this
Resource exists, return false if not. |
Resource<?> |
getChild(String name)
Get a child of this resource.
|
String |
getName()
Return the common name of the resource.
|
Resource<?> |
getParent()
Get the parent of the current resource.
|
InputStream |
getResourceInputStream()
Get the
InputStream represented by this Resource. |
File |
getUnderlyingResourceObject()
Get the actual underlying file resource that this resource instance represents, whether existing or non-existing.
|
boolean |
isDirectory()
Return true if this
AbstractFileResource exists and is actually a directory, otherwise return false; |
boolean |
isStale()
Returns true if the underlying resource has been modified on the file system since it was initially loaded.
|
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
AbstractFileResource |
boolean |
renameTo(String pathspec)
Rename this resource to the given path.
|
T |
setContents(char[] data)
Set the contents of this
AbstractFileResource to the given character array. |
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
AbstractFileResource to the given String |
String |
toString() |
doListResources, equals, getFullyQualifiedName, getResourceFactory, hashCode, listResources, listResources, supportsgetFacet, getFacets, getFacets, hasAllFacets, hasAllFacets, hasFacet, install, uninstallclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetFullyQualifiedName, getResourceFactory, listResources, listResourcesprotected File file
protected long lastModification
protected AbstractFileResource(ResourceFactory factory, File file)
public String getName()
Resourcepublic File getUnderlyingResourceObject()
getUnderlyingResourceObject in interface Resource<File>Filepublic InputStream getResourceInputStream()
ResourceInputStream represented by this Resource.getResourceInputStream in interface Resource<File>public Resource<?> getParent()
public Resource<?> getChild(String name)
Resourcepublic 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()
ResourceResource exists, return false if not.public boolean isDirectory()
AbstractFileResource exists and is actually a directory, otherwise return false;isDirectory in interface FileResource<T extends FileResource<T>>public boolean isStale()
isStale in interface FileResource<T extends FileResource<T>>public void markUpToDate()
markUpToDate in interface FileResource<T extends FileResource<T>>public boolean mkdir()
mkdirs()mkdir in interface FileResource<T extends FileResource<T>>public boolean mkdirs()
mkdirs in interface FileResource<T extends FileResource<T>>public boolean delete()
public boolean delete(boolean recursive)
Resource, and all child resources.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()
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)
AbstractFileResource to the given StringsetContents in interface FileResource<T extends FileResource<T>>public T setContents(char[] data)
AbstractFileResource to the given character array.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()
createNewFile 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)
renameTo in interface FileResource<T extends FileResource<T>>public boolean renameTo(FileResource<?> target)
AbstractFileResourcerenameTo in interface FileResource<T extends FileResource<T>>Copyright © 2013 JBoss by Red Hat. All Rights Reserved.