public interface: Resource
All Known Implementing Classes:
ContextResource, AbstractResource, ClasspathResource
Represents a resource on the server that may be used for server side processing, or may be exposed to the client
side. Generally, this represents an abstraction on top of files on the class path and files stored in the web
Resources are often used as map keys; they should be immutable and should implement hashCode() and equals().
|Method from org.apache.tapestry5.ioc.Resource Detail:|
public boolean exists()
Returns true if the resource exists; if a stream to the content of the file may be openned.
public Resource forFile(String relativePath)
Returns a Resource based on a relative path, relative to the folder containing the resource. Understands the "."
(current folder) and ".." (parent folder) conventions, and treats multiple sequential slashes as a single slash.
public Resource forLocale(Locale locale)
Returns a localized version of the resource. May return null if no such resource exists.
public String getFile()
Returns the file portion of the Resource path, everything that follows the final forward slash.
public String getFolder()
Returns the portion of the path up to the last forward slash; this is the directory or folder portion of the
public String getPath()
Return the path (the combination of folder and file).
public InputStream openStream() throws IOException
Opens a stream to the content of the resource, or returns null if the resource does not exist.
public URL toURL()
Returns the URL for the resource, or null if it does not exist.
public Resource withExtension(String extension)
Returns a new Resource with the extension changed (or, if the resource does not have an extension, the extension
is added). The new Resource may not exist (that is, #toURL() may return null.