Class Properties
- java.lang.Object
-
- org.apache.commons.configuration2.event.BaseEventSource
-
- org.apache.commons.configuration2.AbstractConfiguration
-
- org.apache.commons.configuration2.BaseConfiguration
-
- org.apache.commons.configuration2.PropertiesConfiguration
-
- it.unimi.dsi.util.Properties
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.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
public class Properties extends org.apache.commons.configuration2.PropertiesConfiguration implements java.io.SerializableAn 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.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
-
-
Constructor Summary
Constructors Constructor Description Properties()Properties(java.io.File file)Properties(java.io.InputStream inputStream)Properties(java.lang.String filename)Properties(java.net.URL url)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAll(org.apache.commons.configuration2.Configuration configuration)Adds all properties from the given configuration.voidaddProperties(java.lang.Enum<?> key, java.lang.String[] s)voidaddProperties(java.lang.String key, java.lang.String[] s)voidaddProperty(java.lang.Enum<?> key, boolean b)voidaddProperty(java.lang.Enum<?> key, byte b)voidaddProperty(java.lang.Enum<?> key, char c)voidaddProperty(java.lang.Enum<?> key, double d)voidaddProperty(java.lang.Enum<?> key, float f)voidaddProperty(java.lang.Enum<?> key, int i)voidaddProperty(java.lang.Enum<?> key, long l)voidaddProperty(java.lang.Enum<?> key, short s)voidaddProperty(java.lang.Enum<?> key, java.lang.Object arg)voidaddProperty(java.lang.String key, boolean b)voidaddProperty(java.lang.String key, byte b)voidaddProperty(java.lang.String key, char c)voidaddProperty(java.lang.String key, double d)voidaddProperty(java.lang.String key, float f)voidaddProperty(java.lang.String key, int i)voidaddProperty(java.lang.String key, long l)voidaddProperty(java.lang.String key, short s)booleancontainsKey(java.lang.Enum<?> key)booleanequals(java.lang.Object o)Returns true if the provided object is equal to this set of properties.java.math.BigDecimalgetBigDecimal(java.lang.Enum<?> key)java.math.BigDecimalgetBigDecimal(java.lang.Enum<?> key, java.math.BigDecimal arg)java.math.BigIntegergetBigInteger(java.lang.Enum<?> key)java.math.BigIntegergetBigInteger(java.lang.Enum<?> key, java.math.BigInteger arg)booleangetBoolean(java.lang.Enum<?> key)booleangetBoolean(java.lang.Enum<?> key, boolean arg)java.lang.BooleangetBoolean(java.lang.Enum<?> key, java.lang.Boolean arg)bytegetByte(java.lang.Enum<?> key)bytegetByte(java.lang.Enum<?> key, byte arg)java.lang.BytegetByte(java.lang.Enum<?> key, java.lang.Byte arg)doublegetDouble(java.lang.Enum<?> key)doublegetDouble(java.lang.Enum<?> key, double arg)java.lang.DoublegetDouble(java.lang.Enum<?> key, java.lang.Double arg)floatgetFloat(java.lang.Enum<?> key)floatgetFloat(java.lang.Enum<?> key, float arg)java.lang.FloatgetFloat(java.lang.Enum<?> key, java.lang.Float arg)intgetInt(java.lang.Enum<?> key)intgetInt(java.lang.Enum<?> key, int arg)java.lang.IntegergetInteger(java.lang.Enum<?> key, java.lang.Integer arg)java.util.Iterator<?>getKeys(java.lang.Enum<?> key)java.util.List<?>getList(java.lang.Enum<?> key)java.util.List<java.lang.Object>getList(java.lang.Enum<?> key, java.util.List<java.lang.Object> arg)longgetLong(java.lang.Enum<?> key)longgetLong(java.lang.Enum<?> key, long arg)java.lang.LonggetLong(java.lang.Enum<?> key, java.lang.Long arg)java.util.PropertiesgetProperties(java.lang.Enum<?> key)java.util.PropertiesgetProperties(java.lang.Enum<?> key, java.util.Properties arg)java.lang.ObjectgetProperty(java.lang.Enum<?> key)shortgetShort(java.lang.Enum<?> key)shortgetShort(java.lang.Enum<?> key, short arg)java.lang.ShortgetShort(java.lang.Enum<?> key, java.lang.Short arg)java.lang.StringgetString(java.lang.Enum<?> key)java.lang.StringgetString(java.lang.Enum<?> key, java.lang.String arg)java.lang.String[]getStringArray(java.lang.Enum<?> key)inthashCode()voidload(java.io.File file)Loads a configuration from a specified file.voidload(java.io.InputStream is)Loads a configuration from an input stream.voidload(java.lang.CharSequence filename)Loads a configuration from a specified file.voidsave(java.io.File file)Saves the configuration to the specified file.voidsave(java.io.OutputStream os)Saves the configuration to an output stream.voidsave(java.lang.CharSequence filename)Saves the configuration to the specified file.voidsetProperty(java.lang.Enum<?> key, boolean b)voidsetProperty(java.lang.Enum<?> key, byte b)voidsetProperty(java.lang.Enum<?> key, char b)voidsetProperty(java.lang.Enum<?> key, double d)voidsetProperty(java.lang.Enum<?> key, float f)voidsetProperty(java.lang.Enum<?> key, int i)voidsetProperty(java.lang.Enum<?> key, long l)voidsetProperty(java.lang.Enum<?> key, short s)voidsetProperty(java.lang.Enum<?> key, java.lang.Object arg)voidsetProperty(java.lang.String key, boolean b)voidsetProperty(java.lang.String key, byte b)voidsetProperty(java.lang.String key, char b)voidsetProperty(java.lang.String key, double d)voidsetProperty(java.lang.String key, float f)voidsetProperty(java.lang.String key, int i)voidsetProperty(java.lang.String key, long l)voidsetProperty(java.lang.String key, short s)org.apache.commons.configuration2.Configurationsubset(java.lang.Enum<?> key)java.lang.StringtoString()-
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, 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, 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, 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, size
-
-
-
-
Constructor Detail
-
Properties
public Properties()
-
Properties
public Properties(java.lang.String filename) throws org.apache.commons.configuration2.ex.ConfigurationException- Throws:
org.apache.commons.configuration2.ex.ConfigurationException
-
Properties
public Properties(java.io.File file) throws org.apache.commons.configuration2.ex.ConfigurationException- Throws:
org.apache.commons.configuration2.ex.ConfigurationException
-
Properties
public Properties(java.net.URL url) throws org.apache.commons.configuration2.ex.ConfigurationException- Throws:
org.apache.commons.configuration2.ex.ConfigurationException
-
Properties
public Properties(java.io.InputStream inputStream) throws org.apache.commons.configuration2.ex.ConfigurationException- Throws:
org.apache.commons.configuration2.ex.ConfigurationException
-
-
Method Detail
-
save
public void save(java.lang.CharSequence filename) throws org.apache.commons.configuration2.ex.ConfigurationException, java.io.IOExceptionSaves the configuration to the specified file.- Parameters:
filename- a file name.- Throws:
org.apache.commons.configuration2.ex.ConfigurationExceptionjava.io.IOException
-
save
public void save(java.io.File file) throws org.apache.commons.configuration2.ex.ConfigurationException, java.io.IOExceptionSaves the configuration to the specified file.- Parameters:
file- a file.- Throws:
org.apache.commons.configuration2.ex.ConfigurationExceptionjava.io.IOException
-
save
public void save(java.io.OutputStream os) throws org.apache.commons.configuration2.ex.ConfigurationExceptionSaves the configuration to an output stream.- Parameters:
os- an output stream.- Throws:
org.apache.commons.configuration2.ex.ConfigurationException
-
load
public void load(java.lang.CharSequence filename) throws org.apache.commons.configuration2.ex.ConfigurationException, java.io.IOExceptionLoads a configuration from a specified file.- Parameters:
filename- a file name.- Throws:
org.apache.commons.configuration2.ex.ConfigurationExceptionjava.io.IOException
-
load
public void load(java.io.File file) throws org.apache.commons.configuration2.ex.ConfigurationException, java.io.IOExceptionLoads a configuration from a specified file.- Parameters:
file- a file.- Throws:
org.apache.commons.configuration2.ex.ConfigurationExceptionjava.io.IOException
-
load
public void load(java.io.InputStream is) throws org.apache.commons.configuration2.ex.ConfigurationExceptionLoads 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
public void addProperties(java.lang.String key, java.lang.String[] s)
-
addProperty
public void addProperty(java.lang.String key, boolean b)
-
setProperty
public void setProperty(java.lang.String key, boolean b)
-
addProperty
public void addProperty(java.lang.String key, byte b)
-
setProperty
public void setProperty(java.lang.String key, byte b)
-
addProperty
public void addProperty(java.lang.String key, short s)
-
setProperty
public void setProperty(java.lang.String key, short s)
-
addProperty
public void addProperty(java.lang.String key, char c)
-
setProperty
public void setProperty(java.lang.String key, char b)
-
addProperty
public void addProperty(java.lang.String key, int i)
-
setProperty
public void setProperty(java.lang.String key, int i)
-
addProperty
public void addProperty(java.lang.String key, long l)
-
setProperty
public void setProperty(java.lang.String key, long l)
-
addProperty
public void addProperty(java.lang.String key, float f)
-
setProperty
public void setProperty(java.lang.String key, float f)
-
addProperty
public void addProperty(java.lang.String key, double d)
-
setProperty
public void setProperty(java.lang.String key, double d)
-
addProperties
public void addProperties(java.lang.Enum<?> key, java.lang.String[] s)
-
addProperty
public void addProperty(java.lang.Enum<?> key, boolean b)
-
setProperty
public void setProperty(java.lang.Enum<?> key, boolean b)
-
addProperty
public void addProperty(java.lang.Enum<?> key, byte b)
-
setProperty
public void setProperty(java.lang.Enum<?> key, byte b)
-
addProperty
public void addProperty(java.lang.Enum<?> key, short s)
-
setProperty
public void setProperty(java.lang.Enum<?> key, short s)
-
addProperty
public void addProperty(java.lang.Enum<?> key, char c)
-
setProperty
public void setProperty(java.lang.Enum<?> key, char b)
-
addProperty
public void addProperty(java.lang.Enum<?> key, int i)
-
setProperty
public void setProperty(java.lang.Enum<?> key, int i)
-
addProperty
public void addProperty(java.lang.Enum<?> key, long l)
-
setProperty
public void setProperty(java.lang.Enum<?> key, long l)
-
addProperty
public void addProperty(java.lang.Enum<?> key, float f)
-
setProperty
public void setProperty(java.lang.Enum<?> key, float f)
-
addProperty
public void addProperty(java.lang.Enum<?> key, double d)
-
setProperty
public void setProperty(java.lang.Enum<?> key, double d)
-
containsKey
public boolean containsKey(java.lang.Enum<?> key)
-
getProperty
public java.lang.Object getProperty(java.lang.Enum<?> key)
-
addProperty
public void addProperty(java.lang.Enum<?> key, java.lang.Object arg)
-
getBigDecimal
public java.math.BigDecimal getBigDecimal(java.lang.Enum<?> key, java.math.BigDecimal arg)
-
getBigDecimal
public java.math.BigDecimal getBigDecimal(java.lang.Enum<?> key)
-
getBigInteger
public java.math.BigInteger getBigInteger(java.lang.Enum<?> key, java.math.BigInteger arg)
-
getBigInteger
public java.math.BigInteger getBigInteger(java.lang.Enum<?> key)
-
getBoolean
public boolean getBoolean(java.lang.Enum<?> key, boolean arg)
-
getBoolean
public java.lang.Boolean getBoolean(java.lang.Enum<?> key, java.lang.Boolean arg)
-
getBoolean
public boolean getBoolean(java.lang.Enum<?> key)
-
getByte
public byte getByte(java.lang.Enum<?> key, byte arg)
-
getByte
public java.lang.Byte getByte(java.lang.Enum<?> key, java.lang.Byte arg)
-
getByte
public byte getByte(java.lang.Enum<?> key)
-
getDouble
public double getDouble(java.lang.Enum<?> key, double arg)
-
getDouble
public java.lang.Double getDouble(java.lang.Enum<?> key, java.lang.Double arg)
-
getDouble
public double getDouble(java.lang.Enum<?> key)
-
getFloat
public float getFloat(java.lang.Enum<?> key, float arg)
-
getFloat
public java.lang.Float getFloat(java.lang.Enum<?> key, java.lang.Float arg)
-
getFloat
public float getFloat(java.lang.Enum<?> key)
-
getInt
public int getInt(java.lang.Enum<?> key, int arg)
-
getInt
public int getInt(java.lang.Enum<?> key)
-
getInteger
public java.lang.Integer getInteger(java.lang.Enum<?> key, java.lang.Integer arg)
-
getKeys
public java.util.Iterator<?> getKeys(java.lang.Enum<?> key)
-
getList
public java.util.List<java.lang.Object> getList(java.lang.Enum<?> key, java.util.List<java.lang.Object> arg)
-
getList
public java.util.List<?> getList(java.lang.Enum<?> key)
-
getLong
public long getLong(java.lang.Enum<?> key, long arg)
-
getLong
public java.lang.Long getLong(java.lang.Enum<?> key, java.lang.Long arg)
-
getLong
public long getLong(java.lang.Enum<?> key)
-
getProperties
public java.util.Properties getProperties(java.lang.Enum<?> key, java.util.Properties arg)
-
getProperties
public java.util.Properties getProperties(java.lang.Enum<?> key)
-
getShort
public short getShort(java.lang.Enum<?> key, short arg)
-
getShort
public java.lang.Short getShort(java.lang.Enum<?> key, java.lang.Short arg)
-
getShort
public short getShort(java.lang.Enum<?> key)
-
getString
public java.lang.String getString(java.lang.Enum<?> key, java.lang.String arg)
-
getString
public java.lang.String getString(java.lang.Enum<?> key)
-
getStringArray
public java.lang.String[] getStringArray(java.lang.Enum<?> key)
-
setProperty
public void setProperty(java.lang.Enum<?> key, java.lang.Object arg)
-
subset
public org.apache.commons.configuration2.Configuration subset(java.lang.Enum<?> key)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.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.
- Overrides:
equalsin classjava.lang.Object- Returns:
- true if the argument is equal to this set of properties.
-
-