}
}
try
{
final ResourceKey contentBase = runtime.getProcessingContext().getContentBase();
final ResourceManager resManager = runtime.getProcessingContext().getResourceManager();
final ResourceKey key;
if (value instanceof ResourceKey)
{
key = (ResourceKey) value;
}
else if (value instanceof Blob)
{
final Blob b = (Blob) value;
final byte[] data = IOUtils.getInstance().readBlob(b);
key = resManager.createKey(data);
}
else if (value instanceof String)
{
final Object baseURL = element.getAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.CONTENT_BASE);
if (baseURL instanceof String)
{
final ResourceKey baseKey = createKeyFromString(resManager, null, (String) baseURL);
key = createKeyFromString(resManager, baseKey, (String) value);
}
else if (baseURL instanceof ResourceKey)
{
final ResourceKey baseKey = (ResourceKey) baseURL;
key = createKeyFromString(resManager, baseKey, (String) value);
}
else if (baseURL != null)
{
// if a base-url object is given, we assume that it is indeed valid.
final ResourceKey baseKey = resManager.createKey(baseURL);
key = createKeyFromString(resManager, baseKey, (String) value);
}
else
{
key = createKeyFromString(resManager, contentBase, (String) value);
}
}
else
{
key = resManager.createKey(value);
}
if (key == null)
{
return null;
}
final Resource resource = resManager.create(key, contentBase, ContentType.TARGETS);
final Object resourceContent = resource.getResource();
if (resourceContent instanceof DrawableWrapper)
{
return resourceContent;
}