Example usage for org.apache.commons.collections ExtendedProperties put

List of usage examples for org.apache.commons.collections ExtendedProperties put

Introduction

In this page you can find the example usage for org.apache.commons.collections ExtendedProperties put.

Prototype

public synchronized V put(K key, V value) 

Source Link

Document

Maps the specified key to the specified value in this hashtable.

Usage

From source file:org.opencms.util.CmsPropertyUtils.java

/**
 * Unescapes the given properties, unescaping "," and "=" entries.<p>
 * /*from w w  w . ja v a  2s .  c o m*/
 * @param properties the properties to adjust
 */
public static void unescapeProperties(ExtendedProperties properties) {

    for (Iterator i = properties.entrySet().iterator(); i.hasNext();) {
        Map.Entry entry = (Map.Entry) i.next();
        String key = (String) entry.getKey();
        Object obj = entry.getValue();
        String[] value = {};

        if (obj instanceof Vector) {
            value = (String[]) ((Vector) obj).toArray(value);
        } else {
            String[] v = { (String) obj };
            value = v;
        }

        for (int j = 0; j < value.length; j++) {
            value[j] = CmsStringUtil.substitute(value[j], "\\,", ",");
            value[j] = CmsStringUtil.substitute(value[j], "\\=", "=");
        }

        if (value.length > 1) {
            properties.put(key, new Vector(Arrays.asList(value)));
        } else {
            properties.put(key, value[0]);
        }
    }
}