public class EnvironmentConfiguration extends MapConfiguration
A Configuration implementation that reads the platform specific
environment variables using the map returned by System.getenv()
.
This configuration implementation is read-only. It allows read access to the
defined OS environment variables, but their values cannot be changed. Any
attempts to add or remove a property will throw an
UnsupportedOperationException
Usage of this class is easy: After an instance has been created the get
methods provided by the Configuration
interface can be used
for querying environment variables, e.g.:
Configuration envConfig = new EnvironmentConfiguration(); System.out.println("JAVA_HOME=" + envConfig.getString("JAVA_HOME");
map
END_TOKEN, EVENT_ADD_PROPERTY, EVENT_CLEAR, EVENT_CLEAR_PROPERTY, EVENT_READ_PROPERTY, EVENT_SET_PROPERTY, START_TOKEN
Constructor and Description |
---|
EnvironmentConfiguration()
Create a Configuration based on the environment variables.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addPropertyDirect(String key,
Object value)
Adds a property to this configuration.
|
void |
clear()
Removes all properties from this configuration.
|
void |
clearProperty(String key)
Removes a property from this configuration.
|
clearPropertyDirect, clone, containsKey, getKeys, getMap, getProperty, isEmpty, isTrimmingDisabled, setTrimmingDisabled
addErrorLogListener, addProperty, append, copy, createInterpolator, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDefaultListDelimiter, getDelimiter, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getInterpolator, getKeys, getList, getList, getListDelimiter, getLogger, getLong, getLong, getLong, getProperties, getProperties, getShort, getShort, getShort, getString, getString, getStringArray, getSubstitutor, interpolate, interpolate, interpolatedConfiguration, interpolateHelper, isDelimiterParsingDisabled, isScalarValue, isThrowExceptionOnMissing, resolveContainerStore, setDefaultListDelimiter, setDelimiter, setDelimiterParsingDisabled, setListDelimiter, setLogger, setProperty, setThrowExceptionOnMissing, subset
addConfigurationListener, addErrorListener, clearConfigurationListeners, clearErrorListeners, createErrorEvent, createEvent, fireError, fireEvent, getConfigurationListeners, getErrorListeners, isDetailEvents, removeConfigurationListener, removeErrorListener, setDetailEvents
public EnvironmentConfiguration()
System.getenv()
protected void addPropertyDirect(String key, Object value)
addPropertyDirect
in class MapConfiguration
key
- the key of the property to be addedvalue
- the property valuepublic void clearProperty(String key)
clearProperty
in interface Configuration
clearProperty
in class AbstractConfiguration
key
- the key of the property to be removedpublic void clear()
clear
in interface Configuration
clear
in class AbstractConfiguration
Copyright © 2001–2013 The Apache Software Foundation. All rights reserved.