Class ConfigurationParseHelper
java.lang.Object
org.hibernate.search.backend.configuration.ConfigurationParseHelper
Helper class to avoid managing NumberFormatException and similar code
and ensure consistent error messages across Configuration parsing problems.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final booleangetBooleanValue(Properties cfg, String key, boolean defaultValue) Extracts a boolean value from configuration propertiesstatic final intgetIntValue(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 final booleanparseBoolean(String value, String errorMsgOnParseFailure) Parses a string to recognize exactly either "true" or "false".static final intIn case value is null or an empty string the defValue is returnedstatic final intParses a String to get an int value.
-
Constructor Details
-
ConfigurationParseHelper
public ConfigurationParseHelper()
-
-
Method Details
-
parseInt
Parses a String to get an int value.- Parameters:
value- A string containing an int value to parseerrorMsgOnParseFailure- message being wrapped in a SearchException if value is null or not correct.- Returns:
- the parsed value
- Throws:
SearchException- both for null values and for Strings not containing a valid int.
-
parseInt
In case value is null or an empty string the defValue is returned- Parameters:
value-defValue-errorMsgOnParseFailure-- Returns:
- the converted int.
- Throws:
SearchException- if value can't be parsed.
-
getIntValue
Looks for a numeric value in the Properties, returning defValue if not found or if an empty string is found. When the key the value is found but not in valid format a standard error message is generated.- Parameters:
cfg-key-defValue-- Returns:
- the converted int.
- Throws:
SearchException- for invalid format.
-
parseBoolean
Parses a string to recognize exactly either "true" or "false".- Parameters:
value- the string to be parsederrorMsgOnParseFailure- the message to be put in the exception if thrown- Returns:
- true if value is "true", false if value is "false"
- Throws:
SearchException- for invalid format or values.
-
getBooleanValue
Extracts a boolean value from configuration properties- Parameters:
cfg- configuration Propertieskey- the property keydefaultValue-- Returns:
- the defaultValue if the property was not defined
- Throws:
SearchException- for invalid format or values.
-