Package org.hibernate.util
Class PropertiesHelper
java.lang.Object
org.hibernate.util.PropertiesHelper
Collection of helper methods for dealing with
Properties
objects.-
Method Summary
Modifier and TypeMethodDescriptionstatic StringextractPropertyValue(String propertyName, Properties properties) Extract a property value by name from the given properties object.static booleangetBoolean(String propertyName, Properties properties) Get a property value as a boolean.static booleangetBoolean(String propertyName, Properties properties, boolean defaultValue) Get a property value as a boolean.static intgetInt(String propertyName, Properties properties, int defaultValue) Get a property value as an int.static IntegergetInteger(String propertyName, Properties properties) Get a property value as an Integer.static StringgetString(String propertyName, Properties properties, String defaultValue) Get a property value as a string.static PropertiesmaskOut(Properties props, String key) replace a property by a starred versionstatic StringresolvePlaceHolder(String property) Handles interpolation processing for a single property.static voidresolvePlaceHolders(Properties properties) Handles interpolation processing for all entries in a properties object.static MaptoMap(String propertyName, String delim, Properties properties) Constructs a map from a property value.static String[]toStringArray(String stringForm, String delim) Convert a string to an array of strings.static String[]toStringArray(String propertyName, String delim, Properties properties) Get a property value as a string array.
-
Method Details
-
getString
Get a property value as a string.- Parameters:
propertyName- The name of the property for which to retrieve valueproperties- The properties objectdefaultValue- The default property value to use.- Returns:
- The property value; may be null.
- See Also:
-
extractPropertyValue
Extract a property value by name from the given properties object. Both null and empty string are viewed as the same, and return null.- Parameters:
propertyName- The name of the property for which to extract valueproperties- The properties object- Returns:
- The property value; may be null.
-
getBoolean
Get a property value as a boolean. Shorthand for callinggetBoolean(String, java.util.Properties, boolean)with false as the default value.- Parameters:
propertyName- The name of the property for which to retrieve valueproperties- The properties object- Returns:
- The property value.
-
getBoolean
Get a property value as a boolean. First, the string value is extracted, and thenBoolean.valueOf(String)is used to determine the correct boolean value.- Parameters:
propertyName- The name of the property for which to retrieve valueproperties- The properties objectdefaultValue- The default property value to use.- Returns:
- The property value.
- See Also:
-
getInt
Get a property value as an int. First, the string value is extracted, and thenInteger.parseInt(String)is used to determine the correct int value for any non-null property values.- Parameters:
propertyName- The name of the property for which to retrieve valueproperties- The properties objectdefaultValue- The default property value to use.- Returns:
- The property value.
- See Also:
-
getInteger
Get a property value as an Integer. First, the string value is extracted, and thenInteger.valueOf(String)is used to determine the correct boolean value for any non-null property values.- Parameters:
propertyName- The name of the property for which to retrieve valueproperties- The properties object- Returns:
- The property value; may be null.
- See Also:
-
toMap
Constructs a map from a property value. The exact behavior here is largely dependant upon what is passed in as the delimiter.- Parameters:
propertyName- The name of the property for which to retrieve valuedelim- The string defining tokens used as both entry and key/value delimiters.properties- The properties object- Returns:
- The resulting map; never null, though perhaps empty.
- See Also:
-
toStringArray
Get a property value as a string array.- Parameters:
propertyName- The name of the property for which to retrieve valuedelim- The delimiter used to separate individual array elements.properties- The properties object- Returns:
- The array; never null, though may be empty.
- See Also:
-
toStringArray
Convert a string to an array of strings. The assumption is that the individual array elements are delimited in the source stringForm param by the delim param.- Parameters:
stringForm- The string form of the string array.delim- The delimiter used to separate individual array elements.- Returns:
- The array; never null, though may be empty.
-
maskOut
replace a property by a starred version- Parameters:
props- properties to checkkey- proeprty to mask- Returns:
- cloned and masked properties
-
resolvePlaceHolders
Handles interpolation processing for all entries in a properties object.- Parameters:
properties- The properties object.
-
resolvePlaceHolder
Handles interpolation processing for a single property.- Parameters:
property- The property value to be processed for interpolation.- Returns:
- The (possibly) interpolated property value.
-