Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| The Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.web.portlet.context
Class PortletContextResource

    java.lang.Object
      org.springframework.core.io.AbstractResource
          org.springframework.web.portlet.context.PortletContextResource

All Implemented Interfaces:
  InputStreamSource, Resource

    public class PortletContextResource

extends AbstractResource

Resource implementation for PortletContext resources, interpreting relative paths within the portlet application root.

Always supports stream access, but only allows java.io.File access when the portlet application archive is expanded. Always supports resolution as URL.

Since:
  2.0
Author:
  Juergen Hoeller, John A. Lewis
See Also:
  `PortletContext.getResourceAsStream(java.lang.String)`, `PortletContext.getRealPath(java.lang.String)`

Constructor Summary
`PortletContextResource(PortletContext portletContext, String path)` Create a new PortletContextResource.

Method Summary
`Resource` | `createRelative(String relativePath)` This implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource.
`boolean` | `equals(Object obj)` This implementation compares description strings.
`String` | `getDescription()` This abstract method declaration shadows the method in the Resource interface.
`File` | `getFile()` This implementation delegates to PortletContext.getRealPath, but throws a FileNotFoundException if not found or not resolvable.
`String` | `getFilename()` This implementation always throws IllegalStateException, assuming that the resource does not carry a filename.
`InputStream` | `getInputStream()` This implementation delegates to PortletContext.getResourceAsStream, but throws a FileNotFoundException if not found.
`String` | `getPath()` Return the path for this resource.
`PortletContext` | `getPortletContext()` Return the PortletContext for this resource.
`URL` | `getURL()` This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to a URL.
`int` | `hashCode()` This implementation returns the description's hash code.

Methods inherited from class org.springframework.core.io.AbstractResource
`exists, isOpen, toString`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### 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.

  Parameters:
    `portletContext` - the PortletContext to load from
    `path` - the path of the resource

Method Detail

### getPortletContext

    public PortletContext getPortletContext()

  Return the PortletContext for this resource.

### getPath

    public String getPath()

  Return the path for this resource.

### getInputStream

    public InputStream getInputStream()
                               throws IOException

  This implementation delegates to PortletContext.getResourceAsStream, but throws a FileNotFoundException if not found.

  Throws:
    `IOException` - if the stream could not be opened
  See Also:
    `PortletContext.getResourceAsStream(java.lang.String)`

### getURL

    public URL getURL()
               throws IOException

  Description copied from class: `AbstractResource`
  This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to a URL.

  Specified by:
    `getURL` in interface `Resource`
  Overrides:
    `getURL` in class `AbstractResource`
  Throws:
    `IOException` - if the resource cannot be resolved as URL, i.e. if the resource is not available as descriptor

### getFile

    public File getFile()
                 throws IOException

  This implementation delegates to PortletContext.getRealPath, but throws a FileNotFoundException if not found or not resolvable.

  Specified by:
    `getFile` in interface `Resource`
  Overrides:
    `getFile` in class `AbstractResource`
  Throws:
    `IOException` - if the resource cannot be resolved as absolute file path, i.e. if the resource is not available in a file system
  See Also:
    `PortletContext.getRealPath(java.lang.String)`

### createRelative

    public Resource createRelative(String relativePath)
                            throws IOException

  Description copied from class: `AbstractResource`
  This implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource.

  Specified by:
    `createRelative` in interface `Resource`
  Overrides:
    `createRelative` in class `AbstractResource`
  Parameters:
    `relativePath` - the relative path (relative to this resource)
  Returns:
    the resource handle for the relative resource
  Throws:
    `IOException` - if the relative resource cannot be determined

### getFilename

    public String getFilename()

  Description copied from class: `AbstractResource`
  This implementation always throws IllegalStateException, assuming that the resource does not carry a filename.

  Specified by:
    `getFilename` in interface `Resource`
  Overrides:
    `getFilename` in class `AbstractResource`

### getDescription

    public String getDescription()

  Description copied from class: `AbstractResource`
  This abstract method declaration shadows the method in the Resource interface. This is necessary to make the `toString` implementation in this class work on Sun's JDK 1.3 classic VM, which can't find the method when executing `toString` else. Furthermore, `getDescription` is also called from `equals` and `hashCode`

  Specified by:
    `getDescription` in interface `Resource`
  Specified by:
    `getDescription` in class `AbstractResource`
  See Also:
    `Resource.getDescription()`, `AbstractResource.toString()`, `AbstractResource.equals(Object)`, `AbstractResource.hashCode()`

### equals

    public boolean equals(Object obj)

  Description copied from class: `AbstractResource`
  This implementation compares description strings.

  Overrides:
    `equals` in class `AbstractResource`
  See Also:
    `AbstractResource.getDescription()`

### hashCode

    public int hashCode()

  Description copied from class: `AbstractResource`
  This implementation returns the description's hash code.

  Overrides:
    `hashCode` in class `AbstractResource`
  See Also:
    `AbstractResource.getDescription()`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| The Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2007 The Spring Framework.