Top Description Fields Constructors Methods
org.hibernate.internal.util.config

public final Class ConfigurationHelper

extends Object
Class Inheritance
Imports
java.util.HashMap, .Iterator, .Map, .Properties, .StringTokenizer, org.hibernate.internal.util.StringHelper, org.hibernate.internal.util.collections.ArrayHelper

Collection of helper methods for dealing with configuration settings.
Authors
Gavin King, Steve Ebersole

Field Summary

Modifier and TypeField and Description
private static final String

Constructor Summary

AccessConstructor and Description
private
ConfigurationHelper()

Disallow instantiation

Method Summary

Modifier and TypeMethod and Description
public static Map<K, V>

Returns:

The clone
clone
(Map<?, ?>
The config values to clone
configurationValues
)

Make a clone of the configuration values.

private static String
extractFromSystem(String systemPropertyName)

public static String

Returns:

The property value; may be null.
extractPropertyValue
(String
The name of the property for which to extract value
propertyName
,
Properties
The properties object
properties
)

Extract a property value by name from the given properties object.

public static String

Returns:

The property value; may be null.
extractPropertyValue
(String
The name of the property for which to extract value
propertyName
,
Map<K, V>
The properties object
properties
)

Extract a property value by name from the given properties object.

public static boolean

Returns:

The value.
getBoolean
(String
The config setting name.
name
,
Map<K, V>
The map of config values
values
)

Get the config value as a boolean (default of false)

public static boolean

Returns:

The value.
getBoolean
(String
The config setting name.
name
,
Map<K, V>
The map of config values
values
,
boolean
The default value to use if not found
defaultValue
)

Get the config value as a boolean.

public static Boolean

Returns:

The value.
getBooleanWrapper
(String
The config setting name.
name
,
Map<K, V>
The map of config values
values
,
Boolean defaultValue)

Get the config value as a boolean (default of false)

public static int

Returns:

The value.
getInt
(String
The config setting name.
name
,
Map<K, V>
The map of config values
values
,
int
The default value to use if not found
defaultValue
)

Get the config value as an int

public static Integer

Returns:

The value, or null if not found
getInteger
(String
The config setting name.
name
,
Map<K, V>
The map of config values
values
)

Get the config value as an Integer

public static long
getLong(String name, Map<K, V> values, int defaultValue)

public static String

Returns:

The value, or null if not found
getString
(String
The config setting name.
name
,
Map<K, V>
The map of config values
values
)

Get the config value as a String

public static String

Returns:

The value.
getString
(String
The config setting name.
name
,
Map<K, V>
The map of config values
values
,
String
The default value to use if not found
defaultValue
)

Get the config value as a String

public static String

Returns:

The value.
getString
(String
The config setting name.
name
,
Map<K, V>
The map of config parameters.
values
,
String
The default value to use if not found.
defaultValue
,
String...
List of other supported values. Does not need to contain the default one.
otherSupportedValues
)

Get the config value as a String.

public static Properties

Returns:

cloned and masked properties
maskOut
(Properties
properties to check
props
,
String
property to mask
key
)

replace a property by a starred version

public static String

Returns:

The (possibly) interpolated property value.
resolvePlaceHolder
(String
The property value to be processed for interpolation.
property
)

Handles interpolation processing for a single property.

public static void
resolvePlaceHolders(Map<?, ?>
The configuration map.
configurationValues
)

Handles interpolation processing for all entries in a properties object.

public static Boolean
toBoolean(Object value, boolean defaultValue)

public static Map<K, V>

Returns:

The resulting map; never null, though perhaps empty.
toMap
(String
The name of the property for which to retrieve value
propertyName
,
String
The string defining tokens used as both entry and key/value delimiters.
delim
,
Properties
The properties object
properties
)

Constructs a map from a property value.

public static Map<K, V>

Returns:

The resulting map; never null, though perhaps empty.
toMap
(String
The name of the property for which to retrieve value
propertyName
,
String
The string defining tokens used as both entry and key/value delimiters.
delim
,
Map<K, V>
The properties object
properties
)

Constructs a map from a property value.

public static String[]

Returns:

The array; never null, though may be empty.
toStringArray
(String
The name of the property for which to retrieve value
propertyName
,
String
The delimiter used to separate individual array elements.
delim
,
Properties
The properties object
properties
)

Get a property value as a string array.

public static String[]

Returns:

The array; never null, though may be empty.
toStringArray
(String
The string form of the string array.
stringForm
,
String
The delimiter used to separate individual array elements.
delim
)

Convert a string to an array of strings.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

PLACEHOLDER_STARTback to summary
private static final String PLACEHOLDER_START

Constructor Detail

ConfigurationHelperback to summary
private ConfigurationHelper()

Disallow instantiation

Method Detail

cloneback to summary
public static Map<K, V> clone(Map<?, ?> configurationValues)

Make a clone of the configuration values.

Parameters
configurationValues:Map<?, ?>

