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

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

Introduction

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

Prototype

public Object remove(Object key, Object value) 

Source Link

Document

Removes a specific value from map.

Usage

From source file:com.nextep.datadesigner.impl.Observable.java

/**
 * Dumps the listeners registration difference between the specified snapshot and the current
 * snaphsot.//from   w ww  .  ja v  a2  s  . co m
 * 
 * @param snapshot old snapshot
 */
@SuppressWarnings("unchecked")
public static void dumpSnapshotDelta(Object snapshot) {
    MultiValueMap initial = (MultiValueMap) snapshot;
    MultiValueMap current = (MultiValueMap) getSnapshot();
    log.debug(">>>> DUMPING OBSERVABLE SNAPSHOT DIFFERENCE <<<<");
    log.debug("Initial listeners: " + initial.totalSize());
    log.debug("Current listeners: " + current.totalSize());
    boolean showWarning = (initial.totalSize() != current.totalSize());
    // Removing all identical listener registrations
    for (Object o : initial.keySet()) {
        Collection<IEventListener> listeners = (Collection<IEventListener>) initial.get(o);
        for (IEventListener l : listeners) {
            current.remove(o, l);
        }
    }
    // Our current map now only contains differences, we dump it
    log.debug("Residual listeners: " + current.totalSize());
    for (Object o : current.keySet()) {
        String name = NameHelper.getQualifiedName(o);

        log.debug("- Observable <" + name + "> has:");
        Collection<IEventListener> listeners = (Collection<IEventListener>) current.get(o);
        for (IEventListener l : listeners) {
            log.debug("    * Listener <" + l.toString() + "> of class [" + l.getClass().getName() + "]");
        }
    }
    if (showWarning) {
        log.warn("Some listeners have not been released");
    }
    log.debug(">>>> DUMPING ENDS <<<<");
}

From source file:pt.ua.tm.gimli.reader.BCReader.java

/**
 * Get annotations of this corpus reading the Annotations file.
 * @return MultiValueMap containing the annotations of each sentence
 * @throws GimliException Problem reading the annotations file
 *//* w w  w.  ja  v a2s  .  c o m*/
private MultiValueMap getAnnotations() throws GimliException {
    MultiValueMap annotations = new MultiValueMap();

    try {
        InputStreamReader isr = new InputStreamReader(new FileInputStream(fileAnnotations));
        BufferedReader br = new BufferedReader(isr);
        String line;

        int startChar, endChar;
        String pos, id;
        String[] parts;

        while ((line = br.readLine()) != null) {
            parts = line.split("[|]");
            id = parts[0];

            pos = parts[1];
            parts = pos.split("\\s+");

            startChar = Integer.parseInt(parts[0]);
            endChar = Integer.parseInt(parts[1]);

            BCAnnotation a = new BCAnnotation(startChar, endChar);
            BCAnnotation other;

            // For annotations with the same start, use the largest one
            Collection<BCAnnotation> col;
            if ((col = annotations.getCollection(id)) != null) {
                Iterator<BCAnnotation> it = col.iterator();
                while (it.hasNext()) {
                    other = it.next();
                    if (other.getStartChar() == a.getStartChar() && a.getEndChar() > other.getEndChar()) {
                        annotations.remove(id, other);
                        break;
                    }
                }
            }

            annotations.put(id, a);
        }
    } catch (IOException ex) {
        throw new GimliException("There was a problem reading the annotations file.", ex);
    }

    return annotations;
}

From source file:pt.ua.tm.neji.train.reader.BC2Reader.java

private MultiValueMap getAnnotations(InputStream inputAnnotations) throws NejiException {

    MultiValueMap annotations = new MultiValueMap();

    try {/*from   w w w .j  av  a 2 s .  com*/
        InputStreamReader isr = new InputStreamReader(inputAnnotations);
        BufferedReader br = new BufferedReader(isr);
        String line;
        String parts[];
        int startChar;
        int endChar;
        String pos;
        String id;

        while ((line = br.readLine()) != null) {
            parts = line.split("[|]");
            id = parts[0];

            pos = parts[1];
            parts = pos.split("\\s+");
            startChar = Integer.parseInt(parts[0]);
            endChar = Integer.parseInt(parts[1]);

            BCAnnotation a = new BCAnnotation(startChar, endChar);
            BCAnnotation other;

            // For annotations with the same start, use the largest one
            Collection<BCAnnotation> col;

            if ((col = annotations.getCollection(id)) != null) {
                Iterator<BCAnnotation> it = col.iterator();

                while (it.hasNext()) {
                    other = it.next();

                    if ((other.getStartChar() == a.getStartChar()) && (a.getEndChar() > other.getEndChar())) {
                        annotations.remove(id, other);
                        break;
                    }
                }
            }

            annotations.put(id, a);
        }
    } catch (IOException ex) {
        throw new NejiException("There was a problem reading the annotations file.", ex);
    }

    return annotations;
}