Package de.elo.utils
Class PropertiesEx
java.lang.Object
java.util.Dictionary<K,V>
java.util.Hashtable<java.lang.Object,java.lang.Object>
java.util.Properties
de.elo.utils.PropertiesEx
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.Map<java.lang.Object,java.lang.Object>
public class PropertiesEx
extends java.util.Properties
This class extends the Properties class by some commonly used functions.
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
Constructors Constructor Description PropertiesEx()
-
Method Summary
Modifier and Type Method Description java.lang.String
getMandatoryProperty(java.lang.String key)
CallsProperties.getProperty(String)
and throws an IllegalStateException, if the property does not exist or its value is empty.boolean
getMandatoryPropertyBoolean(java.lang.String key)
java.util.Date
getMandatoryPropertyDate(java.lang.String key)
double
getMandatoryPropertyDouble(java.lang.String key)
java.io.File
getMandatoryPropertyFile(java.lang.String key)
int
getMandatoryPropertyInt(java.lang.String key)
long
getMandatoryPropertyLong(java.lang.String key)
boolean
getProperty(java.lang.String key, boolean defaultValue)
double
getProperty(java.lang.String key, double defaultValue)
int
getProperty(java.lang.String key, int defaultValue)
long
getProperty(java.lang.String key, long defaultValue)
java.io.File
getProperty(java.lang.String key, java.io.File defaultValue)
java.util.Date
getProperty(java.lang.String key, java.util.Date defaultValue)
long
getPropertyTimeSpan(java.lang.String key, long defaultValue)
Converts a property value that is formatted as a timespan into milliseconds.void
setProperty(java.lang.String key, boolean value)
void
setProperty(java.lang.String key, double value)
void
setProperty(java.lang.String key, int value)
void
setProperty(java.lang.String key, long value)
void
setProperty(java.lang.String key, java.io.File defaultValue)
void
setProperty(java.lang.String key, java.util.Date value)
void
setPropertyDefault(java.lang.String key, boolean value)
void
setPropertyDefault(java.lang.String key, double value)
void
setPropertyDefault(java.lang.String key, int value)
void
setPropertyDefault(java.lang.String key, long value)
void
setPropertyDefault(java.lang.String key, java.io.File value)
void
setPropertyDefault(java.lang.String key, java.lang.String value)
void
setPropertyDefault(java.lang.String key, java.util.Date value)
Methods inherited from class java.util.Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, getProperty, getProperty, hashCode, isEmpty, keys, keySet, list, list, load, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, setProperty, size, store, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
Constructor Details
-
PropertiesEx
public PropertiesEx()
-
-
Method Details
-
getMandatoryProperty
public java.lang.String getMandatoryProperty(java.lang.String key)CallsProperties.getProperty(String)
and throws an IllegalStateException, if the property does not exist or its value is empty.- Parameters:
key
- Key- Returns:
- Value
-
getMandatoryPropertyInt
public int getMandatoryPropertyInt(java.lang.String key)- See Also:
getMandatoryProperty(String)
-
getMandatoryPropertyLong
public long getMandatoryPropertyLong(java.lang.String key)- See Also:
getMandatoryProperty(String)
-
getMandatoryPropertyDouble
public double getMandatoryPropertyDouble(java.lang.String key)- See Also:
getMandatoryProperty(String)
-
getMandatoryPropertyDate
public java.util.Date getMandatoryPropertyDate(java.lang.String key)- See Also:
getMandatoryProperty(String)
-
getMandatoryPropertyBoolean
public boolean getMandatoryPropertyBoolean(java.lang.String key)- See Also:
getMandatoryProperty(String)
-
getMandatoryPropertyFile
public java.io.File getMandatoryPropertyFile(java.lang.String key)- See Also:
getMandatoryProperty(String)
-
getProperty
public int getProperty(java.lang.String key, int defaultValue) -
setProperty
public void setProperty(java.lang.String key, int value) -
getProperty
public long getProperty(java.lang.String key, long defaultValue) -
setProperty
public void setProperty(java.lang.String key, long value) -
getProperty
public double getProperty(java.lang.String key, double defaultValue) -
setProperty
public void setProperty(java.lang.String key, double value) -
getProperty
public boolean getProperty(java.lang.String key, boolean defaultValue) -
setProperty
public void setProperty(java.lang.String key, boolean value) -
getProperty
public java.util.Date getProperty(java.lang.String key, java.util.Date defaultValue) -
setProperty
public void setProperty(java.lang.String key, java.util.Date value) -
getProperty
public java.io.File getProperty(java.lang.String key, java.io.File defaultValue) -
setProperty
public void setProperty(java.lang.String key, java.io.File defaultValue) -
setPropertyDefault
public void setPropertyDefault(java.lang.String key, java.lang.String value) -
setPropertyDefault
public void setPropertyDefault(java.lang.String key, int value) -
setPropertyDefault
public void setPropertyDefault(java.lang.String key, long value) -
setPropertyDefault
public void setPropertyDefault(java.lang.String key, java.util.Date value) -
setPropertyDefault
public void setPropertyDefault(java.lang.String key, double value) -
setPropertyDefault
public void setPropertyDefault(java.lang.String key, java.io.File value) -
setPropertyDefault
public void setPropertyDefault(java.lang.String key, boolean value) -
getPropertyTimeSpan
public long getPropertyTimeSpan(java.lang.String key, long defaultValue)Converts a property value that is formatted as a timespan into milliseconds. If the property value is not a number, the function tries to parse the value with the following SimpleDateFormat objects:SimpleDateFormat("MM-dd HH:mm:ss"),
SimpleDateFormat("dd HH:mm:ss"),
SimpleDateFormat("HH:mm:ss"),
SimpleDateFormat("HH:mm"),
- Parameters:
key
- Property keydefaultValue
- This value is returned, if the property does not exist or the value cannot be parsed.- Returns:
- value
-