/*
- * FreenetSone - PluginStoreConfigurationBackend.java - Copyright © 2010 David Roden
+ * Sone - PluginStoreConfigurationBackend.java - Copyright © 2010–2013 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
package net.pterodactylus.sone.freenet;
-import java.util.logging.Level;
import java.util.logging.Logger;
import net.pterodactylus.util.config.AttributeNotFoundException;
public class PluginStoreConfigurationBackend implements ExtendedConfigurationBackend {
/** The logger. */
+ @SuppressWarnings("unused")
private static final Logger logger = Logging.getLogger(PluginStoreConfigurationBackend.class);
/** The plugin respirator. */
}
}
- /**
- * {@inheritDoc}
- */
@Override
public String getValue(String attribute) throws ConfigurationException {
if (!pluginStore.strings.containsKey(attribute)) {
return pluginStore.strings.get(attribute);
}
- /**
- * {@inheritDoc}
- */
@Override
public void putValue(String attribute, String value) throws ConfigurationException {
pluginStore.strings.put(attribute, value);
save();
}
- /**
- * {@inheritDoc}
- */
@Override
public Boolean getBooleanValue(String attribute) throws ConfigurationException {
if (!pluginStore.booleans.containsKey(attribute)) {
return pluginStore.booleans.get(attribute);
}
- /**
- * {@inheritDoc}
- */
@Override
public void setBooleanValue(String attribute, Boolean value) throws ConfigurationException {
pluginStore.booleans.put(attribute, value);
save();
}
- /**
- * {@inheritDoc}
- */
@Override
public Double getDoubleValue(String attribute) throws ConfigurationException {
if (!pluginStore.strings.containsKey(attribute)) {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public void setDoubleValue(String attribute, Double value) throws ConfigurationException {
pluginStore.strings.put(attribute, String.valueOf(value));
save();
}
- /**
- * {@inheritDoc}
- */
@Override
public Integer getIntegerValue(String attribute) throws ConfigurationException {
if (!pluginStore.integers.containsKey(attribute)) {
return pluginStore.integers.get(attribute);
}
- /**
- * {@inheritDoc}
- */
@Override
public void setIntegerValue(String attribute, Integer value) throws ConfigurationException {
pluginStore.integers.put(attribute, value);
save();
}
- /**
- * {@inheritDoc}
- */
@Override
public Long getLongValue(String attribute) throws ConfigurationException {
if (!pluginStore.longs.containsKey(attribute)) {
return pluginStore.longs.get(attribute);
}
- /**
- * {@inheritDoc}
- */
@Override
public void setLongValue(String attribute, Long value) throws ConfigurationException {
pluginStore.longs.put(attribute, value);
save();
}
- //
- // PRIVATE METHODS
- //
-
- /**
- * Saves the configuration to the plugin store.
- */
- private void save() {
+ @Override
+ public void save() throws ConfigurationException {
try {
pluginRespirator.putStore(pluginStore);
} catch (DatabaseDisabledException dde1) {
- logger.log(Level.WARNING, "Could not store plugin store, database is disabled.", dde1);
+ throw new ConfigurationException("Could not store plugin store, database is disabled.", dde1);
}
}