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:Main.java

private static String getStringOfClassList(Map<String, Integer> classes) {
    String result = "";
    for (String className : classes.keySet()) {
        Integer occurences = classes.get(className);
        if (!result.isEmpty())
            result += ", ";
        result += className + ": " + occurences;
    }//w  w  w  . ja  v  a 2 s. c  om

    return result;

}

From source file:Main.java

public static String createXml(Map<String, Object> map) {
    StringBuffer sb = new StringBuffer();
    for (String key : map.keySet()) {
        sb.append("<").append(key).append(">");
        sb.append(map.get(key));/*from w  ww  . ja va  2  s .com*/
        sb.append("</").append(key).append(">");
    }
    return sb.toString();
}

From source file:Main.java

public static <K, V> Map<K, V> mutableDeepCopyOfMap(Map<K, V> src) {
    Map<K, V> result = new HashMap<K, V>();
    for (K key : src.keySet()) {
        result.put(key, (V) deepCopyIfNeeded(src.get(key)));
    }/*  w  w  w . j a va 2  s  .c  o  m*/
    return result;
}

From source file:com.microsoft.azure.shortcuts.services.samples.OSImagesSample.java

public static void test(Azure azure) throws Exception {
    final String imageName = "b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-12_04_5_LTS-amd64-server-20150413-en-us-30GB";

    // List the OS images
    Map<String, OSImage> osImages = azure.osImages().asMap();
    Set<String> osImageNames = osImages.keySet();

    System.out.println("Available OS images: \n\t" + StringUtils.join(osImageNames, ",\n\t"));

    // Get information about a specific OS image
    OSImage osImage = azure.osImages(imageName);
    printOsImage(osImage);//from   w  ww  .  j  a v a2s.  c  o m
}

From source file:Main.java

public static <A, B> String mapToString(Map<A, B> m) {
    StringBuilder sb = new StringBuilder();
    Set<A> keys = m.keySet();
    sb.append("{");
    for (A key : keys) {
        sb.append("(").append(key).append(",").append(m.get(key)).append(")");
    }/*from   w  w w.jav a 2 s.c  o m*/
    sb.append("}");
    return sb.toString();
}

From source file:Main.java

public static Bundle toBundle(Map<String, ? extends Parcelable> input) {
    Bundle output = new Bundle();
    for (String key : input.keySet()) {
        output.putParcelable(key, input.get(key));
    }//from  w  ww. j av  a 2  s.c om
    return output;
}

From source file:Main.java

public static String getMapAppendUrl(Map<String, String> params) {
    StringBuffer sb1 = new StringBuffer();
    for (String key : params.keySet()) {
        sb1.append(key);/*from w  w w .j  a v a 2  s  . co  m*/
        sb1.append("=");
        sb1.append((String) params.get(key));
        sb1.append("&");
    }
    sb1.deleteCharAt(sb1.length() - 1);
    return sb1.toString();
}

From source file:Main.java

public static String StringFromMap(Map<String, String> map) {
    StringBuilder sb = new StringBuilder();
    Set<String> set = map.keySet();

    for (Iterator iter = set.iterator(); iter.hasNext();) {
        String key = (String) iter.next();
        sb.append(key + "    " + map.get(key) + "\n");
    }/*from   w w w  .  j a v  a 2s.c  o  m*/

    return sb.toString();
}

From source file:Main.java

public static ContentValues getContentValuesFromMap(Map<String, String> contentValues) {
    ContentValues values = new ContentValues();
    for (String s : contentValues.keySet()) {
        values.put(s, contentValues.get(s));
    }// w  w  w  . j  a  va2  s .  com
    return values;
}

From source file:Main.java

/**
 * conver map to params string/*w  ww  .j a  va 2s  .  c  om*/
 * @param map
 * @return
 */
public static String covertMapToParamStr(Map<String, String> map) {
    StringBuilder sb = new StringBuilder();
    Set<String> set = map.keySet();
    for (String key : set) {
        sb.append("&");
        sb.append(key).append("=").append(map.get(key));
    }

    return sb.toString().substring(1);
}