Example usage for org.apache.commons.collections.map MultiValueMap decorate

List of usage examples for org.apache.commons.collections.map MultiValueMap decorate

Introduction

In this page you can find the example usage for org.apache.commons.collections.map MultiValueMap decorate.

Prototype

public static MultiValueMap decorate(Map map) 

Source Link

Document

Creates a map which wraps the given map and maps keys to ArrayLists.

Usage

From source file:org.s23m.cell.serialization.serializer.InstanceMap.java

private InstanceMap() {
    builtIntances = new HashMap<String, Set>();
    innerShellInstances = new HashMap<String, Set>();
    InstanceBuilder.addInnershellInstancesInMemory(innerShellInstances);
    instancesToBuild = MultiValueMap.decorate(new HashMap<String, List<Instance>>());
    visibilitiesToBuild = MultiValueMap.decorate(new HashMap<String, List<VisibilityType>>());
    valuesToBuild = MultiValueMap.decorate(new HashMap<String, List<MapValue>>());
    variablesToBuild = MultiValueMap.decorate(new HashMap<String, List<MapValue>>());
    edgesToBuild = MultiValueMap.decorate(new HashMap<String, List<EdgeType>>());
    semanticRoleEdgesToBuild = MultiValueMap.decorate(new HashMap<String, List<EdgeType>>());
    superReferencesToBuild = MultiValueMap.decorate(new HashMap<String, List<SuperSetReferenceType>>());
    semanticErrors = new ArrayList<String>();
}

From source file:org.springmodules.xt.ajax.AjaxInterceptor.java

/**
 * Set mappings configured in the given {@link java.util.Properties} object.<br>
 * Each mapping associates an ANT based URL path with a comma separated list of {@link AjaxHandler}s configured in the Spring Application Context.<br>
 * Mappings are ordered in a sorted map, following the longest path order (from the longest path to the shorter).<br>
 * Please note that multiple mappings to the same URL are supported thanks to a {@link org.apache.commons.collections.map.MultiValueMap}.
 *
 * @param mappings A {@link java.util.Properties} containing handler mappings.
 *///from  w w w  . ja va2  s.  c  om
public void setHandlerMappings(Properties mappings) {
    this.handlerMappings = MultiValueMap.decorate(new TreeMap<String, String>(new Comparator() {
        public int compare(Object o1, Object o2) {
            if (!(o1 instanceof String) || !(o2 instanceof String)) {
                throw new ClassCastException(
                        "You have to map an URL to a comma separated list of handler names.");
            }
            if (o1.equals(o2)) {
                return 0;
            } else if (o1.toString().length() > o2.toString().length()) {
                return -1;
            } else {
                return 1;
            }
        }
    }));

    for (Map.Entry entry : mappings.entrySet()) {
        String[] handlers = ((String) entry.getValue()).split(",");
        for (String handler : handlers) {
            String url = (String) entry.getKey();
            if (!url.startsWith("/")) {
                url = "/" + url;
            }
            this.handlerMappings.put(url.trim(), handler.trim());
        }
    }
}