public final class

PropertiesHelper

extends Object
java.lang.Object
   ↳ org.hibernate.util.PropertiesHelper

Class Overview

Collection of helper methods for dealing with java.util.Properties objects.

Summary

Public Methods
static String extractPropertyValue(String propertyName, Properties properties)
Extract a property value by name from the given properties object.
static boolean getBoolean(String propertyName, Properties properties, boolean defaultValue)
Get a property value as a boolean.
static boolean getBoolean(String propertyName, Properties properties)
Get a property value as a boolean.
static int getInt(String propertyName, Properties properties, int defaultValue)
Get a property value as an int.
static Integer getInteger(String propertyName, Properties properties)
Get a property value as an Integer.
static String getString(String propertyName, Properties properties, String defaultValue)
Get a property value as a string.
static Properties maskOut(Properties props, String key)
replace a property by a starred version
static String resolvePlaceHolder(String property)
Handles interpolation processing for a single property.
static void resolvePlaceHolders(Properties properties)
Handles interpolation processing for all entries in a properties object.
static Map toMap(String propertyName, String delim, Properties properties)
Constructs a map from a property value.
static String[] toStringArray(String propertyName, String delim, Properties properties)
Get a property value as a string array.
static String[] toStringArray(String stringForm, String delim)
Convert a string to an array of strings.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static String extractPropertyValue (String propertyName, Properties properties)

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 value
properties The properties object
Returns
  • The property value; may be null.

public static boolean getBoolean (String propertyName, Properties properties, boolean defaultValue)

Get a property value as a boolean.

First, the string value is extracted, and then valueOf(String) is used to determine the correct boolean value.

Parameters
propertyName The name of the property for which to retrieve value
properties The properties object
defaultValue The default property value to use.
Returns
  • The property value.

public static boolean getBoolean (String propertyName, Properties properties)

Get a property value as a boolean. Shorthand for calling getBoolean(String, java.util.Properties, boolean) with false as the default value.

Parameters
propertyName The name of the property for which to retrieve value
properties The properties object
Returns
  • The property value.

public static int getInt (String propertyName, Properties properties, int defaultValue)

Get a property value as an int.

First, the string value is extracted, and then 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 value
properties The properties object
defaultValue The default property value to use.
Returns
  • The property value.

public static Integer getInteger (String propertyName, Properties properties)

Get a property value as an Integer.

First, the string value is extracted, and then 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 value
properties The properties object
Returns
  • The property value; may be null.

public static String getString (String propertyName, Properties properties, String defaultValue)

Get a property value as a string.

Parameters
propertyName The name of the property for which to retrieve value
properties The properties object
defaultValue The default property value to use.
Returns
  • The property value; may be null.

public static Properties maskOut (Properties props, String key)

replace a property by a starred version

Parameters
props properties to check
key proeprty to mask
Returns
  • cloned and masked properties

public static String resolvePlaceHolder (String property)

Handles interpolation processing for a single property.

Parameters
property The property value to be processed for interpolation.
Returns
  • The (possibly) interpolated property value.

public static void resolvePlaceHolders (Properties properties)

Handles interpolation processing for all entries in a properties object.

Parameters
properties The properties object.

public static Map toMap (String propertyName, String delim, Properties properties)

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 value
delim 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.

public static String[] toStringArray (String propertyName, String delim, Properties properties)

Get a property value as a string array.

Parameters
propertyName The name of the property for which to retrieve value
delim The delimiter used to separate individual array elements.
properties The properties object
Returns
  • The array; never null, though may be empty.

public static String[] toStringArray (String stringForm, String delim)

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.