public interface IResource
Instances of IResource
are created by an associated
IResourceFactory
object.
Implementors of this interface also implement the
IResourceVisitor.Resource
interface.
Modifier and Type | Method and Description |
---|---|
IResourceVisitor.Resource |
asVisitorResource()
This is a convenience method to return the current resource as a
IResourceVisitor.Resource object. |
boolean |
exists()
Returns true if the resource exists.
|
InputStream |
getInputStream()
Returns a
InputStream object for the resource if the resource
is not a directory/folder resource. |
String |
getPath()
Returns the reference path of this resource.
|
Reader |
getReader()
Returns a
Reader object for the resource if the resource is not a
directory/folder resource. |
URI |
getReferenceURI()
Returns the reference URI.
|
long |
getSize()
Returns the size of the content for this resource.
|
URI |
getURI()
Returns the URI for this resource.
|
boolean |
isFolder() |
long |
lastModified()
Returns the last-modified date of the resource.
|
URI |
resolve(String relative)
This is equivalent to calling
relative.getReferenceURI().resolve() |
void |
setReferenceURI(URI referenceUri)
Sets the reference URI.
|
void |
walkTree(IResourceVisitor visitor)
Walks the folder tree rooted at the current resource, calling the
IResourceVisitor.visitResource(IResourceVisitor.Resource, String)
method for each resource or folder resource encountered. |
URI getURI()
IResourceFactory
object used to create
this instance. Neither is there any requirement that the path/filename of the URI have any
relationship to the URI originally specified in IAggregator.newResource(URI)
. The
method may return a URI to a file in a cache directory with an arbitrary name as a result of
bundle extraction and/or running resource converters. The file extension portion of the URI
will be the same as the originally requested URI, however.
Use getReferenceURI()
to obtain the originally requested URI.
Because instances of this object can refer to cache resources, you should not hold on to references to IResource objects long term (more than the duration of a request).
String getPath()
getReferenceURI().getPath()
.URI getReferenceURI()
IAggregator.newResource(URI)
, before any conversions by resource factories or
resource converters. This URI may or may not be the same value that is returned by
getURI()
and it may be a pseudo URI specifying a scheme that is not directly
supported by the platform (e.g. namedbundleresource).void setReferenceURI(URI referenceUri)
IllegalStateException
is thrown.referenceUri
- the reference uri
throws IllegalStateExceptionboolean exists()
long lastModified()
boolean isFolder()
long getSize() throws IOException
IOException
is thrown.IOException
URI resolve(String relative)
relative.getReferenceURI().resolve()
relative
- the path to resolve againstReader getReader() throws IOException
Reader
object for the resource if the resource is not a
directory/folder resource.IOException
- if the resource is a folder, or an I/O error occurredInputStream getInputStream() throws IOException
InputStream
object for the resource if the resource
is not a directory/folder resource.IOException
- if the resource is a folder, or an I/O error occurredvoid walkTree(IResourceVisitor visitor) throws IOException
IResourceVisitor.visitResource(IResourceVisitor.Resource, String)
method for each resource or folder resource encountered.
If this resource is not a folder, then visitor's
IResourceVisitor.visitResource(IResourceVisitor.Resource, String)
method is called once for this resource.
visitor
- An instance of IResourceVisitor
IOException
IResourceVisitor.Resource asVisitorResource()
IResourceVisitor.Resource
object. This is useful for when you want to invoke a
resource visitor for a resource that was obtained by means other than
walkTree(IResourceVisitor)
. The resource must exist.
Note that calling IResourceVisitor.Resource.newResource(IAggregator)
on objects
returned from this method will generally throw UnsupportedOperationException
IResourceVisitor.Resource
for current resourceCopyright © 2011-2015 IBM. All Rights Reserved.