Example usage for java.util Map keySet

List of usage examples for java.util Map keySet

Introduction

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

Prototype

Set<K> keySet();

Source Link

Document

Returns a Set view of the keys contained in this map.

Usage

From source file:fi.hsl.parkandride.back.RequestLogDao.java

private static List<DateTime> collectDuplicateTimestamps(Map<RequestLogKey, Long> logCounts) {
    return logCounts.keySet().stream().map(key -> key.roundTimestampDown().timestamp)
            .collect(MapUtils.countingOccurrences()).entrySet().stream().filter(entry -> entry.getValue() > 1)
            .map(entry -> entry.getKey()).collect(toList());
}

From source file:com.cprassoc.solr.auth.util.Utils.java

public static String mapKeysToString(Map map) {
    Iterator<String> iter = map.keySet().iterator();
    String result = "";
    int row = 0;//from  w ww. j a v  a2 s. co m
    String key, value;
    Object obj;
    while (iter.hasNext()) {
        key = iter.next();
        obj = map.get(key);
        if (obj instanceof String) {
            value = (String) map.get(key);
        } else {
            value = obj.toString();
        }
        if (row > 0) {
            result += ",";
        }
        result += key;
        row++;
    }
    return result;
}

From source file:com.cprassoc.solr.auth.util.Utils.java

public static String mapValuesToString(Map map) {
    Iterator<String> iter = map.keySet().iterator();
    String result = "";
    int row = 0;//from w  ww . java  2s  .  c om
    String key;
    Object value;
    while (iter.hasNext()) {
        key = iter.next();
        value = map.get(key);
        if (row > 0) {
            result += ",";
        }
        if (value instanceof String || value instanceof ArrayList) {
            result += value.toString();
        } else if (value instanceof Map) {
            result += mapValuesToString((Map) value);
        }
        // result += value;
        row++;
    }
    return result;
}

From source file:com.rackspacecloud.blueflood.http.DefaultHandler.java

public static void sendResponse(ChannelHandlerContext channel, FullHttpRequest request, String messageBody,
        HttpResponseStatus status, Map<String, String> headers) {

    DefaultFullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, status);
    if (headers != null && !headers.keySet().isEmpty()) {
        Iterator<String> itr = headers.keySet().iterator();
        while (itr.hasNext()) {
            String headerKey = itr.next();
            response.headers().add(headerKey, headers.get(headerKey));
        }/*from www.jav  a2  s  .  c  om*/
    }

    final Timer.Context sendResponseTimerContext = sendResponseTimer.time();
    try {
        if (messageBody != null && !messageBody.isEmpty()) {
            response.content().writeBytes(Unpooled.copiedBuffer(messageBody, Constants.DEFAULT_CHARSET));
        }

        responder.respond(channel, request, response);
        Tracker.getInstance().trackResponse(request, response);
    } finally {
        sendResponseTimerContext.stop();
    }
}

From source file:Main.java

public static String subsituteAttr(Map<String, String> attrMap, String text) {
    if (attrMap == null) {
        return (text);
    }/*from  ww  w .j ava 2 s  .  co  m*/
    if (!text.contains("{")) {
        return (text);
    }
    String newString = text;
    for (Object key : attrMap.keySet()) {
        String value = (String) attrMap.get(key);
        newString = newString.replace("{" + key + "}", value);
    }
    return (newString);
}

From source file:Main.java

/**
 * Compute the intersection of elements between the 2 given maps
 * /*from  w w  w.j a  v  a2 s. c  o  m*/
 * @param control
 *            the control collection
 * @param test
 *            the test collection
 * @return the elements of the control map that whose keys are part of the
 *         test map. The process works with keys and does not compare the
 *         values.
 */
public static <K, V> Map<K, V> intersection(final Map<K, V> control, final Map<K, V> test) {
    if (control == null) {
        return null;
    }
    if (test == null) {
        return control;
    }
    Collection<K> keys = intersection(control.keySet(), test.keySet());
    Map<K, V> result = new HashMap<K, V>();
    for (K key : keys) {
        result.put(key, control.get(key));
    }
    return result;
}

From source file:com.sequenceiq.ambari.shell.support.TableRenderer.java

private static Map<String, List<String>> convert(Map<String, String> map) {
    Map<String, List<String>> result = new HashMap<String, List<String>>(map.size());
    if (map != null) {
        for (String key : map.keySet()) {
            result.put(key, singletonList(map.get(key)));
        }// w  w w .j a va 2s. c o  m
    }
    return result;
}

From source file:adalid.util.info.JavaInfo.java

public static void printManifestInfo(String path, String name, boolean details, Manifest manifest) {
    Object object;//w  w w.  j a  va2 s.  c o m
    String string;
    out.println(path);
    //      out.println(StringUtils.leftPad(++fileCount + "", 4, '0') + ":" + name);
    out.println(name);
    Attributes attributes = manifest.getMainAttributes();
    Map<String, Object> sortedAttributes;
    if (details) {
        sortedAttributes = sort(attributes);
        for (String key : sortedAttributes.keySet()) {
            object = sortedAttributes.get(key);
            if (object != null) {
                out.println("\t" + key + ": " + object);
            }
        }
    } else {
        for (Attributes.Name attribute : ATTRIBUTE_NAMES) {
            string = attributes.getValue(attribute);
            if (StringUtils.isNotBlank(string)) {
                out.println("\t" + attribute + ": " + string);
            }
        }
    }
    out.println();
}

From source file:com.netflix.spinnaker.clouddriver.google.controllers.GoogleNamedImageLookupController.java

private static boolean matchesTagFilters(NamedImage namedImage, Map<String, String> tagFilters) {
    Map<String, String> tags = namedImage.tags;
    return tagFilters.keySet().stream().allMatch(tag -> tags.containsKey(tag.toLowerCase())
            && tags.get(tag.toLowerCase()).equalsIgnoreCase(tagFilters.get(tag)));
}

From source file:net.mlw.vlh.web.util.JspUtils.java

public static String toAttributesString(Map map) {
    StringBuffer sb = new StringBuffer();

    for (Iterator iter = map.keySet().iterator(); iter.hasNext();) {
        Object key = iter.next();
        sb.append(key).append("=\"").append(map.get(key)).append("\" ");
    }//from   www . j a va2  s  . c  o m

    return sb.toString();
}