org.daisy.dotify.impl.config.DefaultConfigurationsProvider Maven / Gradle / Ivy
package org.daisy.dotify.impl.config;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InvalidPropertiesFormatException;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.daisy.streamline.api.config.ConfigurationDetails;
import org.daisy.streamline.api.config.ConfigurationsProvider;
import org.daisy.streamline.api.config.ConfigurationsProviderException;
import org.daisy.dotify.common.io.AbstractResourceLocator;
import org.daisy.dotify.common.io.ResourceLocatorException;
/**
* Provides a default set of configurations. These should not be accessed directly,
* use the ConfigurationsCatalog instead.
* @author Joel Håkansson
*/
public class DefaultConfigurationsProvider extends AbstractResourceLocator implements ConfigurationsProvider {
private static final String PRESETS_PATH = "resource-files/";
private final Logger logger;
private final Properties props = new Properties();
private final Map urls;
private Set details;
/**
* Creates a new default configurations provider. This should not be accessed directly,
* use the ConfigurationsCatalog instead.
*/
public DefaultConfigurationsProvider() {
logger = Logger.getLogger(this.getClass().getCanonicalName());
try {
URL tablesURL = getResource("presets_catalog.xml");
if(tablesURL!=null){
props.loadFromXML(tablesURL.openStream());
} else {
logger.warning("Cannot locate catalog file");
}
} catch (IOException e) {
logger.log(Level.WARNING, "Failed to load catalog.", e);
}
urls = new HashMap();
for (Entry