public abstract class AbstractResourceBase extends Object implements IResource
Constructor and Description |
---|
AbstractResourceBase(URI uri) |
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.
|
String |
getPath()
Returns the reference path of this 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 uri)
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. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getInputStream, getReader
public AbstractResourceBase(URI uri)
public URI getURI()
IResource
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 IResource.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).
public String getPath()
IResource
getReferenceURI().getPath()
.public URI getReferenceURI()
IResource
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
IResource.getURI()
and it may be a pseudo URI specifying a scheme that is not directly
supported by the platform (e.g. namedbundleresource).getReferenceURI
in interface IResource
public void setReferenceURI(URI uri)
IResource
IllegalStateException
is thrown.setReferenceURI
in interface IResource
uri
- the reference uri
throws IllegalStateExceptionpublic boolean exists()
IResource
public long lastModified()
IResource
lastModified
in interface IResource
public boolean isFolder()
public long getSize() throws IOException
IResource
IOException
is thrown.getSize
in interface IResource
IOException
public URI resolve(String relative)
IResource
relative.getReferenceURI().resolve()
public void walkTree(IResourceVisitor visitor) throws IOException
IResource
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.
walkTree
in interface IResource
visitor
- An instance of IResourceVisitor
IOException
public IResourceVisitor.Resource asVisitorResource()
IResource
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
IResource.walkTree(IResourceVisitor)
. The resource must exist.
Note that calling IResourceVisitor.Resource.newResource(IAggregator)
on objects
returned from this method will generally throw UnsupportedOperationException
asVisitorResource
in interface IResource
IResourceVisitor.Resource
for current resourceCopyright © 2011-2015 IBM. All Rights Reserved.