Class Properties
- All Implemented Interfaces:
Serializable, Cloneable, org.apache.commons.configuration2.Configuration, org.apache.commons.configuration2.event.EventSource, org.apache.commons.configuration2.FileBasedConfiguration, org.apache.commons.configuration2.ImmutableConfiguration, org.apache.commons.configuration2.io.FileBased, org.apache.commons.configuration2.io.FileLocatorAware, org.apache.commons.configuration2.sync.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
org.apache.commons.configuration2.PropertiesConfiguration.DefaultIOFactory, org.apache.commons.configuration2.PropertiesConfiguration.IOFactory, org.apache.commons.configuration2.PropertiesConfiguration.JupIOFactory, org.apache.commons.configuration2.PropertiesConfiguration.JupPropertiesReader, org.apache.commons.configuration2.PropertiesConfiguration.JupPropertiesWriter, org.apache.commons.configuration2.PropertiesConfiguration.PropertiesReader, org.apache.commons.configuration2.PropertiesConfiguration.PropertiesWriter -
Field Summary
Fields inherited from class org.apache.commons.configuration2.PropertiesConfiguration
DEFAULT_ENCODING, DEFAULT_INCLUDE_LISTENER, NOOP_INCLUDE_LISTENER -
Constructor Summary
ConstructorsConstructorDescriptionProperties(File file) Properties(InputStream inputStream) Properties(String filename) Properties(URL url) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAll(org.apache.commons.configuration2.Configuration configuration) Adds all properties from the given configuration.voidaddProperties(Enum<?> key, String[] s) voidaddProperties(String key, String[] s) voidaddProperty(Enum<?> key, boolean b) voidaddProperty(Enum<?> key, byte b) voidaddProperty(Enum<?> key, char c) voidaddProperty(Enum<?> key, double d) voidaddProperty(Enum<?> key, float f) voidaddProperty(Enum<?> key, int i) voidaddProperty(Enum<?> key, long l) voidaddProperty(Enum<?> key, short s) voidaddProperty(Enum<?> key, Object arg) voidaddProperty(String key, boolean b) voidaddProperty(String key, byte b) voidaddProperty(String key, char c) voidaddProperty(String key, double d) voidaddProperty(String key, float f) voidaddProperty(String key, int i) voidaddProperty(String key, long l) voidaddProperty(String key, short s) booleancontainsKey(Enum<?> key) booleanReturns 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) booleangetBoolean(Enum<?> key) booleangetBoolean(Enum<?> key, boolean arg) getBoolean(Enum<?> key, Boolean arg) bytebytedoubledoublefloatfloatintintgetInteger(Enum<?> key, Integer arg) Iterator<?> List<?> longlonggetProperties(Enum<?> key) getProperties(Enum<?> key, Properties arg) getProperty(Enum<?> key) shortshortString[]getStringArray(Enum<?> key) inthashCode()voidLoads a configuration from a specified file.voidload(InputStream is) Loads a configuration from an input stream.voidload(CharSequence filename) Loads a configuration from a specified file.voidSaves the configuration to the specified file.voidsave(OutputStream os) Saves the configuration to an output stream.voidsave(CharSequence filename) Saves the configuration to the specified file.voidsetProperty(Enum<?> key, boolean b) voidsetProperty(Enum<?> key, byte b) voidsetProperty(Enum<?> key, char b) voidsetProperty(Enum<?> key, double d) voidsetProperty(Enum<?> key, float f) voidsetProperty(Enum<?> key, int i) voidsetProperty(Enum<?> key, long l) voidsetProperty(Enum<?> key, short s) voidsetProperty(Enum<?> key, Object arg) voidsetProperty(String key, boolean b) voidsetProperty(String key, byte b) voidsetProperty(String key, char b) voidsetProperty(String key, double d) voidsetProperty(String key, float f) voidsetProperty(String key, int i) voidsetProperty(String key, long l) voidsetProperty(String key, short s) org.apache.commons.configuration2.ConfigurationtoString()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, writeMethods inherited from class org.apache.commons.configuration2.BaseConfiguration
addPropertyDirect, clearInternal, clearPropertyDirect, containsKeyInternal, getKeysInternal, getPropertyInternal, isEmptyInternal, sizeInternalMethods 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, getDuration, getDuration, getEncodedString, getEncodedString, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getInterpolator, getKeys, getKeys, getKeys, getKeysInternal, 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, unlockMethods inherited from class org.apache.commons.configuration2.event.BaseEventSource
addEventListener, clearErrorListeners, clearEventListeners, copyEventListeners, createErrorEvent, createEvent, fireError, fireEvent, getEventListenerRegistrations, getEventListeners, isDetailEvents, removeEventListener, setDetailEventsMethods inherited from interface org.apache.commons.configuration2.Configuration
addProperty, clear, clearProperty, getInterpolator, installInterpolator, setInterpolator, setProperty, subsetMethods 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, getDuration, getDuration, getEncodedString, getEncodedString, getEnum, getEnum, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getKeys, getKeys, getKeys, getList, getList, getList, getList, getLong, getLong, getLong, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, immutableSubset, isEmpty, sizeMethods inherited from interface org.apache.commons.configuration2.sync.SynchronizerSupport
getSynchronizer, lock, setSynchronizer, unlock
-
Constructor Details
-
Properties
public Properties() -
Properties
public Properties(String filename) throws org.apache.commons.configuration2.ex.ConfigurationException - Throws:
org.apache.commons.configuration2.ex.ConfigurationException
-
Properties
- Throws:
org.apache.commons.configuration2.ex.ConfigurationException
-
Properties
- Throws:
org.apache.commons.configuration2.ex.ConfigurationException
-
Properties
public Properties(InputStream inputStream) throws org.apache.commons.configuration2.ex.ConfigurationException - Throws:
org.apache.commons.configuration2.ex.ConfigurationException
-
-
Method Details
-
save
public void save(CharSequence filename) throws org.apache.commons.configuration2.ex.ConfigurationException, IOException Saves the configuration to the specified file.- Parameters:
filename- a file name.- Throws:
org.apache.commons.configuration2.ex.ConfigurationExceptionIOException
-
save
public void save(File file) throws org.apache.commons.configuration2.ex.ConfigurationException, IOException Saves the configuration to the specified file.- Parameters:
file- a file.- Throws:
org.apache.commons.configuration2.ex.ConfigurationExceptionIOException
-
save
public void save(OutputStream os) throws org.apache.commons.configuration2.ex.ConfigurationException Saves the configuration to an output stream.- Parameters:
os- an output stream.- Throws:
org.apache.commons.configuration2.ex.ConfigurationException
-
load
public void load(CharSequence filename) throws org.apache.commons.configuration2.ex.ConfigurationException, IOException Loads a configuration from a specified file.- Parameters:
filename- a file name.- Throws:
org.apache.commons.configuration2.ex.ConfigurationExceptionIOException
-
load
public void load(File file) throws org.apache.commons.configuration2.ex.ConfigurationException, IOException Loads a configuration from a specified file.- Parameters:
file- a file.- Throws:
org.apache.commons.configuration2.ex.ConfigurationExceptionIOException
-
load
Loads a configuration from an input stream.- Parameters:
is- an input stream.- Throws:
org.apache.commons.configuration2.ex.ConfigurationException
-
addAll
public void addAll(org.apache.commons.configuration2.Configuration configuration) 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
-
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.
-