public class FileResource extends AbstractResourceBase
Modifier and Type | Class and Description |
---|---|
protected class |
FileResource.VisitorResource
Implementation of
IResourceVisitor.Resource for files. |
Constructor and Description |
---|
FileResource(URI uri)
Public constructor used by factory
|
Modifier and Type | Method and Description |
---|---|
FileResource.VisitorResource |
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. |
Reader |
getReader()
Returns a
Reader object for the resource if the resource is not a
directory/folder resource. |
long |
getSize()
Returns the size of the content for this resource.
|
boolean |
isFolder() |
long |
lastModified()
Returns the last-modified date of the resource.
|
protected FileResource |
newInstance(URI uri) |
String |
toString() |
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. |
getPath, getReferenceURI, getURI, resolve, setReferenceURI
public FileResource(URI uri)
uri
- the resource URIpublic boolean exists()
IResource
exists
in interface IResource
exists
in class AbstractResourceBase
public long lastModified()
IResource
lastModified
in interface IResource
lastModified
in class AbstractResourceBase
public boolean isFolder()
isFolder
in interface IResource
isFolder
in class AbstractResourceBase
public long getSize() throws IOException
IResource
IOException
is thrown.getSize
in interface IResource
getSize
in class AbstractResourceBase
IOException
public Reader getReader() throws IOException
IResource
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 occurredpublic InputStream getInputStream() throws IOException
IResource
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 occurredpublic 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
walkTree
in class AbstractResourceBase
visitor
- An instance of IResourceVisitor
IOException
public FileResource.VisitorResource 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
asVisitorResource
in class AbstractResourceBase
IResourceVisitor.Resource
for current resourceprotected FileResource newInstance(URI uri)
Copyright © 2011-2015 IBM. All Rights Reserved.