Class DefaultResourceManagerBackend
- java.lang.Object
-
- org.pentaho.reporting.libraries.resourceloader.DefaultResourceManagerBackend
-
- All Implemented Interfaces:
ResourceManagerBackend
public class DefaultResourceManagerBackend extends Object implements ResourceManagerBackend
-
-
Constructor Summary
Constructors Constructor Description DefaultResourceManagerBackend()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Resource
create(ResourceManager frontEnd, ResourceData data, ResourceKey context, Class[] target)
ResourceKey
createKey(Object data, Map<? extends ParameterKey,?> parameters)
ResourceKey
deriveKey(ResourceKey parent, String path, Map<? extends ParameterKey,?> parameters)
Derives a new key from the given resource-key.ResourceKey
deserialize(ResourceKey bundleKey, String serializedKey)
Converts a serialized version of aResourceKey
into an actualResourceKey
by locating the properResourceLoader
that can perform the deserialization.boolean
isResourceUnchanged(ResourceManager frontEnd, Resource resource)
ResourceData
loadRawData(ResourceManager frontEnd, ResourceKey key)
ResourceBundleData
loadResourceBundle(ResourceManager frontEnd, ResourceKey key)
Tries to find the first resource-bundle-loader that would be able to process the key.void
registerBundleLoader(ResourceBundleLoader loader)
void
registerDefaultFactories()
void
registerDefaultLoaders()
void
registerFactory(ResourceFactory factory)
void
registerLoader(ResourceLoader loader)
String
serialize(ResourceKey bundleKey, ResourceKey key)
Creates a String version of theResourceKey
that can be deserialized with thedeserialize()
method.URL
toURL(ResourceKey key)
-
-
-
Method Detail
-
createKey
public ResourceKey createKey(Object data, Map<? extends ParameterKey,?> parameters) throws ResourceKeyCreationException
- Specified by:
createKey
in interfaceResourceManagerBackend
- Throws:
ResourceKeyCreationException
-
deriveKey
public ResourceKey deriveKey(ResourceKey parent, String path, Map<? extends ParameterKey,?> parameters) throws ResourceKeyCreationException
Derives a new key from the given resource-key. Only keys for a hierarchical storage system (like file-systems or URLs) can have derived keys. Since LibLoader 0.3.0 only hierarchical keys can be derived. For that, the deriving path must be given as String. The optional parameter-map will be applied to the derived key after the parent's parameters have been copied to the new key. Before trying to derive the key, the system tries to interpret the path as absolute key-value.- Specified by:
deriveKey
in interfaceResourceManagerBackend
- Parameters:
parent
- the parent key, or null to interpret the path as absolute key.path
- the relative path, that is used to derive the key.parameters
- a optional map containing resource-key parameters.- Returns:
- the derived key.
- Throws:
ResourceKeyCreationException
- if deriving the key failed.
-
toURL
public URL toURL(ResourceKey key)
- Specified by:
toURL
in interfaceResourceManagerBackend
-
create
public Resource create(ResourceManager frontEnd, ResourceData data, ResourceKey context, Class[] target) throws ResourceLoadingException, ResourceCreationException
- Specified by:
create
in interfaceResourceManagerBackend
- Throws:
ResourceLoadingException
ResourceCreationException
-
isResourceUnchanged
public boolean isResourceUnchanged(ResourceManager frontEnd, Resource resource) throws ResourceLoadingException
- Specified by:
isResourceUnchanged
in interfaceResourceManagerBackend
- Throws:
ResourceLoadingException
-
loadResourceBundle
public ResourceBundleData loadResourceBundle(ResourceManager frontEnd, ResourceKey key) throws ResourceLoadingException
Tries to find the first resource-bundle-loader that would be able to process the key.- Specified by:
loadResourceBundle
in interfaceResourceManagerBackend
- Parameters:
key
- the resource-key.- Returns:
- the resourceloader for that key, or null, if no resource-loader is able to process the key.
- Throws:
ResourceLoadingException
- if an error occured.
-
loadRawData
public ResourceData loadRawData(ResourceManager frontEnd, ResourceKey key) throws UnrecognizedLoaderException, ResourceLoadingException
- Specified by:
loadRawData
in interfaceResourceManagerBackend
- Throws:
UnrecognizedLoaderException
ResourceLoadingException
-
registerDefaultFactories
public void registerDefaultFactories()
- Specified by:
registerDefaultFactories
in interfaceResourceManagerBackend
-
registerDefaultLoaders
public void registerDefaultLoaders()
- Specified by:
registerDefaultLoaders
in interfaceResourceManagerBackend
-
registerBundleLoader
public void registerBundleLoader(ResourceBundleLoader loader)
- Specified by:
registerBundleLoader
in interfaceResourceManagerBackend
-
registerLoader
public void registerLoader(ResourceLoader loader)
- Specified by:
registerLoader
in interfaceResourceManagerBackend
-
registerFactory
public void registerFactory(ResourceFactory factory)
- Specified by:
registerFactory
in interfaceResourceManagerBackend
-
deserialize
public ResourceKey deserialize(ResourceKey bundleKey, String serializedKey) throws ResourceKeyCreationException
Converts a serialized version of aResourceKey
into an actualResourceKey
by locating the properResourceLoader
that can perform the deserialization.- Specified by:
deserialize
in interfaceResourceManagerBackend
- Parameters:
bundleKey
-serializedKey
- the String serialized key to be deserialized @returns theResourceKey
that has been deserialized- Throws:
ResourceKeyCreationException
- indicates an error trying to create theResourceKey
from the deserialized version
-
serialize
public String serialize(ResourceKey bundleKey, ResourceKey key) throws ResourceException
Creates a String version of theResourceKey
that can be deserialized with thedeserialize()
method.- Specified by:
serialize
in interfaceResourceManagerBackend
- Parameters:
bundleKey
-key
-- Throws:
NullPointerException
- indicates the supplied key isnull
ResourceException
-
-