类 PortletContextResource
- java.lang.Object
- org.springframework.core.io.AbstractResource
- org.springframework.core.io.AbstractFileResolvingResource
- org.springframework.web.portlet.context.PortletContextResource
- 所有已实现的接口:
ContextResource,InputStreamSource,Resource
public class PortletContextResource extends AbstractFileResolvingResource implements ContextResource
Resourceimplementation forPortletContextresources, interpreting relative paths within the portlet application root directory.Always supports stream access and URL access, but only allows
java.io.Fileaccess when the portlet application archive is expanded.- 从以下版本开始:
- 2.0
- 作者:
- Juergen Hoeller, John A. Lewis
- 另请参阅:
PortletContext.getResourceAsStream(java.lang.String),PortletContext.getRealPath(java.lang.String)
构造器概要
构造器 构造器 说明 PortletContextResource(PortletContext portletContext, String path)Create a new PortletContextResource.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 ResourcecreateRelative(String relativePath)This implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource.booleanequals(Object obj)This implementation compares description strings.booleanexists()This implementation checksPortletContext.getResource.StringgetDescription()Return a description for this resource, to be used for error output when working with the resource.FilegetFile()This implementation resolves "file:" URLs or alternatively delegates toPortletContext.getRealPath, throwing a FileNotFoundException if not found or not resolvable.StringgetFilename()This implementation always returnsnull, assuming that this resource type does not have a filename.InputStreamgetInputStream()This implementation delegates toPortletContext.getResourceAsStream, but throws a FileNotFoundException if not found.StringgetPath()Return the path for this resource.StringgetPathWithinContext()Return the path within the enclosing 'context'.PortletContextgetPortletContext()Return the PortletContext for this resource.URLgetURL()This implementation delegates toPortletContext.getResource, but throws a FileNotFoundException if no resource found.inthashCode()This implementation returns the description's hash code.booleanisReadable()This implementation delegates toPortletContext.getResourceAsStream, which returnsnullin case of a non-readable resource (e.g. a directory).从类继承的方法 org.springframework.core.io.AbstractFileResolvingResource
contentLength, customizeConnection, customizeConnection, getFile, getFileForLastModifiedCheck, lastModified
从类继承的方法 org.springframework.core.io.AbstractResource
getURI, isOpen, toString
从接口继承的方法 org.springframework.core.io.Resource
contentLength, getURI, isOpen, lastModified
构造器详细资料
PortletContextResource
public PortletContextResource(PortletContext portletContext, String path)
Create a new PortletContextResource.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 resource
方法详细资料
getPortletContext
public final PortletContext getPortletContext()
Return the PortletContext for this resource.
exists
public boolean exists()
This implementation checksPortletContext.getResource.- 指定者:
exists在接口中Resource- 覆盖:
exists在类中AbstractFileResolvingResource- 另请参阅:
PortletContext.getResource(String)
isReadable
public boolean isReadable()
This implementation delegates toPortletContext.getResourceAsStream, which returnsnullin case of a non-readable resource (e.g. a directory).
getInputStream
public InputStream getInputStream() throws IOException
This implementation delegates toPortletContext.getResourceAsStream, but throws a FileNotFoundException if not found.- 指定者:
getInputStream在接口中InputStreamSource- 返回:
- the input stream for the underlying resource (must not be
null) - 抛出:
FileNotFoundException- if the underlying resource doesn't existIOException- if the content stream could not be opened- 另请参阅:
PortletContext.getResourceAsStream(String)
getURL
public URL getURL() throws IOException
This implementation delegates toPortletContext.getResource, but throws a FileNotFoundException if no resource found.- 指定者:
getURL在接口中Resource- 覆盖:
getURL在类中AbstractResource- 抛出:
IOException- if the resource cannot be resolved as URL, i.e. if the resource is not available as descriptor- 另请参阅:
PortletContext.getResource(String)
getFile
public File getFile() throws IOException
This implementation resolves "file:" URLs or alternatively delegates toPortletContext.getRealPath, throwing a FileNotFoundException if not found or not resolvable.- 指定者:
getFile在接口中Resource- 覆盖:
getFile在类中AbstractFileResolvingResource- 抛出:
FileNotFoundException- if the resource cannot be resolved as absolute file path, i.e. if the resource is not available in a file systemIOException- in case of general resolution/reading failures- 另请参阅:
PortletContext.getResource(String),PortletContext.getRealPath(String)
createRelative
public Resource createRelative(String relativePath)
从类复制的说明:AbstractResourceThis implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource.- 指定者:
createRelative在接口中Resource- 覆盖:
createRelative在类中AbstractResource- 参数:
relativePath- the relative path (relative to this resource)- 返回:
- the resource handle for the relative resource
getFilename
public String getFilename()
从类复制的说明:AbstractResourceThis implementation always returnsnull, assuming that this resource type does not have a filename.- 指定者:
getFilename在接口中Resource- 覆盖:
getFilename在类中AbstractResource
getDescription
public String getDescription()
从接口复制的说明:ResourceReturn a description for this resource, to be used for error output when working with the resource.Implementations are also encouraged to return this value from their
toStringmethod.- 指定者:
getDescription在接口中Resource- 另请参阅:
Object.toString()
getPathWithinContext
public String getPathWithinContext()
从接口复制的说明:ContextResourceReturn the path within the enclosing 'context'.This is typically path relative to a context-specific root directory, e.g. a ServletContext root or a PortletContext root.
- 指定者:
getPathWithinContext在接口中ContextResource
equals
public boolean equals(Object obj)
从类复制的说明:AbstractResourceThis implementation compares description strings.- 覆盖:
equals在类中AbstractResource- 另请参阅:
Resource.getDescription()
hashCode
public int hashCode()
从类复制的说明:AbstractResourceThis implementation returns the description's hash code.- 覆盖:
hashCode在类中AbstractResource- 另请参阅:
Resource.getDescription()