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

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

Introduction

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

Prototype

public Object put(Object key, Object value) 

Source Link

Document

Adds the value to the collection associated with the specified key.

Usage

From source file:net.firejack.platform.core.utils.CollectionUtils.java

/**
 *
 * @param objects/*  w ww  .ja v  a 2s.c o m*/
 * @param key
 * @param value
 * @return
 */
public static MultiValueMap create(List<Object[]> objects, int key, int value) {
    MultiValueMap map = new MultiValueMap();

    if (objects != null) {
        for (Object[] object : objects) {
            map.put(object[key], object[value]);
        }
    }
    return map;
}

From source file:ca.sqlpower.object.SPResolverRegistry.java

/**
 * Creates a {@link MultiValueMap} of {@link SPVariableResolver} user
 * friendly names to their respective namespace.
 * // w w w .  j a  v a  2 s  . co  m
 * @param treeMember
 *            The {@link SPObject} whose root to get the namespaces from.
 * @return The created {@link MultiValueMap}.
 */
public static MultiValueMap getNamespaces(SPObject treeMember) {
    if (treeMember == null) {
        return new MultiValueMap();
    }

    synchronized (resolvers) {
        MultiValueMap results = new MultiValueMap();
        SPObject root = init(treeMember);
        for (SPVariableResolver resolver : resolvers.get(root.getUUID())) {
            results.put(resolver.getUserFriendlyName(), resolver.getNamespace());
        }
        return results;
    }
}

From source file:net.landora.video.utils.UIUtils.java

public static MultiValueMap createCompleteContextByClass(Collection<?> context) {
    Collection<Object> fullContext = UIUtils.createCompleteContext(context);

    MultiValueMap valuesByClass = new MultiValueMap();
    Set<Class<?>> allClasses = new HashSet<Class<?>>();
    for (Object obj : fullContext) {
        Class<?> clazz = obj.getClass();
        allClasses.clear();/*from   w ww. j  ava2  s  .  c  om*/
        while (clazz != null) {
            allClasses.add(clazz);
            allClasses.addAll(Arrays.asList(clazz.getInterfaces()));
            clazz = clazz.getSuperclass();
        }

        for (Class<?> c : allClasses) {
            valuesByClass.put(c, obj);
        }
    }
    return valuesByClass;
}

From source file:com.nextep.designer.synch.ui.jface.ComparisonItemContentProvider.java

@SuppressWarnings("unchecked")
private Collection<ICategorizedType> getHashedItemTypes(Collection<IComparisonItem> items) {
    List<ICategorizedType> categories = new ArrayList<ICategorizedType>();
    MultiValueMap itemsTypeMap = new MultiValueMap();
    for (IComparisonItem item : items) {
        itemsTypeMap.put(item.getType(), item);
    }/*from  w w w  .j  a v  a2  s .  c  o m*/
    for (Object o : itemsTypeMap.keySet()) {
        final IElementType t = (IElementType) o;
        final Collection<IComparisonItem> typedItems = itemsTypeMap.getCollection(t);
        final ICategorizedType category = new CategorizedType(t, typedItems);
        categories.add(category);
    }
    return categories;
}

From source file:com.nextep.designer.synch.ui.jface.ComparisonTypedTreeContentProvider.java

@SuppressWarnings("unchecked")
private void hashItemTypes(Collection<IComparisonItem> items) {
    categories.clear();/*from   www. j  ava 2 s.  com*/
    MultiValueMap itemsTypeMap = new MultiValueMap();
    for (IComparisonItem item : items) {
        itemsTypeMap.put(item.getType(), item);
    }
    for (Object o : itemsTypeMap.keySet()) {
        final IElementType t = (IElementType) o;
        final Collection<IComparisonItem> typedItems = itemsTypeMap.getCollection(t);
        final ICategorizedType category = new CategorizedType(t, typedItems);
        categories.put(t, category);
    }
}

From source file:com.radialpoint.uima.typemapper.TypeMapperTest.java

@Test(expected = AnalysisEngineProcessException.class)
public void testBeginAndEndDoNotMatch() throws ResourceInitializationException, AnalysisEngineProcessException {
    Annotation sentenceAnnotation = (Annotation) cas.createAnnotation(sentenceType, 6, 4);
    sentenceAnnotation.addToIndexes();//from   w w w  . java 2  s  . c  o  m

    AnalysisEngine analysisEngine = AnalysisEngineFactory.createEngine(TypeMapper.class,
            TypeMapper.CONFIG_FILE_NAME,
            "src/test/resources/com/radialpoint/uima/typemapper/NormalWorkflowConfig.xml");

    SimplePipeline.runPipeline(cas, analysisEngine);

    MultiValueMap featureValues = new MultiValueMap();

    featureValues.put("begin", sentenceAnnotation.getBegin());
    featureValues.put("end", sentenceAnnotation.getEnd());

    verifyMappedAnnotation(sentenceType, 1, featureValues);
}

From source file:com.radialpoint.uima.typemapper.TypeMapperTest.java

