Class Properties
-
- All Implemented Interfaces:
Serializable,Cloneable,Configuration,FileConfiguration,FileSystemBased
public class Properties extends PropertiesConfiguration implements Serializable
An extension ofPropertiesConfigurationproviding setters for primitive types, a simpler way to save preferences and transparent handling ofEnumlowercased keys.All accessors defined in
PropertiesConfigurationhave a polymorphic counterpart taking anEnuminstead of a string:Enum.name()andString.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 forEnumelements 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 voidaddAll(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)booleanequals(Object o)Returns true if the provided object is equal to this set of properties.BigDecimalgetBigDecimal(Enum<?> key)BigDecimalgetBigDecimal(Enum<?> key, BigDecimal arg)BigIntegergetBigInteger(Enum<?> key)BigIntegergetBigInteger(Enum<?> key, BigInteger arg)booleangetBoolean(Enum<?> key)booleangetBoolean(Enum<?> key, boolean arg)BooleangetBoolean(Enum<?> key, Boolean arg)bytegetByte(Enum<?> key)bytegetByte(Enum<?> key, byte arg)BytegetByte(Enum<?> key, Byte arg)doublegetDouble(Enum<?> key)doublegetDouble(Enum<?> key, double arg)DoublegetDouble(Enum<?> key, Double arg)floatgetFloat(Enum<?> key)floatgetFloat(Enum<?> key, float arg)FloatgetFloat(Enum<?> key, Float arg)intgetInt(Enum<?> key)intgetInt(Enum<?> key, int arg)IntegergetInteger(Enum<?> key, Integer arg)Iterator<?>getKeys(Enum<?> key)List<?>getList(Enum<?> key)List<Object>getList(Enum<?> key, List<Object> arg)longgetLong(Enum<?> key)longgetLong(Enum<?> key, long arg)LonggetLong(Enum<?> key, Long arg)PropertiesgetProperties(Enum<?> key)PropertiesgetProperties(Enum<?> key, Properties arg)ObjectgetProperty(Enum<?> key)shortgetShort(Enum<?> key)shortgetShort(Enum<?> key, short arg)ShortgetShort(Enum<?> key, Short arg)StringgetString(Enum<?> key)StringgetString(Enum<?> key, String arg)String[]getStringArray(Enum<?> key)inthashCode()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)Configurationsubset(Enum<?> key)StringtoString()-
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 Detail
-
Properties
public Properties()
-
Properties
public Properties(String filename) throws ConfigurationException
- Throws:
ConfigurationException
-
Properties
public Properties(File file) throws ConfigurationException
- Throws:
ConfigurationException
-
Properties
public Properties(URL url) throws ConfigurationException
- Throws:
ConfigurationException
-
-
Method Detail
-
save
public void save(CharSequence filename) throws ConfigurationException, IOException
Saves the configuration to the specified file.- Parameters:
filename- a file name.- Throws:
ConfigurationExceptionIOException
-
addAll
public void addAll(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.
-
addProperty
public void addProperty(String key, boolean b)
-
setProperty
public void setProperty(String key, boolean b)
-
addProperty
public void addProperty(String key, byte b)
-
setProperty
public void setProperty(String key, byte b)
-
addProperty
public void addProperty(String key, short s)
-
setProperty
public void setProperty(String key, short s)
-
addProperty
public void addProperty(String key, char c)
-
setProperty
public void setProperty(String key, char b)
-
addProperty
public void addProperty(String key, int i)
-
setProperty
public void setProperty(String key, int i)
-
addProperty
public void addProperty(String key, long l)
-
setProperty
public void setProperty(String key, long l)
-
addProperty
public void addProperty(String key, float f)
-
setProperty
public void setProperty(String key, float f)
-
addProperty
public void addProperty(String key, double d)
-
setProperty
public void setProperty(String key, double d)
-
addProperty
public void addProperty(Enum<?> key, boolean b)
-
setProperty
public void setProperty(Enum<?> key, boolean b)
-
addProperty
public void addProperty(Enum<?> key, byte b)
-
setProperty
public void setProperty(Enum<?> key, byte b)
-
addProperty
public void addProperty(Enum<?> key, short s)
-
setProperty
public void setProperty(Enum<?> key, short s)
-
addProperty
public void addProperty(Enum<?> key, char c)
-
setProperty
public void setProperty(Enum<?> key, char b)
-
addProperty
public void addProperty(Enum<?> key, int i)
-
setProperty
public void setProperty(Enum<?> key, int i)
-
addProperty
public void addProperty(Enum<?> key, long l)
-
setProperty
public void setProperty(Enum<?> key, long l)
-
addProperty
public void addProperty(Enum<?> key, float f)
-
setProperty
public void setProperty(Enum<?> key, float f)
-
addProperty
public void addProperty(Enum<?> key, double d)
-
setProperty
public void setProperty(Enum<?> key, double d)
-
containsKey
public boolean containsKey(Enum<?> key)
-
getBigDecimal
public BigDecimal getBigDecimal(Enum<?> key, BigDecimal arg)
-
getBigDecimal
public BigDecimal getBigDecimal(Enum<?> key)
-
getBigInteger
public BigInteger getBigInteger(Enum<?> key, BigInteger arg)
-
getBigInteger
public BigInteger getBigInteger(Enum<?> key)
-
getBoolean
public boolean getBoolean(Enum<?> key, boolean arg)
-
getBoolean
public boolean getBoolean(Enum<?> key)
-
getByte
public byte getByte(Enum<?> key, byte arg)
-
getByte
public byte getByte(Enum<?> key)
-
getDouble
public double getDouble(Enum<?> key, double arg)
-
getDouble
public double getDouble(Enum<?> key)
-
getFloat
public float getFloat(Enum<?> key, float arg)
-
getFloat
public float getFloat(Enum<?> key)
-
getInt
public int getInt(Enum<?> key, int arg)
-
getInt
public int getInt(Enum<?> key)
-
getLong
public long getLong(Enum<?> key, long arg)
-
getLong
public long getLong(Enum<?> key)
-
getProperties
public Properties getProperties(Enum<?> key, Properties arg)
-
getProperties
public Properties getProperties(Enum<?> key)
-
getShort
public short getShort(Enum<?> key, short arg)
-
getShort
public short getShort(Enum<?> key)
-
subset
public Configuration subset(Enum<?> key)
-
equals
public boolean equals(Object o)
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.
-
-