|
Forge - Parent 1.0.7-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.forge.resources.AbstractResource<File>
org.jboss.forge.resources.FileResource<T>
public abstract class FileResource<T extends FileResource<?>>
A standard, built-in resource for representing files on the filesystem.
Field Summary | |
---|---|
protected File |
file
|
protected long |
lastModification
|
protected boolean |
scratch
|
protected File |
scratchFile
|
Fields inherited from class org.jboss.forge.resources.AbstractResource |
---|
flags, parent, resourceFactory |
Constructor Summary | |
---|---|
protected |
FileResource(ResourceFactory factory,
File file)
|
Method Summary | ||
---|---|---|
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 |
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. |
|
|
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 |
Methods inherited from class org.jboss.forge.resources.AbstractResource |
---|
doListResources, equals, getFlags, getFullyQualifiedName, getResourceFactory, hashCode, isFlagSet, listResources, listResources, setFlag, unsetFlag |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean scratch
protected File file
protected File scratchFile
protected long lastModification
Constructor Detail |
---|
protected FileResource(ResourceFactory factory, File file)
Method Detail |
---|
public String getName()
Resource
public File getUnderlyingResourceObject()
File
public InputStream getResourceInputStream()
Resource
InputStream
represented by this Resource
.
public Resource<?> getParent()
getParent
in interface Resource<File>
getParent
in class AbstractResource<File>
public Resource<?> getChild(String name)
Resource
public 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()
Resource
Resource
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 String
public 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)
Resource
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.
reify
in interface Resource<File>
reify
in class AbstractResource<File>
public boolean renameTo(String pathspec)
public boolean renameTo(FileResource<?> target)
FileResource
|
Forge - Parent 1.0.7-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |