public class PortletContextResource extends AbstractFileResolvingResource implements ContextResource
Resource
implementation for PortletContext
resources,
interpreting relative paths within the portlet application root directory.
Always supports stream access and URL access, but only allows java.io.File
access when the portlet
application archive is expanded.
PortletContext.getResourceAsStream(java.lang.String)
,
PortletContext.getRealPath(java.lang.String)
Constructor and Description |
---|
PortletContextResource(javax.portlet.PortletContext portletContext,
String path)
Create a new PortletContextResource.
|
Modifier and Type | Method and Description |
---|---|
Resource |
createRelative(String relativePath) |
boolean |
equals(Object obj) |
boolean |
exists()
This implementation checks
PortletContext.getResource . |
String |
getDescription() |
File |
getFile()
This implementation resolves "file:" URLs or alternatively delegates to
PortletContext.getRealPath ,
throwing a FileNotFoundException if not found or not resolvable. |
String |
getFilename() |
InputStream |
getInputStream()
This implementation delegates to
PortletContext.getResourceAsStream , but throws a FileNotFoundException
if not found. |
String |
getPath()
Return the path for this resource.
|
String |
getPathWithinContext() |
javax.portlet.PortletContext |
getPortletContext()
Return the PortletContext for this resource.
|
URL |
getURL()
This implementation delegates to
PortletContext.getResource , but throws a FileNotFoundException if no
resource found. |
int |
hashCode() |
boolean |
isReadable()
This implementation delegates to
PortletContext.getResourceAsStream , which returns null in case
of a non-readable resource (e.g. |
contentLength, customizeConnection, customizeConnection, getFile, getFileForLastModifiedCheck, isFile, isFile, lastModified, readableChannel
getURI, isOpen, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
contentLength, getURI, isFile, isOpen, lastModified, readableChannel
public PortletContextResource(javax.portlet.PortletContext portletContext, String path)
The Portlet spec requires that resource paths start with a slash, even if many containers accept paths without leading slash too. Consequently, the given path will be prepended with a slash if it doesn't already start with one.
portletContext
- the PortletContext to load frompath
- the path of the resourcepublic Resource createRelative(String relativePath)
createRelative
in interface Resource
createRelative
in class AbstractResource
public boolean equals(Object obj)
equals
in class AbstractResource
public boolean exists()
PortletContext.getResource
.exists
in interface Resource
exists
in class AbstractFileResolvingResource
PortletContext.getResource(String)
public String getDescription()
getDescription
in interface Resource
public File getFile() throws IOException
PortletContext.getRealPath
,
throwing a FileNotFoundException if not found or not resolvable.getFile
in interface Resource
getFile
in class AbstractFileResolvingResource
IOException
PortletContext.getResource(String)
,
PortletContext.getRealPath(String)
public String getFilename()
getFilename
in interface Resource
getFilename
in class AbstractResource
public InputStream getInputStream() throws IOException
PortletContext.getResourceAsStream
, but throws a FileNotFoundException
if not found.getInputStream
in interface InputStreamSource
IOException
PortletContext.getResourceAsStream(String)
public final String getPath()
public String getPathWithinContext()
getPathWithinContext
in interface ContextResource
public final javax.portlet.PortletContext getPortletContext()
public URL getURL() throws IOException
PortletContext.getResource
, but throws a FileNotFoundException if no
resource found.getURL
in interface Resource
getURL
in class AbstractResource
IOException
PortletContext.getResource(String)
public int hashCode()
hashCode
in class AbstractResource
public boolean isReadable()
PortletContext.getResourceAsStream
, which returns null
in case
of a non-readable resource (e.g. a directory).isReadable
in interface Resource
isReadable
in class AbstractFileResolvingResource
PortletContext.getResourceAsStream(String)
Copyright © 2019 Liferay, Inc.. All rights reserved.