Class ResourceKeyUtils
java.lang.Object
org.pentaho.reporting.libraries.resourceloader.ResourceKeyUtils
Provides a setup of utility methods for operating on a ResourceKey class.
- Author:
- David Kincade
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringconvertFactoryParametersToString(Map factoryParameters) Returns the list of factory parameters for the specified ResourceKey as a String representation in the format:static StringcreateStringResourceKey(String schema, String identifier, Map factoryParameters) Returns a string representation of the ResourceKey based on the pieces that are passed as parametersstatic ResourceKeyembedResourceInKey(ResourceManager manager, ResourceKey source, Map factoryParameters) Returns a new ResourceKey with the specified source resource embedded inside as a byte []static ResourceKeyDataParses the string version of the Resource Key into the componentsstatic MapparseFactoryParametersFromString(String factoryParameters) Returns a Map of parameters based on the input string.static ObjectreadSchemaFromString(String data) Returns the schema portion of the serialized ResourceKey string.static ResourceKeytoResourceKey(Object value, ResourceManager resourceManager, ResourceKey contextKey, Map parameters) Performs a simple attempt at a "smart" conversion to a ResourceKey.
-
Field Details
-
SERIALIZATION_PREFIX
- See Also:
-
-
Constructor Details
-
ResourceKeyUtils
public ResourceKeyUtils()
-
-
Method Details
-
createStringResourceKey
public static String createStringResourceKey(String schema, String identifier, Map factoryParameters) Returns a string representation of the ResourceKey based on the pieces that are passed as parameters- Parameters:
schema- the string representation of the schemaidentifier- the string representation of the identifierfactoryParameters- the set of factory parameters (nullallowed)- Returns:
- the string version with the pieces delimited and concatenated
-
parse
Parses the string version of the Resource Key into the components- Returns:
- Throws:
ResourceKeyCreationException
-
convertFactoryParametersToString
Returns the list of factory parameters for the specified ResourceKey as a String representation in the format:key=value:key=value:...:key=value
The colon (:) is the separator between parameters and the equal sign (=) is the separator between the key and the value. If the factory parameters is empty,nullwill be returned- Parameters:
factoryParameters- the parameter map.- Returns:
- a String representation of the factory parameters for the ResourceKey
-
parseFactoryParametersFromString
Returns a Map of parameters based on the input string. The string will be parsed using the same format as defined in thegetFactoryParametersAsString()method.- Parameters:
factoryParameters- the String representation of factory parameters- Returns:
- a Map of factory parameters parsed from the string, or
nullif the source string was null or contained no data
-
readSchemaFromString
Returns the schema portion of the serialized ResourceKey string. If the string is invalid,nullwill be returned.- Parameters:
data- the String serialized version of aResourceKey- Returns:
- the schema object.
-
toResourceKey
public static ResourceKey toResourceKey(Object value, ResourceManager resourceManager, ResourceKey contextKey, Map parameters) throws ResourceKeyCreationException Performs a simple attempt at a "smart" conversion to a ResourceKey.- If the
valueisnull, this method will returnnull - If the
valueis aResourceKey, thevaluewill be returned - If the
valueis aStringand is syntactically valid as aURL, it will be converted to aURLand then used to create aResourceKey - If the
valueis aStringand is NOT syntactically valid as aURL, it will be converted ot aFileand then used to create aResourceKey - All other types will be passed along to attempt a key creation as is
- Parameters:
value- the object to convert to aResourceKeyresourceManager- the resource manager used in key creationparameters- the parameters that should be passed to generate a resource key- Returns:
- the resource key created
- Throws:
ResourceKeyCreationException- indicates the value can not be used to create a Resource Key
- If the
-
embedResourceInKey
public static ResourceKey embedResourceInKey(ResourceManager manager, ResourceKey source, Map factoryParameters) throws IOException, ResourceKeyCreationException, ResourceLoadingException Returns a new ResourceKey with the specified source resource embedded inside as a byte []- Parameters:
source- the ResourceKey to the source which will be embedded - NOTE: the pattern can specify an exact name or a pattern for creating a temporary name. If the name exists, it will be replaced.factoryParameters- any factory parameters which should be added to the ResourceKey being created- Returns:
- the ResourceKey for the newly created embedded entry
- Throws:
IOExceptionResourceKeyCreationExceptionResourceLoadingException
-