Java Utililty Methods Dictionary Usage

List of utility methods to do Dictionary Usage

Description

The list of methods to do Dictionary Usage are organized into topic(s).

Method

voidaddReferenceIdsToServiceProperties(String prefix, Map referenceProps, Dictionary serviceProps)
add Reference Ids To Service Properties
Object serviceId = referenceProps.get("service.id");
if (serviceId != null) {
    serviceProps.put(prefix + ".service.id", serviceId);
Object servicedPid = referenceProps.get("service.pid");
if (servicedPid != null) {
    serviceProps.put(prefix + ".service.pid", servicedPid);
booleancontainsKey(Dictionary dict, String key)
contains Key
if (dict == null || key == null) {
    return false;
return dict.get(key) != null;
BooleangetBoolean(Dictionary p, Object key, Boolean defaultValue)
get Boolean
Object value = p.get(key);
if (value == null)
    return defaultValue;
if (value instanceof Boolean)
    return (Boolean) value;
String s = value.toString().toLowerCase().trim();
if (s.equals("true") || s.equals("yes"))
    return new Boolean(true);
...
StringgetSpringContextHeader(Dictionary headers)
Return the #SPRING_CONTEXT_HEADER if present from the given dictionary.
Object header = null;
if (headers != null)
    header = headers.get(SPRING_CONTEXT_HEADER);
return (header != null ? header.toString().trim() : null);
BooleangetState(Dictionary conf, String property)
Getter for the state of a boolean type property.
Object value = conf.get(property);
if (value instanceof String) {
    String strVal = ((String) value).trim();
    if ("0".equals(strVal)) {
        return false;
    } else if ("1".equals(strVal)) {
        return true;
    } else {
...
StringgetString(Dictionary p, Object key, String defaultValue)
get String
Object value = p.get(key);
if (value == null)
    return defaultValue;
else
    return value.toString();
booleanisNullOrNothing(final Object[] array)
is Null Or Nothing
return array == null || array.length == 0;
voidparseRequestOption(Dictionary conf, String confParam, Map requestOptions)
Parses a request option from the configuration parameters.
Boolean state = getState(conf, confParam);
if (state != null) {
    String reqParam = confParam.substring(3); 
    requestOptions.put(reqParam, state);
voidsetDefault(Dictionary dict, String key, String value)
Puts the given key-value pair in the given dictionary if the key does not already exist in it or if its existing value is null.
if (dict.get(key) == null) {
    dict.put(key, value);
voidsetProperty(Dictionary properties, String key, String value)
set Property
if (value != null) {
    properties.put(key, value);