List of usage examples for org.apache.commons.configuration AbstractConfiguration AbstractConfiguration
public AbstractConfiguration()
AbstractConfiguration
. From source file:de.hybris.platform.b2b.mock.MockConfigurationService.java
private Configuration getConfigurationInternal(final ConfigIntf hybrisconfig) throws IOException { return new AbstractConfiguration() { /**//from www. j a va 2s . c o m * @see org.apache.commons.configuration.AbstractConfiguration#addPropertyDirect(String, Object) */ @Override protected void addPropertyDirect(final String key, final Object value) { hybrisconfig.setParameter(key, (String) value); } /** * @see org.apache.commons.configuration.Configuration#containsKey(String) */ @Override public boolean containsKey(final String key) { return hybrisconfig.getParameter(key) != null; } /** * @see org.apache.commons.configuration.Configuration#getKeys() */ @Override public Iterator<String> getKeys() { return hybrisconfig.getAllParameters().keySet().iterator(); } /** * @see org.apache.commons.configuration.Configuration#getProperty(String) */ @Override public Object getProperty(final String key) { return hybrisconfig.getParameter(key); } /** * @see org.apache.commons.configuration.Configuration#isEmpty() */ @Override public boolean isEmpty() { // assume hybris config is never empty return false; } /** * @see org.apache.commons.configuration.Configuration#getString(String) */ @Override public String getString(final String key) { return this.getString(key, ""); } /** * Default behavior gets overriden with that one from hybris. This disables the * {@link org.apache.commons.configuration.interpol.ConfigurationInterpolator} which would be created/asked * with every call for an appropriate {@link org.apache.commons.lang.text.StrLookup} which itself deals with an * {@link org.apache.commons.lang.text.StrSubstitutor} and so on. (only pitfall is that variable replacement as * commons defines it doesn't work anymore) * * @see org.apache.commons.configuration.AbstractConfiguration#getString(String, String) */ @Override public String getString(final String key, final String defaultValue) { return hybrisconfig.getString(key, defaultValue); } @Override public Collection getErrorListeners() { return super.getErrorListeners(); // To change body of // overridden methods use // File | Settings | File // Templates. } }; }
From source file:it.grid.storm.config.ConfigReader.java
/** * Private method that returns an Empty implementation of Apache s * Configuration Object, which does not contain any key, does not * addPropertyDirect, does not clearProperty, returns an empty Iterator for * getKeys, returns a primitive Object for getPropertyDirect, returns true for * isEmpty.//from w w w.j a v a 2s . c o m */ private Configuration makeEmptyConfiguration() { return new AbstractConfiguration() { protected void addPropertyDirect(String key, Object obj) { } public void clearProperty(String key) { } public boolean containsKey(String key) { return false; } public Iterator getKeys() { return new ArrayList().iterator(); } protected Object getPropertyDirect(String key) { return new Object(); } public boolean isEmpty() { return true; } public Object getProperty(String key) { return new Object(); } }; }