@Test
public void testNormalWorkflow()
        throws ResourceInitializationException, AnalysisEngineProcessException, CASException {

    Annotation sentenceAnnotation = (Annotation) cas.createAnnotation(sentenceType, 0, 4);
    sentenceAnnotation.addToIndexes();//from   w w  w . j a  v  a2  s.  co  m

    Annotation paragraphAnnotation01 = (Annotation) cas.createAnnotation(paragraphType, 3, 6);
    paragraphAnnotation01.addToIndexes();

    Annotation paragraphAnnotation02 = (Annotation) cas.createAnnotation(paragraphType, 10, 25);
    paragraphAnnotation02.addToIndexes();

    AnalysisEngine analysisEngine = AnalysisEngineFactory.createEngine(TypeMapper.class,
            TypeMapper.CONFIG_FILE_NAME,
            "src/test/resources/com/radialpoint/uima/typemapper/NormalWorkflowConfig.xml");

    SimplePipeline.runPipeline(cas, analysisEngine);

    MultiValueMap featureValues = new MultiValueMap();

    featureValues.put("begin", sentenceAnnotation.getBegin());
    featureValues.put("end", sentenceAnnotation.getEnd());

    verifyMappedAnnotation(sentenceType, 1, featureValues);

    featureValues.clear();
    featureValues.put("begin", paragraphAnnotation01.getBegin());
    featureValues.put("end", paragraphAnnotation01.getEnd());
    featureValues.put("begin", paragraphAnnotation02.getBegin());
    featureValues.put("end", paragraphAnnotation02.getEnd());

    verifyMappedAnnotation(paragraphType, 2, featureValues);

}

From source file:net.landora.animeinfo.notifications.NotificationViewer.java

public void loadNotifications() {
    List<AnimeNotification> notifications = AnimeDBA.getOutstandAnimeNotifications();

    Set<AnimeStub> animes = new HashSet<AnimeStub>();
    for (AnimeNotification notification : notifications) {
        animes.add(notification.getFile().getEpisode().getAnime());
    }//from w  ww . j a  v a  2  s .  c o m

    List<AnimeStub> sortedAnime = new ArrayList<AnimeStub>(animes);
    Collections.sort(sortedAnime, UIUtils.LEXICAL_SORTER);

    notificationsNode.removeAllChildren();

    for (AnimeStub anime : sortedAnime) {
        DefaultMutableTreeNode animeNode = new DefaultMutableTreeNode(anime);

        MultiValueMap map = new MultiValueMap();
        for (AnimeNotification notificaton : notifications) {
            if (notificaton.getFile().getEpisode().getAnime().equals(anime)) {
                map.put(notificaton.getFile().getEpisode(), notificaton);
            }
        }
        List<AnimeEpisode> episodes = new ArrayList<AnimeEpisode>(map.keySet());
        Collections.sort(episodes, UIUtils.LEXICAL_SORTER);

        for (AnimeEpisode episode : episodes) {
            DefaultMutableTreeNode episodeNode = new DefaultMutableTreeNode(episode);
            List<AnimeNotification> list = (List<AnimeNotification>) map.get(episode);
            Collections.sort(list, UIUtils.LEXICAL_SORTER);
            for (AnimeNotification notification : list) {
                episodeNode.add(new DefaultMutableTreeNode(notification, false));
            }
            animeNode.add(episodeNode);
        }
        notificationsNode.add(animeNode);
    }

    treeModel.nodeStructureChanged(notificationsNode);
}

From source file:edu.scripps.fl.pubchem.promiscuity.OverallListsAndMapsFactory.java

public MultiValueMap getSummaryToAIDsMap(Map<Long, List<ELinkResult>> aidToSummaryMap) {
    MultiValueMap map = new MultiValueMap();
    log.info("Memory used before summary to aids map: " + memUsage());
    log.info("Setting up summary to AID map");
    for (Long ll : aidToSummaryMap.keySet()) {
        ELinkResult result = (ELinkResult) aidToSummaryMap.get(ll);
        if (result == null)
            continue;
        List<Long> summaries = result.getIds("pcassay", "pcassay_pcassay_neighbor_list");
        if (summaries != null) {
            for (Long summary : summaries) {
                map.put(summary, ll);
            }/*ww  w.j  a v a  2 s .c o  m*/
        }
    }
    log.info("Finished setting up summary to AID map");
    log.info("Memory used after summary to aids map: " + memUsage());
    return map;
}

From source file:edu.scripps.fl.curves.plot.CurvePlot.java

public void addCurveMeanAndStdDev(Curve curve, FitFunction fitFunction, String description) {
    double min = Double.MAX_VALUE, max = Double.MIN_VALUE;
    MultiValueMap validMap = new MultiValueMap();
    MultiValueMap invalidMap = new MultiValueMap();
    // group each concentration in a hash, average, then add point
    for (int ii = 0; ii < curve.getConcentrations().size(); ii++) {
        Double c = curve.getConcentrations().get(ii);
        Double r = curve.getResponses().get(ii);
        if (curve.getMask().get(ii))
            validMap.put(c, r);
        else//  w ww  .j ava 2 s.co m
            invalidMap.put(c, r);
        min = Math.min(min, c);
        max = Math.max(max, c);
    }
    addCurve(curve, getSeries(validMap, description), getSeries(invalidMap, ""), fitFunction, min, max);
}