public interface Resource<T> extends Faceted<ResourceFacet>
Resource is an abstraction on top of usable items within a Furnace 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 Addon instances to, for example, directly 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.
| Modifier and Type | Method and Description |
|---|---|
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()
|
boolean |
delete(boolean recursive)
Delete this resource, return
true if successful, false if not. |
boolean |
exists()
|
Resource<?> |
getChild(String name)
Get a child of this resource.
|
String |
getContents()
|
String |
getContents(Charset charset)
|
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. |
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. |
<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. |
List<Resource<?>> |
resolveChildren(String path)
Resolve children resources from this
Resource given a specific path. |
getFacet, getFacets, getFacets, hasAllFacets, hasAllFacets, hasFacet, supportsboolean delete()
throws UnsupportedOperationException
UnsupportedOperationException - if deleting is not supported by the underlying implementation.boolean delete(boolean recursive)
throws UnsupportedOperationException
true if successful, false if not.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()
Resource. If it's a file, for instance, just the file name.Resource.String getFullyQualifiedName()
File resource, this
would normally be the full path name.Resource<?> getParent()
null if the current resource is the filesystem root.Resource parent.Resource<T> createFrom(T file)
file - The target reference to create the resource instance from.Resource instance.List<Resource<?>> listResources()
List<Resource<?>> listResources(ResourceFilter filter)
ResourceFilter.T getUnderlyingResourceObject()
Resource.InputStream getResourceInputStream()
InputStream represented by this Resource.String getContents()
Resource<?> getChild(String name)
null if no child by the given name can be found.boolean exists()
<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.Copyright © 2014 JBoss by Red Hat. All rights reserved.