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.Serializable
An extension ofPropertiesConfiguration
providing setters for primitive types, a simpler way to save preferences and transparent handling ofEnum
lowercased keys.All accessors defined in
PropertiesConfiguration
have a polymorphic counterpart taking anEnum
instead 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 forEnum
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.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 void
addAll(org.apache.commons.configuration2.Configuration configuration)
Adds all properties from the given configuration.void
addProperties(java.lang.Enum<?> key, java.lang.String[] s)
void
addProperties(java.lang.String key, java.lang.String[] s)
void
addProperty(java.lang.Enum<?> key, boolean b)
void
addProperty(java.lang.Enum<?> key, byte b)
void
addProperty(java.lang.Enum<?> key, char c)
void
addProperty(java.lang.Enum<?> key, double d)
void
addProperty(java.lang.Enum<?> key, float f)
void
addProperty(java.lang.Enum<?> key, int i)
void
addProperty(java.lang.Enum<?> key, long l)
void
addProperty(java.lang.Enum<?> key, short s)
void
addProperty(java.lang.Enum<?> key, java.lang.Object arg)
void
addProperty(java.lang.String key, boolean b)
void
addProperty(java.lang.String key, byte b)
void
addProperty(java.lang.String key, char c)
void
addProperty(java.lang.String key, double d)
void
addProperty(java.lang.String key, float f)
void
addProperty(java.lang.String key, int i)
void
addProperty(java.lang.String key, long l)
void
addProperty(java.lang.String key, short s)
boolean
containsKey(java.lang.Enum<?> key)
boolean
equals(java.lang.Object o)
Returns true if the provided object is equal to this set of properties.java.math.BigDecimal
getBigDecimal(java.lang.Enum<?> key)
java.math.BigDecimal
getBigDecimal(java.lang.Enum<?> key, java.math.BigDecimal arg)
java.math.BigInteger
getBigInteger(java.lang.Enum<?> key)
java.math.BigInteger
getBigInteger(java.lang.Enum<?> key, java.math.BigInteger arg)
boolean
getBoolean(java.lang.Enum<?> key)
boolean
getBoolean(java.lang.Enum<?> key, boolean arg)
java.lang.Boolean
getBoolean(java.lang.Enum<?> key, java.lang.Boolean arg)
byte
getByte(java.lang.Enum<?> key)
byte
getByte(java.lang.Enum<?> key, byte arg)
java.lang.Byte
getByte(java.lang.Enum<?> key, java.lang.Byte arg)
double
getDouble(java.lang.Enum<?> key)
double
getDouble(java.lang.Enum<?> key, double arg)
java.lang.Double
getDouble(java.lang.Enum<?> key, java.lang.Double arg)
float
getFloat(java.lang.Enum<?> key)
float
getFloat(java.lang.Enum<?> key, float arg)
java.lang.Float
getFloat(java.lang.Enum<?> key, java.lang.Float arg)
int
getInt(java.lang.Enum<?> key)
int
getInt(java.lang.Enum<?> key, int arg)
java.lang.Integer
getInteger(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)
long
getLong(java.lang.Enum<?> key)
long
getLong(java.lang.Enum<?> key, long arg)
java.lang.Long
getLong(java.lang.Enum<?> key, java.lang.Long arg)
java.util.Properties
getProperties(java.lang.Enum<?> key)
java.util.Properties
getProperties(java.lang.Enum<?> key, java.util.Properties arg)
java.lang.Object
getProperty(java.lang.Enum<?> key)
short
getShort(java.lang.Enum<?> key)
short
getShort(java.lang.Enum<?> key, short arg)
java.lang.Short
getShort(java.lang.Enum<?> key, java.lang.Short arg)
java.lang.String
getString(java.lang.Enum<?> key)
java.lang.String
getString(java.lang.Enum<?> key, java.lang.String arg)
java.lang.String[]
getStringArray(java.lang.Enum<?> key)
int
hashCode()
void
load(java.io.File file)
Loads a configuration from a specified file.void
load(java.io.InputStream is)
Loads a configuration from an input stream.void
load(java.lang.CharSequence filename)
Loads a configuration from a specified file.void
save(java.io.File file)
Saves the configuration to the specified file.void
save(java.io.OutputStream os)
Saves the configuration to an output stream.void
save(java.lang.CharSequence filename)
Saves the configuration to the specified file.void
setProperty(java.lang.Enum<?> key, boolean b)
void
setProperty(java.lang.Enum<?> key, byte b)
void
setProperty(java.lang.Enum<?> key, char b)
void
setProperty(java.lang.Enum<?> key, double d)
void
setProperty(java.lang.Enum<?> key, float f)
void
setProperty(java.lang.Enum<?> key, int i)
void
setProperty(java.lang.Enum<?> key, long l)
void
setProperty(java.lang.Enum<?> key, short s)
void
setProperty(java.lang.Enum<?> key, java.lang.Object arg)
void
setProperty(java.lang.String key, boolean b)
void
setProperty(java.lang.String key, byte b)
void
setProperty(java.lang.String key, char b)
void
setProperty(java.lang.String key, double d)
void
setProperty(java.lang.String key, float f)
void
setProperty(java.lang.String key, int i)
void
setProperty(java.lang.String key, long l)
void
setProperty(java.lang.String key, short s)
org.apache.commons.configuration2.Configuration
subset(java.lang.Enum<?> key)
java.lang.String
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, 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.IOException
Saves the configuration to the specified file.- Parameters:
filename
- a file name.- Throws:
org.apache.commons.configuration2.ex.ConfigurationException
java.io.IOException
-
save
public void save(java.io.File file) throws org.apache.commons.configuration2.ex.ConfigurationException, java.io.IOException
Saves the configuration to the specified file.- Parameters:
file
- a file.- Throws:
org.apache.commons.configuration2.ex.ConfigurationException
java.io.IOException
-
save
public void save(java.io.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(java.lang.CharSequence filename) throws org.apache.commons.configuration2.ex.ConfigurationException, java.io.IOException
Loads a configuration from a specified file.- Parameters:
filename
- a file name.- Throws:
org.apache.commons.configuration2.ex.ConfigurationException
java.io.IOException
-
load
public void load(java.io.File file) throws org.apache.commons.configuration2.ex.ConfigurationException, java.io.IOException
Loads a configuration from a specified file.- Parameters:
file
- a file.- Throws:
org.apache.commons.configuration2.ex.ConfigurationException
java.io.IOException
-
load
public void load(java.io.InputStream is) throws org.apache.commons.configuration2.ex.ConfigurationException
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
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:
toString
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in 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:
equals
in classjava.lang.Object
- Returns:
- true if the argument is equal to this set of properties.
-
-