The config values to clone

Returns:Map<K, V>

The clone

Annotations
@SuppressWarnings:unchecked
extractFromSystemback to summary
private static String extractFromSystem(String systemPropertyName)
extractPropertyValueback to summary
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:String

The name of the property for which to extract value

properties:Properties

The properties object

Returns:String

The property value; may be null.

extractPropertyValueback to summary
public static String extractPropertyValue(String propertyName, Map<K, V> 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:String

The name of the property for which to extract value

properties:Map<K, V>

The properties object

Returns:String

The property value; may be null.

getBooleanback to summary
public static boolean getBoolean(String name, Map<K, V> values)

Get the config value as a boolean (default of false)

Parameters
name:String

The config setting name.

values:Map<K, V>

The map of config values

Returns:boolean

The value.

getBooleanback to summary
public static boolean getBoolean(String name, Map<K, V> values, boolean defaultValue)

Get the config value as a boolean.

Parameters
name:String

The config setting name.

values:Map<K, V>

The map of config values

defaultValue:boolean

The default value to use if not found

Returns:boolean

The value.

getBooleanWrapperback to summary
public static Boolean getBooleanWrapper(String name, Map<K, V> values, Boolean defaultValue)

Get the config value as a boolean (default of false)

Parameters
name:String

The config setting name.

values:Map<K, V>

The map of config values

Returns:Boolean

The value.

getIntback to summary
public static int getInt(String name, Map<K, V> values, int defaultValue)

Get the config value as an int

Parameters
name:String

The config setting name.

values:Map<K, V>

The map of config values

defaultValue:int

The default value to use if not found

Returns:int

The value.

getIntegerback to summary
public static Integer getInteger(String name, Map<K, V> values)

Get the config value as an Integer

Parameters
name:String

The config setting name.

values:Map<K, V>

The map of config values

Returns:Integer

The value, or null if not found

getLongback to summary
public static long getLong(String name, Map<K, V> values, int defaultValue)
getStringback to summary
public static String getString(String name, Map<K, V> values)

Get the config value as a String

Parameters
name:String

The config setting name.

values:Map<K, V>

The map of config values

Returns:String

The value, or null if not found

getStringback to summary
public static String getString(String name, Map<K, V> values, String defaultValue)

Get the config value as a String

Parameters
name:String

The config setting name.

values:Map<K, V>

The map of config values

defaultValue:String

The default value to use if not found

Returns:String

The value.

getStringback to summary
public static String getString(String name, Map<K, V> values, String defaultValue, String... otherSupportedValues)

Get the config value as a String.

Parameters
name:String

The config setting name.

values:Map<K, V>

The map of config parameters.

defaultValue:String

The default value to use if not found.

otherSupportedValues:String[]

List of other supported values. Does not need to contain the default one.

Returns:String

The value.

Exceptions
ConfigurationException:
Unsupported value provided.
maskOutback to summary
public static Properties maskOut(Properties props, String key)

replace a property by a starred version

Parameters
props:Properties

properties to check

key:String

property to mask

Returns:Properties

cloned and masked properties

resolvePlaceHolderback to summary
public static String resolvePlaceHolder(String property)

Handles interpolation processing for a single property.

Parameters
property:String

The property value to be processed for interpolation.

Returns:String

The (possibly) interpolated property value.

resolvePlaceHoldersback to summary
public static void resolvePlaceHolders(Map<?, ?> configurationValues)

Handles interpolation processing for all entries in a properties object.

Parameters
configurationValues:Map<?, ?>

The configuration map.

toBooleanback to summary
public static Boolean toBoolean(Object value, boolean defaultValue)
toMapback to summary
public static Map<K, V> 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:String

The name of the property for which to retrieve value

delim:String

The string defining tokens used as both entry and key/value delimiters.

properties:Properties

The properties object

Returns:Map<K, V>

The resulting map; never null, though perhaps empty.

See Also
extractPropertyValue(String, java.util.Properties)
toMapback to summary
public static Map<K, V> toMap(String propertyName, String delim, Map<K, V> 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:String

The name of the property for which to retrieve value

delim:String

The string defining tokens used as both entry and key/value delimiters.

properties:Map<K, V>

The properties object

Returns:Map<K, V>

The resulting map; never null, though perhaps empty.

See Also
extractPropertyValue(String, java.util.Properties)
toStringArrayback to summary
public static String[] toStringArray(String propertyName, String delim, Properties properties)

Get a property value as a string array.

Parameters
propertyName:String

The name of the property for which to retrieve value

delim:String

The delimiter used to separate individual array elements.

properties:Properties

The properties object

Returns:String[]

The array; never null, though may be empty.

See Also
extractPropertyValue(String, java.util.Properties), toStringArray(String, String)
toStringArrayback to summary
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:String

The string form of the string array.

delim:String

The delimiter used to separate individual array elements.

Returns:String[]

The array; never null, though may be empty.