Class Properties
- All Implemented Interfaces:
Serializable
,Cloneable
,Configuration
,EventSource
,FileBasedConfiguration
,ImmutableConfiguration
,FileBased
,FileLocatorAware
,SynchronizerSupport
PropertiesConfiguration
providing
setters for primitive types, a simpler way to save preferences
and transparent handling of Enum
lowercased keys.
All accessors defined in PropertiesConfiguration
have a
polymorphic counterpart taking an Enum
instead of a string:
Enum.name()
and String.toLowerCase()
are
applied before delegating to the corresponding string-based method. (This apparently wierd choice
is due to the need to accommodate the upper-case standard for Enum
elements and
the lower-case standard for property keys.)
Additionally, instances of this class can be serialised.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.commons.configuration2.PropertiesConfiguration
PropertiesConfiguration.DefaultIOFactory, PropertiesConfiguration.IOFactory, PropertiesConfiguration.JupIOFactory, PropertiesConfiguration.JupPropertiesReader, PropertiesConfiguration.JupPropertiesWriter, PropertiesConfiguration.PropertiesReader, PropertiesConfiguration.PropertiesWriter
-
Field Summary
Fields inherited from class org.apache.commons.configuration2.PropertiesConfiguration
DEFAULT_ENCODING, DEFAULT_INCLUDE_LISTENER, NOOP_INCLUDE_LISTENER
-
Constructor Summary
ConstructorDescriptionProperties
(File file) Properties
(InputStream inputStream) Properties
(String filename) Properties
(URL url) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAll
(Configuration configuration) Adds all properties from the given configuration.void
addProperties
(Enum<?> key, String[] s) void
addProperties
(String key, String[] s) void
addProperty
(Enum<?> key, boolean b) void
addProperty
(Enum<?> key, byte b) void
addProperty
(Enum<?> key, char c) void
addProperty
(Enum<?> key, double d) void
addProperty
(Enum<?> key, float f) void
addProperty
(Enum<?> key, int i) void
addProperty
(Enum<?> key, long l) void
addProperty
(Enum<?> key, short s) void
addProperty
(Enum<?> key, Object arg) void
addProperty
(String key, boolean b) void
addProperty
(String key, byte b) void
addProperty
(String key, char c) void
addProperty
(String key, double d) void
addProperty
(String key, float f) void
addProperty
(String key, int i) void
addProperty
(String key, long l) void
addProperty
(String key, short s) boolean
containsKey
(Enum<?> key) boolean
Returns true if the provided object is equal to this set of properties.getBigDecimal
(Enum<?> key) getBigDecimal
(Enum<?> key, BigDecimal arg) getBigInteger
(Enum<?> key) getBigInteger
(Enum<?> key, BigInteger arg) boolean
getBoolean
(Enum<?> key) boolean
getBoolean
(Enum<?> key, boolean arg) getBoolean
(Enum<?> key, Boolean arg) byte
byte
double
double
float
float
int
int
getInteger
(Enum<?> key, Integer arg) Iterator<?>
List<?>
long
long
getProperties
(Enum<?> key) getProperties
(Enum<?> key, Properties arg) getProperty
(Enum<?> key) short
short
String[]
getStringArray
(Enum<?> key) int
hashCode()
void
Loads a configuration from a specified file.void
load
(InputStream is) Loads a configuration from an input stream.void
load
(CharSequence filename) Loads a configuration from a specified file.void
Saves the configuration to the specified file.void
save
(OutputStream os) Saves the configuration to an output stream.void
save
(CharSequence filename) Saves the configuration to the specified file.void
setProperty
(Enum<?> key, boolean b) void
setProperty
(Enum<?> key, byte b) void
setProperty
(Enum<?> key, char b) void
setProperty
(Enum<?> key, double d) void
setProperty
(Enum<?> key, float f) void
setProperty
(Enum<?> key, int i) void
setProperty
(Enum<?> key, long l) void
setProperty
(Enum<?> key, short s) void
setProperty
(Enum<?> key, Object arg) void
setProperty
(String key, boolean b) void
setProperty
(String key, byte b) void
setProperty
(String key, char b) void
setProperty
(String key, double d) void
setProperty
(String key, float f) void
setProperty
(String key, int i) void
setProperty
(String key, long l) void
setProperty
(String key, short s) toString()
Methods inherited from class org.apache.commons.configuration2.PropertiesConfiguration
clone, getFooter, getHeader, getInclude, getIncludeListener, getIncludeOptional, getIOFactory, getLayout, initFileLocator, isIncludesAllowed, read, setFooter, setHeader, setInclude, setIncludeListener, setIncludeOptional, setIncludesAllowed, setIOFactory, setLayout, unescapeJava, unescapeJava, write
Methods inherited from class org.apache.commons.configuration2.BaseConfiguration
addPropertyDirect, clearInternal, clearPropertyDirect, containsKeyInternal, getKeysInternal, getPropertyInternal, isEmptyInternal, sizeInternal
Methods inherited from class org.apache.commons.configuration2.AbstractConfiguration
addErrorLogListener, addProperty, addPropertyInternal, append, beginRead, beginWrite, clear, clearProperty, cloneInterpolator, containsKey, copy, endRead, endWrite, get, get, getArray, getArray, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getCollection, getCollection, getConfigurationDecoder, getConversionHandler, getDouble, getDouble, getDouble, getEncodedString, getEncodedString, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getInterpolator, getKeys, getKeys, getKeysInternal, getList, getList, getList, getList, getListDelimiterHandler, getLogger, getLong, getLong, getLong, getProperties, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, getSynchronizer, immutableSubset, initLogger, installInterpolator, interpolate, interpolate, interpolatedConfiguration, isEmpty, isScalarValue, isThrowExceptionOnMissing, lock, setConfigurationDecoder, setConversionHandler, setDefaultLookups, setInterpolator, setListDelimiterHandler, setLogger, setParentInterpolator, setPrefixLookups, setProperty, setPropertyInternal, setSynchronizer, setThrowExceptionOnMissing, size, subset, unlock
Methods inherited from class org.apache.commons.configuration2.event.BaseEventSource
addEventListener, clearErrorListeners, clearEventListeners, copyEventListeners, createErrorEvent, createEvent, fireError, fireEvent, getEventListenerRegistrations, getEventListeners, isDetailEvents, removeEventListener, setDetailEvents
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.commons.configuration2.Configuration
addProperty, clear, clearProperty, getInterpolator, installInterpolator, setInterpolator, setProperty, subset
Methods inherited from interface org.apache.commons.configuration2.ImmutableConfiguration
containsKey, get, get, getArray, getArray, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getCollection, getCollection, getDouble, getDouble, getDouble, getEncodedString, getEncodedString, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getKeys, getKeys, getList, getList, getList, getList, getLong, getLong, getLong, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, immutableSubset, isEmpty, size
Methods inherited from interface org.apache.commons.configuration2.sync.SynchronizerSupport
getSynchronizer, lock, setSynchronizer, unlock
-
Constructor Details
-
Properties
public Properties() -
Properties
- Throws:
ConfigurationException
-
Properties
- Throws:
ConfigurationException
-
Properties
- Throws:
ConfigurationException
-
Properties
- Throws:
ConfigurationException
-
-
Method Details
-
save
Saves the configuration to the specified file.- Parameters:
filename
- a file name.- Throws:
ConfigurationException
IOException
-
save
Saves the configuration to the specified file.- Parameters:
file
- a file.- Throws:
ConfigurationException
IOException
-
save
Saves the configuration to an output stream.- Parameters:
os
- an output stream.- Throws:
ConfigurationException
-
load
Loads a configuration from a specified file.- Parameters:
filename
- a file name.- Throws:
ConfigurationException
IOException
-
load
Loads a configuration from a specified file.- Parameters:
file
- a file.- Throws:
ConfigurationException
IOException
-
load
Loads a configuration from an input stream.- Parameters:
is
- an input stream.- Throws:
ConfigurationException
-
addAll
Adds all properties from the given configuration.Properties from the new configuration will clear properties from the first one.
- Parameters:
configuration
- a configuration.
-
addProperties
-
addProperty
-
setProperty
-
addProperty
-
setProperty
-
addProperty
-
setProperty
-
addProperty
-
setProperty
-
addProperty
-
setProperty
-
addProperty
-
setProperty
-
addProperty
-
setProperty
-
addProperty
-
setProperty
-
addProperties
-
addProperty
-
setProperty
-
addProperty
-
setProperty
-
addProperty
-
setProperty
-
addProperty
-
setProperty
-
addProperty
-
setProperty
-
addProperty
-
setProperty
-
addProperty
-
setProperty
-
addProperty
-
setProperty
-
containsKey
-
getProperty
-
addProperty
-
getBigDecimal
-
getBigDecimal
-
getBigInteger
-
getBigInteger
-
getBoolean
-
getBoolean
-
getBoolean
-
getByte
-
getByte
-
getByte
-
getDouble
-
getDouble
-
getDouble
-
getFloat
-
getFloat
-
getFloat
-
getInt
-
getInt
-
getInteger
-
getKeys
-
getList
-
getList
-
getLong
-
getLong
-
getLong
-
getProperties
-
getProperties
-
getShort
-
getShort
-
getShort
-
getString
-
getString
-
getStringArray
-
setProperty
-
subset
-
toString
-
hashCode
public int hashCode() -
equals
Returns true if the provided object is equal to this set of properties.Equality between set of properties happens when the keys are the same, and the list of strings associated with each key is the same. Note that the order in which different keys appear in a property file is irrelevant, but the order between properties with the same key is significant.
Due to the strictness of the check (e.g., no number conversion is performed) this method is mainly useful when writing tests.
-