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.StringgetMandatoryProperty(java.lang.String key)CallsProperties.getProperty(String)and throws an IllegalStateException, if the property does not exist or its value is empty.booleangetMandatoryPropertyBoolean(java.lang.String key)java.util.DategetMandatoryPropertyDate(java.lang.String key)doublegetMandatoryPropertyDouble(java.lang.String key)java.io.FilegetMandatoryPropertyFile(java.lang.String key)intgetMandatoryPropertyInt(java.lang.String key)longgetMandatoryPropertyLong(java.lang.String key)booleangetProperty(java.lang.String key, boolean defaultValue)doublegetProperty(java.lang.String key, double defaultValue)intgetProperty(java.lang.String key, int defaultValue)longgetProperty(java.lang.String key, long defaultValue)java.io.FilegetProperty(java.lang.String key, java.io.File defaultValue)java.util.DategetProperty(java.lang.String key, java.util.Date defaultValue)longgetPropertyTimeSpan(java.lang.String key, long defaultValue)Converts a property value that is formatted as a timespan into milliseconds.voidsetProperty(java.lang.String key, boolean value)voidsetProperty(java.lang.String key, double value)voidsetProperty(java.lang.String key, int value)voidsetProperty(java.lang.String key, long value)voidsetProperty(java.lang.String key, java.io.File defaultValue)voidsetProperty(java.lang.String key, java.util.Date value)voidsetPropertyDefault(java.lang.String key, boolean value)voidsetPropertyDefault(java.lang.String key, double value)voidsetPropertyDefault(java.lang.String key, int value)voidsetPropertyDefault(java.lang.String key, long value)voidsetPropertyDefault(java.lang.String key, java.io.File value)voidsetPropertyDefault(java.lang.String key, java.lang.String value)voidsetPropertyDefault(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
-