public abstract class FileResource<T extends FileResource<?>> extends AbstractResource<File>
| Modifier and Type | Field and Description |
|---|---|
protected File |
file |
protected long |
lastModification |
protected boolean |
scratch |
protected File |
scratchFile |
flags, parent, resourceFactory| Modifier | Constructor and Description |
|---|---|
protected |
FileResource(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() |
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 |
getFullyQualifiedName()
Return the fully qualified name of the resource (if applicable).
|
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
FileResource 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
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. |
T |
setContents(InputStream data) |
T |
setContents(String data)
Set the contents of this
FileResource to the given String |
doListResources, equals, getFlags, getResourceFactory, hashCode, isFlagSet, listResources, listResources, setFlag, unsetFlagprotected boolean scratch
protected File file
protected File scratchFile
protected long lastModification
protected FileResource(ResourceFactory factory, File file)
public String getName()
Resourcepublic String getFullyQualifiedName()
ResourcegetFullyQualifiedName in interface Resource<File>getFullyQualifiedName in class AbstractResource<File>public File getUnderlyingResourceObject()
Filepublic InputStream getResourceInputStream()
ResourceInputStream represented by this Resource.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.file - The file to create the resource instance from.public boolean exists()
ResourceResource exists, return false if not.public boolean isDirectory()
FileResource exists and is actually a directory, otherwise return false;public boolean isStale()
public void markUpToDate()
public boolean mkdir()
mkdirs()public boolean mkdirs()
public boolean delete()
public boolean delete(boolean recursive)
Resource, and all child resources.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.
public T setContents(String data)
FileResource to the given Stringpublic T setContents(char[] data)
FileResource to the given character array.public T setContents(InputStream data)
public boolean createNewFile()
public T createTempResource()
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)
public boolean renameTo(FileResource<?> target)
FileResourceCopyright © 2013 JBoss by Red Hat. All Rights Reserved.