Class Properties
- All Implemented Interfaces:
Serializable
,Cloneable
,Configuration
,FileConfiguration
,FileSystemBased
public class Properties extends PropertiesConfiguration implements Serializable
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:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.commons.configuration.PropertiesConfiguration
PropertiesConfiguration.DefaultIOFactory, PropertiesConfiguration.IOFactory, PropertiesConfiguration.PropertiesReader, PropertiesConfiguration.PropertiesWriter
-
Field Summary
Fields inherited from class org.apache.commons.configuration.AbstractFileConfiguration
autoSave, basePath, EVENT_CONFIG_CHANGED, EVENT_RELOAD, fileName, reloadLock, strategy
Fields inherited from class org.apache.commons.configuration.AbstractConfiguration
END_TOKEN, EVENT_ADD_PROPERTY, EVENT_CLEAR, EVENT_CLEAR_PROPERTY, EVENT_READ_PROPERTY, EVENT_SET_PROPERTY, START_TOKEN
-
Constructor Summary
Constructors Constructor Description Properties()
Properties(File file)
Properties(String filename)
Properties(URL url)
-
Method Summary
Modifier and Type Method Description void
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
equals(Object o)
Returns true if the provided object is equal to this set of properties.BigDecimal
getBigDecimal(Enum<?> key)
BigDecimal
getBigDecimal(Enum<?> key, BigDecimal arg)
BigInteger
getBigInteger(Enum<?> key)
BigInteger
getBigInteger(Enum<?> key, BigInteger arg)
boolean
getBoolean(Enum<?> key)
boolean
getBoolean(Enum<?> key, boolean arg)
Boolean
getBoolean(Enum<?> key, Boolean arg)
byte
getByte(Enum<?> key)
byte
getByte(Enum<?> key, byte arg)
Byte
getByte(Enum<?> key, Byte arg)
double
getDouble(Enum<?> key)
double
getDouble(Enum<?> key, double arg)
Double
getDouble(Enum<?> key, Double arg)
float
getFloat(Enum<?> key)
float
getFloat(Enum<?> key, float arg)
Float
getFloat(Enum<?> key, Float arg)
int
getInt(Enum<?> key)
int
getInt(Enum<?> key, int arg)
Integer
getInteger(Enum<?> key, Integer arg)
Iterator<?>
getKeys(Enum<?> key)
List<?>
getList(Enum<?> key)
List<Object>
getList(Enum<?> key, List<Object> arg)
long
getLong(Enum<?> key)
long
getLong(Enum<?> key, long arg)
Long
getLong(Enum<?> key, Long arg)
Properties
getProperties(Enum<?> key)
Properties
getProperties(Enum<?> key, Properties arg)
Object
getProperty(Enum<?> key)
short
getShort(Enum<?> key)
short
getShort(Enum<?> key, short arg)
Short
getShort(Enum<?> key, Short arg)
String
getString(Enum<?> key)
String
getString(Enum<?> key, String arg)
String[]
getStringArray(Enum<?> key)
int
hashCode()
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)
Configuration
subset(Enum<?> key)
String
toString()
Methods inherited from class org.apache.commons.configuration.PropertiesConfiguration
clone, createLayout, getEncoding, getFooter, getHeader, getInclude, getIncludesAllowed, getIOFactory, getLayout, isIncludesAllowed, load, save, setBasePath, setFooter, setHeader, setInclude, setIncludesAllowed, setIOFactory, setLayout, unescapeJava
Methods inherited from class org.apache.commons.configuration.AbstractFileConfiguration
addProperty, clearProperty, closeSilent, configurationChanged, containsKey, enterNoReload, exitNoReload, fireEvent, getBasePath, getFile, getFileName, getFileSystem, getKeys, getPath, getProperty, getReloadingStrategy, getReloadLock, getURL, isAutoSave, isEmpty, load, load, load, load, load, load, possiblySave, refresh, reload, reload, resetFileSystem, save, save, save, save, save, save, setAutoSave, setEncoding, setFile, setFileName, setFileSystem, setPath, setProperty, setReloadingStrategy, setURL
Methods inherited from class org.apache.commons.configuration.BaseConfiguration
addPropertyDirect, clear, clearPropertyDirect
Methods inherited from class org.apache.commons.configuration.AbstractConfiguration
addErrorLogListener, 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, setThrowExceptionOnMissing, subset
Methods inherited from class org.apache.commons.configuration.event.EventSource
addConfigurationListener, addErrorListener, clearConfigurationListeners, clearErrorListeners, createErrorEvent, createEvent, fireError, getConfigurationListeners, getErrorListeners, isDetailEvents, removeConfigurationListener, removeErrorListener, setDetailEvents
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.commons.configuration.Configuration
clear, 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, getShort, getShort, getShort, getString, getString, getStringArray, subset
-
Constructor Details
-
Properties
public Properties() -
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
-
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.
-