public class RelativeResolver extends Object implements DelegateResourceResolver
Decorator resource resolver that use parent path and extension for resource resolution.
For example, the parent path values "email/user/" and the extension is ".html". The resource name is "hello". This resource resolver appends the parent path, the resource name and the extension generating the path "email/user/hello.html".
Once the path is generated, then this implementation delegates the real resource resolution to another implementation.
Constructor and Description |
---|
RelativeResolver(RelativisableResourceResolver delegate,
String parentPath)
Initialize the resolver with the mandatory delegate and a parent path.
|
RelativeResolver(RelativisableResourceResolver delegate,
String parentPath,
String extension)
Initialize the resolver with the mandatory delegate, a parent path and a
extension.
|
Modifier and Type | Method and Description |
---|---|
ResourceResolver |
getActualResourceResolver()
Finds the final delegated
ResourceResolver by any level of
delegation. |
String |
getExtension() |
String |
getParentPath() |
Resource |
getResource(String path)
Find the resource using the resource path (or its name).
|
ResourcePath |
getResourcePath(String path)
Transforms a string path in a
ResourcePath . |
boolean |
supports(String path)
Indicates if the resource path can be handled by this resource resolver
or not.
|
public RelativeResolver(RelativisableResourceResolver delegate, String parentPath)
delegate
- the resolver that will do the real resource resolutionparentPath
- a string to add before the resource pathpublic RelativeResolver(RelativisableResourceResolver delegate, String parentPath, String extension)
delegate
- the resolver that will do the real resource resolutionparentPath
- a string to add before the resource pathextension
- a string to add after the resource pathpublic Resource getResource(String path) throws ResourceResolutionException
ResourceResolver
getResource
in interface ResourceResolver
path
- the path of the resourceResourceResolutionException
- when the resource couldn't be foundpublic String getParentPath()
public String getExtension()
public boolean supports(String path)
ResourceResolver
supports
in interface ResourceResolver
path
- the name or the path of the resourcepublic ResourcePath getResourcePath(String path)
ResourceResolver
ResourcePath
.getResourcePath
in interface ResourceResolver
public ResourceResolver getActualResourceResolver()
DelegateResourceResolver
ResourceResolver
by any level of
delegation.getActualResourceResolver
in interface DelegateResourceResolver
ResourceResolver
that can be translated to an template
engine adapterCopyright © 2017. All rights reserved.