Class JProperties
Properties.-
Method Summary
Modifier and TypeMethodDescriptionstatic PropertiesLoad properties from the given file.static BigDecimalgetBigDecimal(Properties properties, String key) Returns the real value associated withkeyin the properties referenced byproperties.static BigDecimalgetBigDecimalWithDefault(Properties properties, String key, BigDecimal other) Returns the real value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returns the given default value.static BigIntegergetBigInteger(Properties properties, String key) Returns the integer value associated withkeyin the properties referenced byproperties.static BigIntegergetBigIntegerWithDefault(Properties properties, String key, BigInteger other) Returns the integer value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returnsother.static booleangetBoolean(Properties properties, String key) Returns the boolean value associated withkeyin the properties referenced byproperties.static booleangetBooleanWithDefault(Properties properties, String key, boolean other) Returns the boolean value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returnsother.static doublegetDouble(Properties properties, String key) Returns the double value associated withkeyin the properties referenced byproperties.static doublegetDoubleWithDefault(Properties properties, String key, double other) Returns the double value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returnsother.static DurationgetDuration(Properties properties, String key) Returns the Duration value associated withkeyin the properties referenced byproperties.static DurationgetDurationWithDefault(Properties properties, String key, Duration other) Returns the Duration value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returnsother.static InetAddressgetInetAddress(Properties properties, String key) Returns the InetAddress value associated withkeyin the properties referenced byproperties.static InetAddressgetInetAddressWithDefault(Properties properties, String key, InetAddress other) Returns the InetAddress value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returnsother.static intgetInteger(Properties properties, String key) Returns the integer value associated withkeyin the properties referenced byproperties.static intgetIntegerWithDefault(Properties properties, String key, int other) Returns the integer value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returnsother.static longgetLong(Properties properties, String key) Returns the integer value associated withkeyin the properties referenced byproperties.static longgetLongWithDefault(Properties properties, String key, long other) Returns the integer value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returnsother.static StringgetString(Properties properties, String key) Returns the string value associated withkeyin the properties referenced bypropsgetStringOptional(Properties properties, String key) Returns the string value associated withkeyin the properties referenced bypropsstatic StringgetStringWithDefault(Properties properties, String key, String other) Returns the string value associated withkeyin the properties referenced bypropsif it exists, otherwise returnsother.static URIgetURI(Properties properties, String key) Returns the URI value associated withkeyin the properties referenced byproperties.static URIgetURIWithDefault(Properties properties, String key, URI other) Returns the URI value associated withkeyin the properties referenced bypropertiesif it exists, otherwise returnsother.static UUIDgetUUID(Properties properties, String key) Returns the UUID value associated withkeyin the properties referenced byproperties.static UUIDgetUUIDWithDefault(Properties properties, String key, UUID other) Returns the UUID value associated withkeyin the properties referenced bypropertiesif 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
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 BigDecimal getBigDecimalWithDefault(Properties properties, String key, BigDecimal other) throws JPropertyIncorrectType Returns 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 BigInteger getBigInteger(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns 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 BigInteger getBigIntegerWithDefault(Properties properties, String key, BigInteger other) throws JPropertyIncorrectType Returns 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(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns 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(Properties properties, String key, boolean other) throws JPropertyIncorrectType Returns 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
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
- Throws:
JPropertyNonexistent- If the given key is not present in the given properties.
-
getStringOptional
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
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(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns 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(Properties properties, String key, int other) throws JPropertyIncorrectType Returns 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(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns 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(Properties properties, String key, long other) throws JPropertyIncorrectType Returns 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(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns 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(Properties properties, String key, double other) throws JPropertyIncorrectType Returns 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 URI getURI(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns 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 URI getURIWithDefault(Properties properties, String key, URI other) throws JPropertyIncorrectType Returns 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 UUID getUUID(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns 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 UUID getUUIDWithDefault(Properties properties, String key, UUID other) throws JPropertyIncorrectType Returns 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 InetAddress getInetAddress(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns 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 InetAddress getInetAddressWithDefault(Properties properties, String key, InetAddress other) throws JPropertyIncorrectType Returns 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 Duration getDuration(Properties properties, String key) throws JPropertyNonexistent, JPropertyIncorrectType Returns 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 Duration getDurationWithDefault(Properties properties, String key, Duration other) throws JPropertyIncorrectType Returns 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
-