Package org.springframework.core.io

# Class DefaultResourceLoader.ClassPathContextResource

java.lang.Object
org.springframework.core.io.AbstractResource
org.springframework.core.io.AbstractFileResolvingResource
org.springframework.core.io.ClassPathResource
org.springframework.core.io.DefaultResourceLoader.ClassPathContextResource

All Implemented Interfaces:
  `ContextResource`, `InputStreamSource`, `Resource`

Enclosing class:
  DefaultResourceLoader

protected static class DefaultResourceLoader.ClassPathContextResource extends ClassPathResource implements ContextResource
ClassPathResource that explicitly expresses a context-relative path through implementing the ContextResource interface.

## Constructor Summary

Constructors
Constructor
Description
`ClassPathContextResource(String path, ClassLoader classLoader)`

## Method Summary

Modifier and Type
Method
Description
`Resource`
`createRelative(String relativePath)`
This implementation creates a `ClassPathResource`, applying the given path relative to the path used to create this descriptor.
`String`
`getPathWithinContext()`
Return the path within the enclosing 'context'.

### Methods inherited from class org.springframework.core.io.ClassPathResource

`equals, exists, getClassLoader, getDescription, getFilename, getInputStream, getPath, getURL, hashCode, isReadable, resolveURL`

### Methods inherited from class org.springframework.core.io.AbstractFileResolvingResource

`contentLength, customizeConnection, customizeConnection, getFile, getFile, getFileForLastModifiedCheck, isFile, isFile, lastModified, readableChannel`

### Methods inherited from class org.springframework.core.io.AbstractResource

`getURI, isOpen, toString`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.springframework.core.io.InputStreamSource

`getInputStream`

### Methods inherited from interface org.springframework.core.io.Resource

`contentLength, exists, getContentAsByteArray, getContentAsString, getDescription, getFile, getFilename, getURI, getURL, isFile, isOpen, isReadable, lastModified, readableChannel`

## Constructor Details

### ClassPathContextResource

public ClassPathContextResource(String path, @Nullable ClassLoader classLoader)

## Method Details

### getPathWithinContext

public String getPathWithinContext()
Description copied from interface: `ContextResource`
Return the path within the enclosing 'context'.

This is typically path relative to a context-specific root directory, for example, a ServletContext root or a PortletContext root.

Specified by:
  `getPathWithinContext` in interface `ContextResource`

### createRelative

public Resource createRelative(String relativePath)
Description copied from class: `ClassPathResource`
This implementation creates a `ClassPathResource`, applying the given path relative to the path used to create this descriptor.

Specified by:
  `createRelative` in interface `Resource`
Overrides:
  `createRelative` in class `ClassPathResource`
Parameters:
  `relativePath` - the relative path (relative to this resource)
Returns:
  the resource handle for the relative resource
See Also:
  - `StringUtils.applyRelativePath(String, String)`