Class JProperties
public final class JProperties
extends java.lang.Object
Properties.-
Method Summary
Modifier and Type Method Description static java.util.PropertiesfromFile(java.io.File file)Load properties from the given file.static java.math.BigDecimalgetBigDecimal(java.util.Properties properties, java.lang.String key)Returns the real value associated withkeyin the properties referenced byproperties.static java.math.BigDecimalgetBigDecimalWithDefault(java.util.Properties properties, java.lang.String key, java.math.BigDecimal other)Returns the real value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returns the given default value.static java.math.BigIntegergetBigInteger(java.util.Properties properties, java.lang.String key)Returns the integer value associated withkeyin the properties referenced byproperties.static java.math.BigIntegergetBigIntegerWithDefault(java.util.Properties properties, java.lang.String key, java.math.BigInteger other)Returns the integer value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returnsother.static booleangetBoolean(java.util.Properties properties, java.lang.String key)Returns the boolean value associated withkeyin the properties referenced byproperties.static booleangetBooleanWithDefault(java.util.Properties properties, java.lang.String key, boolean other)Returns the boolean value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returnsother.static doublegetDouble(java.util.Properties properties, java.lang.String key)Returns the double value associated withkeyin the properties referenced byproperties.static doublegetDoubleWithDefault(java.util.Properties properties, java.lang.String key, double other)Returns the double value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returnsother.static java.time.DurationgetDuration(java.util.Properties properties, java.lang.String key)Returns the Duration value associated withkeyin the properties referenced byproperties.static java.time.DurationgetDurationWithDefault(java.util.Properties properties, java.lang.String key, java.time.Duration other)Returns the Duration value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returnsother.static java.net.InetAddressgetInetAddress(java.util.Properties properties, java.lang.String key)Returns the InetAddress value associated withkeyin the properties referenced byproperties.static java.net.InetAddressgetInetAddressWithDefault(java.util.Properties properties, java.lang.String key, java.net.InetAddress other)Returns the InetAddress value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returnsother.static intgetInteger(java.util.Properties properties, java.lang.String key)Returns the integer value associated withkeyin the properties referenced byproperties.static intgetIntegerWithDefault(java.util.Properties properties, java.lang.String key, int other)Returns the integer value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returnsother.static longgetLong(java.util.Properties properties, java.lang.String key)Returns the integer value associated withkeyin the properties referenced byproperties.static longgetLongWithDefault(java.util.Properties properties, java.lang.String key, long other)Returns the integer value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returnsother.static java.lang.StringgetString(java.util.Properties properties, java.lang.String key)Returns the string value associated withkeyin the properties referenced bypropsstatic java.util.Optional<java.lang.String>getStringOptional(java.util.Properties properties, java.lang.String key)Returns the string value associated withkeyin the properties referenced bypropsstatic java.lang.StringgetStringWithDefault(java.util.Properties properties, java.lang.String key, java.lang.String other)Returns the string value associated withkeyin the properties referenced bypropsif it exists, otherwise returnsother.static java.net.URIgetURI(java.util.Properties properties, java.lang.String key)Returns the URI value associated withkeyin the properties referenced byproperties.static java.net.URIgetURIWithDefault(java.util.Properties properties, java.lang.String key, java.net.URI other)Returns the URI value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returnsother.static java.util.UUIDgetUUID(java.util.Properties properties, java.lang.String key)Returns the UUID value associated withkeyin the properties referenced byproperties.static java.util.UUIDgetUUIDWithDefault(java.util.Properties properties, java.lang.String key, java.util.UUID other)Returns the UUID value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returnsother.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
fromFile
public static java.util.Properties fromFile(java.io.File file) throws java.io.IOExceptionLoad properties from the given file.- Parameters:
file- The file.- Returns:
- The loaded properties.
- Throws:
java.io.IOException- On I/O errors.
-
getBigDecimal
public static java.math.BigDecimal getBigDecimal(java.util.Properties properties, java.lang.String key) throws JPropertyNonexistent, JPropertyIncorrectTypeReturns the real value associated with
keyin the properties referenced byproperties.- Parameters:
properties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as an real.
- Throws:
JPropertyNonexistent- If the key does not exist in the given properties.JPropertyIncorrectType- If the value associated with the key cannot be parsed as a real.
-
getBigDecimalWithDefault
public static java.math.BigDecimal getBigDecimalWithDefault(java.util.Properties properties, java.lang.String key, java.math.BigDecimal other) throws JPropertyIncorrectTypeReturns the real value associated with
keyin the properties referenced bypropertiesif it exists, otherwise returns the given default value.- Parameters:
other- The default valueproperties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as an real.
- Throws:
JPropertyIncorrectType- If the value associated with the key cannot be parsed as a real.- Since:
- 3.0.0
-
getBigInteger
public static java.math.BigInteger getBigInteger(java.util.Properties properties, java.lang.String key) throws JPropertyNonexistent, JPropertyIncorrectTypeReturns the integer value associated with
keyin the properties referenced byproperties.- Parameters:
properties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as an integer.
- Throws:
JPropertyNonexistent- If the key does not exist in the given properties.JPropertyIncorrectType- If the value associated with the key cannot be parsed as an integer.
-
getBigIntegerWithDefault
public static java.math.BigInteger getBigIntegerWithDefault(java.util.Properties properties, java.lang.String key, java.math.BigInteger other) throws JPropertyIncorrectTypeReturns the integer value associated with
keyin the properties referenced bypropertiesif it exists, otherwise returnsother.- Parameters:
other- The default valueproperties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as an integer.
- Throws:
JPropertyIncorrectType- If the value associated with the key cannot be parsed as an integer.- Since:
- 3.0.0
-
getBoolean
public static boolean getBoolean(java.util.Properties properties, java.lang.String key) throws JPropertyNonexistent, JPropertyIncorrectTypeReturns the boolean value associated with
keyin the properties referenced byproperties.A boolean value is syntactically the strings "true" or "false", case insensitive.
- Parameters:
properties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as a boolean.
- Throws:
JPropertyNonexistent- If the key does not exist in the given properties.JPropertyIncorrectType- If the value associated with the key cannot be parsed as a boolean.
-
getBooleanWithDefault
public static boolean getBooleanWithDefault(java.util.Properties properties, java.lang.String key, boolean other) throws JPropertyIncorrectTypeReturns the boolean value associated with
keyin the properties referenced bypropertiesif it exists, otherwise returnsother.A boolean value is syntactically the strings "true" or "false", case insensitive.
- Parameters:
other- The default valueproperties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as a boolean.
- Throws:
JPropertyIncorrectType- If the value associated with the key cannot be parsed as a boolean.- Since:
- 3.0.0
-
getString
public static java.lang.String getString(java.util.Properties properties, java.lang.String key) throws JPropertyNonexistentReturns the string value associated with
keyin the properties referenced byprops- Parameters:
properties- The loaded properties.key- The requested key.- Returns:
- The value associated with the given key
- Throws:
JPropertyNonexistent- If the given key is not present in the given properties.
-
getStringOptional
public static java.util.Optional<java.lang.String> getStringOptional(java.util.Properties properties, java.lang.String key)Returns the string value associated with
keyin the properties referenced byprops- Parameters:
properties- The loaded properties.key- The requested key.- Returns:
- The value associated with the given key
- Since:
- 3.0.0
-
getStringWithDefault
public static java.lang.String getStringWithDefault(java.util.Properties properties, java.lang.String key, java.lang.String other)Returns the string value associated with
keyin the properties referenced bypropsif it exists, otherwise returnsother.- Parameters:
other- The default valueproperties- The loaded properties.key- The requested key.- Returns:
- The value associated with the given key
- Since:
- 3.0.0
-
getInteger
public static int getInteger(java.util.Properties properties, java.lang.String key) throws JPropertyNonexistent, JPropertyIncorrectTypeReturns the integer value associated with
keyin the properties referenced byproperties.- Parameters:
properties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as an integer.
- Throws:
JPropertyNonexistent- If the key does not exist in the given properties.JPropertyIncorrectType- If the value associated with the key cannot be parsed as an integer.- Since:
- 3.0.0
-
getIntegerWithDefault
public static int getIntegerWithDefault(java.util.Properties properties, java.lang.String key, int other) throws JPropertyIncorrectTypeReturns the integer value associated with
keyin the properties referenced bypropertiesif it exists, otherwise returnsother.- Parameters:
other- The default valueproperties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as an integer.
- Throws:
JPropertyIncorrectType- If the value associated with the key cannot be parsed as an integer.- Since:
- 3.0.0
-
getLong
public static long getLong(java.util.Properties properties, java.lang.String key) throws JPropertyNonexistent, JPropertyIncorrectTypeReturns the integer value associated with
keyin the properties referenced byproperties.- Parameters:
properties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as an integer.
- Throws:
JPropertyNonexistent- If the key does not exist in the given properties.JPropertyIncorrectType- If the value associated with the key cannot be parsed as an integer.- Since:
- 3.0.0
-
getLongWithDefault
public static long getLongWithDefault(java.util.Properties properties, java.lang.String key, long other) throws JPropertyIncorrectTypeReturns the integer value associated with
keyin the properties referenced bypropertiesif it exists, otherwise returnsother.- Parameters:
other- The default valueproperties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as an integer.
- Throws:
JPropertyIncorrectType- If the value associated with the key cannot be parsed as an integer.- Since:
- 3.0.0
-
getDouble
public static double getDouble(java.util.Properties properties, java.lang.String key) throws JPropertyNonexistent, JPropertyIncorrectTypeReturns the double value associated with
keyin the properties referenced byproperties.- Parameters:
properties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed a double
- Throws:
JPropertyNonexistent- If the key does not exist in the given properties.JPropertyIncorrectType- If the value associated with the key cannot be parsed as an integer.- Since:
- 3.0.0
-
getDoubleWithDefault
public static double getDoubleWithDefault(java.util.Properties properties, java.lang.String key, double other) throws JPropertyIncorrectTypeReturns the double value associated with
keyin the properties referenced bypropertiesif it exists, otherwise returnsother.- Parameters:
other- The default valueproperties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as a double
- Throws:
JPropertyIncorrectType- If the value associated with the key cannot be parsed as an integer.- Since:
- 3.0.0
-
getURI
public static java.net.URI getURI(java.util.Properties properties, java.lang.String key) throws JPropertyNonexistent, JPropertyIncorrectTypeReturns the URI value associated with
keyin the properties referenced byproperties.- Parameters:
properties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as a URI.
- Throws:
JPropertyNonexistent- If the key does not exist in the given properties.JPropertyIncorrectType- If the value associated with the key cannot be parsed as a URI.- Since:
- 3.0.0
-
getURIWithDefault
public static java.net.URI getURIWithDefault(java.util.Properties properties, java.lang.String key, java.net.URI other) throws JPropertyIncorrectTypeReturns the URI value associated with
keyin the properties referenced bypropertiesif it exists, otherwise returnsother.- Parameters:
other- The default valueproperties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as a URI.
- Throws:
JPropertyIncorrectType- If the value associated with the key cannot be parsed as a URI.- Since:
- 3.0.0
-
getUUID
public static java.util.UUID getUUID(java.util.Properties properties, java.lang.String key) throws JPropertyNonexistent, JPropertyIncorrectTypeReturns the UUID value associated with
keyin the properties referenced byproperties.- Parameters:
properties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as a UUID.
- Throws:
JPropertyNonexistent- If the key does not exist in the given properties.JPropertyIncorrectType- If the value associated with the key cannot be parsed as a UUID.- Since:
- 3.0.0
-
getUUIDWithDefault
public static java.util.UUID getUUIDWithDefault(java.util.Properties properties, java.lang.String key, java.util.UUID other) throws JPropertyIncorrectTypeReturns the UUID value associated with
keyin the properties referenced bypropertiesif it exists, otherwise returnsother.- Parameters:
other- The default valueproperties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as a UUID.
- Throws:
JPropertyIncorrectType- If the value associated with the key cannot be parsed as a UUID.- Since:
- 3.0.0
-
getInetAddress
public static java.net.InetAddress getInetAddress(java.util.Properties properties, java.lang.String key) throws JPropertyNonexistent, JPropertyIncorrectTypeReturns the InetAddress value associated with
keyin the properties referenced byproperties.- Parameters:
properties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as an InetAddress.
- Throws:
JPropertyNonexistent- If the key does not exist in the given properties.JPropertyIncorrectType- If the value associated with the key cannot be parsed as a InetAddress.- Since:
- 3.0.0
-
getInetAddressWithDefault
public static java.net.InetAddress getInetAddressWithDefault(java.util.Properties properties, java.lang.String key, java.net.InetAddress other) throws JPropertyIncorrectTypeReturns the InetAddress value associated with
keyin the properties referenced bypropertiesif it exists, otherwise returnsother.- Parameters:
other- The default valueproperties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as an InetAddress.
- Throws:
JPropertyIncorrectType- If the value associated with the key cannot be parsed as a InetAddress.- Since:
- 3.0.0
-
getDuration
public static java.time.Duration getDuration(java.util.Properties properties, java.lang.String key) throws JPropertyNonexistent, JPropertyIncorrectTypeReturns the Duration value associated with
keyin the properties referenced byproperties.- Parameters:
properties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as an Duration.
- Throws:
JPropertyNonexistent- If the key does not exist in the given properties.JPropertyIncorrectType- If the value associated with the key cannot be parsed as a Duration.- Since:
- 3.1.0
-
getDurationWithDefault
public static java.time.Duration getDurationWithDefault(java.util.Properties properties, java.lang.String key, java.time.Duration other) throws JPropertyIncorrectTypeReturns the Duration value associated with
keyin the properties referenced bypropertiesif it exists, otherwise returnsother.- Parameters:
other- The default valueproperties- The loaded properties.key- The requested key.- Returns:
- The value associated with the key, parsed as an Duration.
- Throws:
JPropertyIncorrectType- If the value associated with the key cannot be parsed as a Duration.- Since:
- 3.1.0
-