Example usage for java.util Map remove

List of usage examples for java.util Map remove

Introduction

In this page you can find the example usage for java.util Map remove.

Prototype

V remove(Object key);

Source Link

Document

Removes the mapping for a key from this map if it is present (optional operation).

Usage

From source file:com.edgenius.wiki.render.macro.BaseMacro.java

/**
 * @param node//from  w  w  w  . ja v  a 2  s.  c  om
 * @param name
 * @return
 */
protected String getMacroMarkupString(HTMLNode node, String name) {
    StringBuffer markup = new StringBuffer("{").append(name);
    if (node.getAttributes() != null && !StringUtil.isBlank(node.getAttributes().get(NameConstants.WAJAX))) {

        String wajax = node.getAttributes().get(NameConstants.WAJAX);
        Map<String, String> map = RichTagUtil.parseWajaxAttribute(wajax);
        map.remove(NameConstants.ANAME);
        //remove name as !!!
        map.remove(NameConstants.MACRO);

        boolean first = true;
        if (map.size() > 0) {
            markup.append(":");
            for (Entry<String, String> entry : map.entrySet()) {
                if (!first)
                    markup.append("|");
                first = false;
                markup.append(entry.getKey()).append("=").append(EscapeUtil.escapeMacroParam(entry.getValue()));
            }
        }
    }

    markup.append("}");
    return markup.toString();
}

From source file:com.joliciel.talismane.extensions.Extensions.java

/**
 * To be called initially, so that any parameters specific to the extensions can be removed
 * and/or replaced in the argument map.//from ww w . jav a  2s .  c  o  m
 * @param args
 */
public void pluckParameters(Map<String, String> args) {
    if (args.containsKey("referenceStats")) {
        referenceStatsPath = args.get("referenceStats");
        args.remove("referenceStats");
    }
    if (args.containsKey("corpusRules")) {
        corpusRulesPath = args.get("corpusRules");
        args.remove("corpusRules");
    }

    if (args.containsKey("command")) {
        try {
            command = ExtendedCommand.valueOf(args.get("command"));
            args.remove("command");
            args.put("command", "process");
        } catch (IllegalArgumentException iae) {
            // do nothing
        }

    }
}

From source file:com.threewks.thundr.route.Router.java

private void remove(Route route) {
    if (route != null) {
        Map<String, Route> routesForMethod = this.routes.get(route.getMethod());
        routesForMethod.remove(route.getRouteMatchRegex());
        actionsForRoutes.remove(route);//  w w  w  .j a  v a  2  s .  co  m
        if (route.getName() != null) {
            namedRoutes.remove(route.getName());
        }
    }
}

From source file:edu.uci.ics.jung.utils.UnifiedUserData.java

/**
 * Removes the Datum (if any) for this key, and returns it.
 * //from  w  ww . j  av a 2 s. c  o  m
 * @param key
 */
public Object removeUserDatum(Object key) {
    Object o = getUserDatum(key);
    Map key_map = getKeyMap(key);
    //        key_map.remove(getObjectKey());
    key_map.remove(this);
    if (key_map.isEmpty())
        key_meta_map.remove(key_map);
    //        getStorage().remove(key);
    //        return value_pair.getFirst();
    return o;
}

From source file:playground.anhorni.surprice.analysis.ModeSharesEventHandler.java

public void printInfo(final int iteration) {
    Map<String, Double> currentModeXYs = getModeXYs();
    double totalXY = currentModeXYs.remove(ALL_MODES);

    for (Map.Entry<String, Double> mode : currentModeXYs.entrySet()) {
        if (this.xy.equals("times")) {
            log.info("Share of " + mode.getKey() + ":\t" + "time [s]: " + (100d * mode.getValue() / totalXY)
                    + "%");
        } else {//  w w w .j  a  v  a  2 s  . c om
            log.info("Share of " + mode.getKey() + ":\t" + "distance [km]: "
                    + (100d * mode.getValue() / totalXY) + "%");
        }
    }
}

From source file:io.fabric8.maven.core.util.kubernetes.KubernetesResourceUtil.java

/**
 * Returns a merge of the given maps and then removes any resulting empty string values (which is the way to remove, say, a label or annotation
 * when overriding//from  w w w . j  a v a 2  s .co m
 */
private static Map<String, String> mergeMapsAndRemoveEmptyStrings(Map<String, String> overrideMap,
        Map<String, String> originalMap) {
    Map<String, String> answer = MapUtil.mergeMaps(overrideMap, originalMap);
    Set<Map.Entry<String, String>> entries = overrideMap.entrySet();
    for (Map.Entry<String, String> entry : entries) {
        String value = entry.getValue();
        if (value == null || value.isEmpty()) {
            String key = entry.getKey();
            answer.remove(key);
        }
    }
    return answer;
}

