Class JProperties
Properties
.-
Method Summary
Modifier and TypeMethodDescriptionstatic Properties
Load properties from the given file.static BigDecimal
getBigDecimal
(Properties properties, String key) Returns the real value associated withkey
in the properties referenced byproperties
.static BigDecimal
getBigDecimalWithDefault
(Properties properties, String key, BigDecimal other) Returns the real value associated withkey
in the properties referenced byproperties
if it exists, otherwise returns the given default value.static BigInteger
getBigInteger
(Properties properties, String key) Returns the integer value associated withkey
in the properties referenced byproperties
.static BigInteger
getBigIntegerWithDefault
(Properties properties, String key, BigInteger other) Returns the integer value associated withkey
in the properties referenced byproperties
if it exists, otherwise returnsother
.static boolean
getBoolean
(Properties properties, String key) Returns the boolean value associated withkey
in the properties referenced byproperties
.static boolean
getBooleanWithDefault
(Properties properties, String key, boolean other) Returns the boolean value associated withkey
in the properties referenced byproperties
if it exists, otherwise returnsother
.static double
getDouble
(Properties properties, String key) Returns the double value associated withkey
in the properties referenced byproperties
.static double
getDoubleWithDefault
(Properties properties, String key, double other) Returns the double value associated withkey
in the properties referenced byproperties
if it exists, otherwise returnsother
.static Duration
getDuration
(Properties properties, String key) Returns the Duration value associated withkey
in the properties referenced byproperties
.static Duration
getDurationWithDefault
(Properties properties, String key, Duration other) Returns the Duration value associated withkey
in the properties referenced byproperties
if it exists, otherwise returnsother
.static InetAddress
getInetAddress
(Properties properties, String key) Returns the InetAddress value associated withkey
in the properties referenced byproperties
.static InetAddress
getInetAddressWithDefault
(Properties properties, String key, InetAddress other) Returns the InetAddress value associated withkey
in the properties referenced byproperties
if it exists, otherwise returnsother
.static int
getInteger
(Properties properties, String key) Returns the integer value associated withkey
in the properties referenced byproperties
.static int
getIntegerWithDefault
(Properties properties, String key, int other) Returns the integer value associated withkey
in the properties referenced byproperties
if it exists, otherwise returnsother
.static long
getLong
(Properties properties, String key) Returns the integer value associated withkey
in the properties referenced byproperties
.static long
getLongWithDefault
(Properties properties, String key, long other) Returns the integer value associated withkey
in the properties referenced byproperties
if it exists, otherwise returnsother
.static String
getString
(Properties properties, String key) Returns the string value associated withkey
in the properties referenced byprops
getStringOptional
(Properties properties, String key) Returns the string value associated withkey
in the properties referenced byprops
static String
getStringWithDefault
(Properties properties, String key, String other) Returns the string value associated withkey
in the properties referenced byprops
if it exists, otherwise returnsother
.static URI
getURI
(Properties properties, String key) Returns the URI value associated withkey
in the properties referenced byproperties
.static URI
getURIWithDefault
(Properties properties, String key, URI other) Returns the URI value associated withkey
in the properties referenced byproperties
if it exists, otherwise returnsother
.static UUID
getUUID
(Properties properties, String key) Returns the UUID value associated withkey
in the properties referenced byproperties
.static UUID
getUUIDWithDefault
(Properties properties, String key, UUID other) Returns the UUID value associated withkey
in the properties referenced byproperties
if it exists, otherwise returnsother
.
-
Method Details
-
fromFile
Load properties from the given file.- Parameters:
file
- The file.- Returns:
- The loaded properties.
- Throws:
IOException
- On I/O errors.
-
getBigDecimal
public static BigDecimal getBigDecimal(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns the real value associated with
key
in 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 BigDecimal getBigDecimalWithDefault(Properties properties, String key, BigDecimal other) throws JPropertyIncorrectType Returns the real value associated with
key
in the properties referenced byproperties
if 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 BigInteger getBigInteger(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns the integer value associated with
key
in 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 BigInteger getBigIntegerWithDefault(Properties properties, String key, BigInteger other) throws JPropertyIncorrectType Returns the integer value associated with
key
in the properties referenced byproperties
if 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(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns the boolean value associated with
key
in 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(Properties properties, String key, boolean other) throws JPropertyIncorrectType Returns the boolean value associated with
key
in the properties referenced byproperties
if 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
Returns the string value associated with
key
in 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
Returns the string value associated with
key
in 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
Returns the string value associated with
key
in the properties referenced byprops
if 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(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns the integer value associated with
key
in 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(Properties properties, String key, int other) throws JPropertyIncorrectType Returns the integer value associated with
key
in the properties referenced byproperties
if 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(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns the integer value associated with
key
in 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(Properties properties, String key, long other) throws JPropertyIncorrectType Returns the integer value associated with
key
in the properties referenced byproperties
if 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(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns the double value associated with
key
in 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(Properties properties, String key, double other) throws JPropertyIncorrectType Returns the double value associated with
key
in the properties referenced byproperties
if 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 URI getURI(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns the URI value associated with
key
in 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 URI getURIWithDefault(Properties properties, String key, URI other) throws JPropertyIncorrectType Returns the URI value associated with
key
in the properties referenced byproperties
if 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 UUID getUUID(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns the UUID value associated with
key
in 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 UUID getUUIDWithDefault(Properties properties, String key, UUID other) throws JPropertyIncorrectType Returns the UUID value associated with
key
in the properties referenced byproperties
if 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 InetAddress getInetAddress(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns the InetAddress value associated with
key
in 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 InetAddress getInetAddressWithDefault(Properties properties, String key, InetAddress other) throws JPropertyIncorrectType Returns the InetAddress value associated with
key
in the properties referenced byproperties
if 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 Duration getDuration(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns the Duration value associated with
key
in 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 Duration getDurationWithDefault(Properties properties, String key, Duration other) throws JPropertyIncorrectType Returns the Duration value associated with
key
in the properties referenced byproperties
if 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
-