public ResourceKey deriveKey(final ResourceKey parent, final String path, final Map factoryKeys)
throws ResourceKeyCreationException
{
if (isSupportedKey(parent) == false)
{
throw new ResourceKeyCreationException("Assertation: Unsupported parent key type");
}
try
{
final File target;
if (path != null)
{
final File parentResource = (File) parent.getIdentifier();
final File parentFile = parentResource.getCanonicalFile().getParentFile();
if (parentFile == null)
{
throw new FileNotFoundException("Parent file does not exist");
}
target = new File(parentFile, path);
if (target.exists() == false || target.isFile() == false)
{
throw new ResourceKeyCreationException("Malformed value: " + path + " (" + target + "): File does not exist.");
}
}
else
{
target = (File) parent.getIdentifier();
}
final Map map;
if (factoryKeys != null)
{
map = new HashMap();
map.putAll(parent.getFactoryParameters());
map.putAll(factoryKeys);
}
else
{
map = parent.getFactoryParameters();
}
return new ResourceKey(parent.getSchema(), target, map);
}
catch (IOException ioe)
{
throw new ResourceKeyCreationException("Failed to create key", ioe);
}
}