public class ConfigurationParseHelper extends Object
NumberFormatException
s and similarModifier and Type | Method and Description |
---|---|
static URL |
findAsResource(String path)
Try to locate a local URL representing the incoming path.
|
static boolean |
getBooleanValue(Properties cfg,
String key,
boolean defaultValue)
Extracts a boolean value from configuration properties
|
static Integer |
getIntValue(Properties cfg,
String key)
Retrieves a configuration property and parses it as an Integer if it exists,
or returns null if the property is not set (undefined).
|
static int |
getIntValue(Properties cfg,
String key,
int defValue)
Looks for a numeric value in the Properties, returning
defValue if not found or if an empty string is found.
|
static long |
getLongValue(Properties cfg,
String key,
long defaultValue)
Looks for a numeric value in the Properties, returning
defValue if not found or if an empty string is found.
|
static String |
getString(Properties cfg,
String key,
String defaultValue)
Get the string property or defaults if not present
|
static URL |
locateConfig(String path)
Try to locate a local URL representing the incoming path.
|
static boolean |
parseBoolean(String value,
String errorMsgOnParseFailure)
Parses a string to recognize exactly either "true" or "false".
|
static int |
parseInt(String value,
int defValue,
String errorMsgOnParseFailure)
In case value is null or an empty string the defValue is returned.
|
static int |
parseInt(String value,
String errorMsgOnParseFailure)
Parses a string into an integer value.
|
static long |
parseLong(String value,
long defValue,
String errorMsgOnParseFailure)
In case value is null or an empty string the defValue is returned
|
static long |
parseLong(String value,
String errorMsgOnParseFailure)
Parses a String to get an long value.
|
public static URL locateConfig(String path)
path
- The path representing the config location.public static URL findAsResource(String path)
path
- The path representing the config location.public static int parseInt(String value, String errorMsgOnParseFailure)
value
- a string containing an int value to parseerrorMsgOnParseFailure
- message being wrapped in a SearchException if value is null
or not an integerSearchException
- both for null values and for Strings not containing a valid int.public static long parseLong(String value, String errorMsgOnParseFailure)
value
- A string containing an long value to parseerrorMsgOnParseFailure
- message being wrapped in a SearchException if value is null or not correct.SearchException
- both for null values and for Strings not containing a valid int.public static final int parseInt(String value, int defValue, String errorMsgOnParseFailure)
value
- the text to parsedefValue
- the value to return in case the text is nullerrorMsgOnParseFailure
- message in case of errorSearchException
- if value can't be parsed.public static final long parseLong(String value, long defValue, String errorMsgOnParseFailure)
value
- the text to parsedefValue
- the value to return in case the text is nullerrorMsgOnParseFailure
- message in case of errorSearchException
- if value can't be parsed.public static final int getIntValue(Properties cfg, String key, int defValue)
cfg
- the propertieskey
- the property identifierdefValue
- the value to return if the property is not found or emptySearchException
- for invalid format.public static long getLongValue(Properties cfg, String key, long defaultValue)
cfg
- the propertieskey
- the property identifierdefaultValue
- the value to return if the property is not found or emptySearchException
- for invalid format.public static final boolean parseBoolean(String value, String errorMsgOnParseFailure)
value
- the string to be parsederrorMsgOnParseFailure
- the message to be put in the exception if thrownSearchException
- for invalid format or values.public static final boolean getBooleanValue(Properties cfg, String key, boolean defaultValue)
cfg
- configuration Propertieskey
- the property keydefaultValue
- a boolean.SearchException
- for invalid format or values.public static final String getString(Properties cfg, String key, String defaultValue)
cfg
- configuration Propertieskey
- the property keydefaultValue
- the value to return if the property value is nullpublic static Integer getIntValue(Properties cfg, String key)
cfg
- configuration Propertieskey
- the property keySearchException
- both for empty (non-null) values and for Strings not containing a valid int representation.Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved