|
Forge - Shell API 1.2.0.Final | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Resource<T>
A Resource is an abstraction on top of usable items within a Forge project. For instance, files, source code, etc. Like a simplified virtual file system, a Resource is represented hierarchically with a parent and children. This allows plugins to say, direct access to project elements within a consistent API from files to class members. However, Resource instances should be treated as representative query result objects. A modification to an instance variable in a resource will not be persisted. Rather than thinking of the Resource object as meta-data (which it is not), it is better conceptualized as a wrapper or "view" of an underlying resource such as a File. For this reason, custom Resource types should never implement any sort of static cache and should preferably lazily initialize their data.
| Method Summary | ||
|---|---|---|
Resource<T> |
createFrom(T file)
Create a new resource instance for the target resource reference of the type that this current resource is. |
|
boolean |
delete()
Delete this resource, return true if successful, false if not. |
|
boolean |
delete(boolean recursive)
Delete this resource, return true if successful, false if not. |
|
boolean |
exists()
Return true if this Resource exists, return false if not. |
|
Resource<?> |
getChild(String name)
Get a child of this resource. |
|
Set<ResourceFlag> |
getFlags()
|
|
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. |
|
ResourceFactory |
getResourceFactory()
Return the ResourceFactory with which this Resource was created. |
|
InputStream |
getResourceInputStream()
Get the InputStream represented by this Resource. |
|
T |
getUnderlyingResourceObject()
Get the underlying object represented by this Resource |
|
boolean |
isFlagSet(ResourceFlag flag)
Return true if the given ResourceFlag is set. |
|
List<Resource<?>> |
listResources()
Return a list of child resources of the current resource. |
|
List<Resource<?>> |
listResources(ResourceFilter filter)
Return a list of child resources of the current resource matching the given ResourceFilter. |
|
|
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. |
|
void |
setFlag(ResourceFlag flag)
Set the given ResourceFlag. |
|
void |
unsetFlag(ResourceFlag flag)
Unset the given ResourceFlag. |
|
| Method Detail |
|---|
boolean delete()
throws UnsupportedOperationException
UnsupportedOperationException - if deleting is not supported by the underlying implementation.
boolean delete(boolean recursive)
throws UnsupportedOperationException
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 delete()
UnsupportedOperationException - if deleting is not supported by the underlying implementation.String getName()
String getFullyQualifiedName()
Resource<?> getParent()
Resource<T> createFrom(T file)
file - The target reference to create the resource instance from.
List<Resource<?>> listResources()
List<Resource<?>> listResources(ResourceFilter filter)
ResourceFilter.
T getUnderlyingResourceObject()
Resource
InputStream getResourceInputStream()
InputStream represented by this Resource.
Resource<?> getChild(String name)
void setFlag(ResourceFlag flag)
ResourceFlag.
void unsetFlag(ResourceFlag flag)
ResourceFlag.
boolean isFlagSet(ResourceFlag flag)
ResourceFlag is set.
boolean exists()
Resource exists, return false if not.
Set<ResourceFlag> getFlags()
<R extends Resource<?>> R reify(Class<R> type)
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.
ResourceFactory getResourceFactory()
ResourceFactory with which this Resource was created. If no factory was used, return
null.
|
Forge - Shell API 1.2.0.Final | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||