ConfigPropertiesHelper to implement the named configuration APIConfigPropertiesHelper instance will maintain the values of all properties. The first thing to do is to create the properties in the constructor of the Plugin configuration. addxxxProperty(String name) methods. In that case the default value will be set automatically by the classpublic class OpenPNGImagePluginConfiguration implements Configuration { private static OpenPNGImagePluginConfiguration conf = null; private final ConfigPropertiesHelper helper = new ConfigPropertiesHelper(); private OpenPNGImagePluginConfiguration() { ConfigPropertiesHelper.ConfigSet set = helper.createDefaultConfiguration(); set.addIntProperty("maxWidth").setValue(1000); set.addBooleanProperty("limitWidth"); } public static OpenPNGImagePluginConfiguration getInstance() { if (conf == null) { conf = new OpenPNGImagePluginConfiguration(); } return conf; } @Override public Set<String> getConfigurationPropertiesNames(String confName) { return helper.getConfigurationPropertiesNames(confName); } @Override public boolean hasConfigurationProperty(String propertyName, String confName) { return helper.hasConfigurationProperty(propertyName, confName); } @Override public Object getConfigurationProperty(File dir, String propertyName, String confName) { return helper.getConfigurationProperty(dir, propertyName, confName); } @Override public Class getConfigurationPropertyType(String propertyName, String confName) { return helper.getConfigurationPropertyType(propertyName, confName); } @Override public void setConfigurationProperty(File dir, String propertyName, String confName, Object property) { helper.setConfigurationProperty(dir, propertyName, confName, property); } }
Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences