public abstract class VirtualResource extends java.lang.Object implements Resource
Resource.openStream() method to return a stream of
the contents of the virtual resource.ModuleManager,
ModuleDispatcher| Modifier and Type | Field and Description |
|---|---|
protected static java.nio.charset.Charset |
UTF8 |
| Constructor and Description |
|---|
VirtualResource() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
exists()
Returns true if the resource exists; if a stream to the content of the file may be opened.
|
Resource |
forFile(java.lang.String relativePath)
Returns a Resource based on a relative path, relative to the folder containing the resource.
|
Resource |
forLocale(java.util.Locale locale)
Returns a localized version of the resource.
|
java.lang.String |
getFile()
Returns the file portion of the Resource path, everything that follows the final forward slash.
|
java.lang.String |
getFolder()
Returns the portion of the path up to the last forward slash; this is the directory or folder portion of the
Resource.
|
java.lang.String |
getPath()
Return the path (the combination of folder and file).
|
boolean |
isVirtual()
Returns true if the resource is virtual, meaning this is no underlying file.
|
protected java.io.InputStream |
toInputStream(byte[] content) |
protected java.io.InputStream |
toInputStream(java.lang.String content) |
java.net.URL |
toURL()
Returns the URL for the resource, or null if it does not exist.
|
Resource |
withExtension(java.lang.String extension)
Returns a new Resource with the extension changed (or, if the resource does not have an extension, the extension
is added).
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitopenStreamprotected static final java.nio.charset.Charset UTF8
public VirtualResource()
public boolean exists()
ResourceResource.toURL() returns a non-null value. Starting in release 5.3.4, the result of this is cached.
Starting in 5.4, some "virtual resources", may return true even though Resource.toURL() returns null.public java.net.URL toURL()
Resourcepublic Resource forLocale(java.util.Locale locale)
Resourcepublic Resource forFile(java.lang.String relativePath)
Resourcepublic Resource withExtension(java.lang.String extension)
ResourceResource.toURL() may return null.withExtension in interface Resourceextension - to apply to the resource, such as "html" or "properties"public java.lang.String getFolder()
Resourcepublic java.lang.String getFile()
Resourcepublic java.lang.String getPath()
Resourceprotected java.io.InputStream toInputStream(java.lang.String content) throws java.io.IOException
java.io.IOExceptionprotected java.io.InputStream toInputStream(byte[] content) throws java.io.IOException
java.io.IOExceptionpublic boolean isVirtual()
ResourceResource.toURL(), Resource.forLocale(java.util.Locale),
Resource.withExtension(String), Resource.getFile(), Resource.getFolder(), Resource.getPath()}; these
operations will throw an UnsupportedOperationException.${project.version} - Copyright © 2003-2015 The Apache Software Foundation.