From source file:org.graylog.plugins.beats.BeatsCodec.java

private Message createMessage(String message, Map<String, Object> event) {
    @SuppressWarnings("unchecked")
    final Map<String, Object> beat = (Map<String, Object>) event.remove("beat");
    final String hostname;
    final String name;
    if (beat == null) {
        hostname = "unknown";
        name = "unknown";
    } else {/* w  ww  . j  a v a 2s. c om*/
        hostname = String.valueOf(beat.get("hostname"));
        name = String.valueOf(beat.get("name"));
    }
    final String timestampField = String.valueOf(event.remove("@timestamp"));
    final DateTime timestamp = Tools.dateTimeFromString(timestampField);
    final String type = String.valueOf(event.get("type"));
    final Object tags = event.get("tags");

    final Message result = new Message(message, hostname, timestamp);
    result.addField("name", name);
    result.addField("type", type);
    result.addField("tags", tags);

    return result;
}

From source file:com.impetus.ankush.agent.action.impl.YAMLManipulator.java

/**
 * Delete conf value./* w w  w . j  ava 2  s  .c o  m*/
 * 
 * @param file
 *            the file
 * @param propertyName
 *            the property name
 * @return true, if successful
 */
public boolean deleteConfValue(String file, String objPropertyName) {

    String propertyName = (String) objPropertyName;
    Yaml yaml = new Yaml();
    try {
        InputStream fis = new FileInputStream(file);
        Object javaObject = yaml.load(fis);
        Map<String, Object> map = (Map<String, Object>) javaObject;
        if (map.containsKey(propertyName)) {
            map.remove(propertyName);
        }
        fis.close();
        // save to file
        File confFile = new File(file);
        if (!confFile.exists()) {
            System.err.println("File " + file + " does not exists.");
        }
        String dumped = yaml.dumpAsMap(map);
        FileUtils.writeStringToFile(confFile, dumped, false);

        return true;

    } catch (FileNotFoundException e) {
        System.err.println(e.getMessage());
    } catch (IOException e) {
        System.err.println(e.getMessage());
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    return false;
}

From source file:com.univocity.app.data.Dao.java

private Set<Entry<String, Object>> extractPrimaryKeyValues(Map<String, Object> rowData) {
    Map<String, Object> idsToMatch = new HashMap<String, Object>();
    for (String id : getPrimaryKeys()) {
        Object idValue = rowData.remove(id);
        idsToMatch.put(id, idValue);/*  w w  w  .j a  va 2s.  c o m*/
    }
    return idsToMatch.entrySet();
}

From source file:com.verisign.storm.metrics.reporters.kafka.BaseKafkaReporter.java

@Override
public void prepare(Map<String, Object> conf) {
    LOG.info(conf.toString());/*from  ww  w. j ava 2  s  .  c  om*/

    if (conf.containsKey(KAFKA_TOPIC_NAME_FIELD)) {
        kafkaTopicName = (String) conf.get(KAFKA_TOPIC_NAME_FIELD);
        conf.remove(KAFKA_TOPIC_NAME_FIELD);
    } else {
        throw new IllegalArgumentException("Field " + KAFKA_TOPIC_NAME_FIELD + " required.");
    }

    if (conf.containsKey(KAFKA_BROKER_LIST_FIELD)) {
        kafkaBrokerList = (String) conf.get(KAFKA_BROKER_LIST_FIELD);
        conf.remove(KAFKA_BROKER_LIST_FIELD);
        conf.put(KAFKA_PRODUCER_BOOTSTRAP_SERVERS_FIELD, kafkaBrokerList);
    } else if (conf.containsKey(KAFKA_PRODUCER_BOOTSTRAP_SERVERS_FIELD)) {
        kafkaBrokerList = (String) conf.get(KAFKA_PRODUCER_BOOTSTRAP_SERVERS_FIELD);
    } else {
        throw new IllegalArgumentException("Field " + KAFKA_BROKER_LIST_FIELD + " required.");
    }

    Properties producerProps = new Properties();
    for (Entry<String, Object> entry : conf.entrySet()) {
        if (entry.getValue() != null) {
            producerProps.setProperty(entry.getKey(), entry.getValue().toString());
        }
    }

    kafkaProducer = configureKafkaProducer(producerProps);
    buffer = new LinkedList<GraphingMetrics>();
    failures = 0;
}