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:com.snapdeal.archive.util.ArchivalUtil.java

/**
 * Returns the set of property with name <code>propertyName</code>, of type  <code>propertyClass</code> from the list of object
 * @param objects// w  w  w.  ja v  a 2s .c o m
 * @param propertyName
 * @param propertyClass
 * @return Set<K>, where K is of class <code>propertyClass</code>, 
 * @return empty set if either list is empty or if these exception occurs IllegalAccessException,InvocationTargetException,NoSuchMethodException
 */
public static <K, T> Set<K> getPropertySet(Set<T> objects, String propertyName, Class<K> propertyClass) {
    Map<K, T> map = getPropertyObjectMap(objects, propertyName, propertyClass);
    return map.keySet();
}

From source file:com.snapdeal.archive.util.ArchivalUtil.java

/**
 * Returns the set of property with name <code>propertyName</code>, of type  <code>propertyClass</code> from the list of object
 * @param objects/*from  w  ww.  j a v  a  2 s  .c om*/
 * @param propertyName
 * @param propertyClass
 * @return Set<K>, where K is of class <code>propertyClass</code>, 
 * @return empty set if either list is empty or if these exception occurs IllegalAccessException,InvocationTargetException,NoSuchMethodException
 */
public static <K, T> Set<K> getPropertySet(List<T> objects, String propertyName, Class<K> propertyClass) {
    Map<K, T> map = getPropertyObjectMap(objects, propertyName, propertyClass);
    return map.keySet();
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.individuallist.IndividualListResultsUtils.java

private static void dumpParametersFromRequest(VitroRequest vreq) {
    Map<String, String[]> pMap = vreq.getParameterMap();
    for (String name : pMap.keySet()) {
        for (String value : pMap.get(name)) {
            log.debug("value for " + name + ": '" + value + "'");
        }/*from  w  w w . j ava  2  s. c o  m*/
    }
}

From source file:demo.vmware.commands.CommandRegionUtils.java

/**
 * this is an argument for making this a singleton bean instead of static. We cold then make this
 * ApplicationContextAware// w w w.j a  va  2  s.c  o m
 * 
 * @param mainContext
 * @param targetRegionName
 * @return
 */
public static GemfireTemplate findTemplateForRegionName(ApplicationContext mainContext,
        String targetRegionName) {
    Map<String, GemfireTemplate> allRegionTemplates = getAllGemfireTemplates(mainContext);
    for (String key : allRegionTemplates.keySet()) {
        GemfireTemplate oneTemplate = allRegionTemplates.get(key);
        if (oneTemplate.getRegion().getName().equals(targetRegionName)) {
            return oneTemplate;
        }
    }
    throw new IllegalArgumentException("region not found " + targetRegionName);
}

From source file:com.google.mr4c.hadoop.HadoopUtils.java

/**
  * @param varMap apply environment variable values from this map
  * @param vars apply existing values of these environment variables
*///  w w  w . java  2 s.  c om
public static void applyEnvironmentVariables(JobConf conf, Map<String, String> varMap, List<String> vars) {
    Map<String, String> allMap = new HashMap<String, String>(System.getenv());
    allMap.keySet().retainAll(vars); // only the env we wanted
    allMap.putAll(varMap);
    List<String> assigns = new ArrayList<String>();
    for (String var : allMap.keySet()) {
        String val = allMap.get(var);
        if (!StringUtils.isEmpty(val)) {
            assigns.add(var + "=" + val);
        }
    }
    String value = StringUtils.join(assigns, ", ");
    conf.set(JobConf.MAPRED_MAP_TASK_ENV, value);
    conf.set(JobConf.MAPRED_REDUCE_TASK_ENV, value);
}

From source file:com.datasalt.utils.commons.URLUtils.java

/**
 * build a url from a hashtable and a base.  Not tested but may be useful for building urls from 
 * other data.  Also might be usefull for testing later on .
 * @param base/*from  w ww  .j  a v a 2 s .co m*/
 * @param pars
 */
@SuppressWarnings("rawtypes")
public static String getUrlFromParameters(String base, Map pars) {
    StringBuffer s = new StringBuffer(base);
    if (pars.size() > 0)
        s.append("?");
    for (Object k : pars.keySet()) {
        s.append(k);
        s.append("=");
        s.append(pars.get(k));
    }
    return s.toString();
}

From source file:com.boyuanitsm.pay.alipay.util.AlipayCore.java

/** 
 * ??=???&??/*from  w ww.  j  a v a 2  s  .c  o  m*/
 * @param params ????
 * @return ?
 */
public static String createLinkString(Map<String, String> params) {

    List<String> keys = new ArrayList<String>(params.keySet());
    Collections.sort(keys);

    String prestr = "";

    for (int i = 0; i < keys.size(); i++) {
        String key = keys.get(i);
        String value = params.get(key);

        if (i == keys.size() - 1) {//??&
            prestr = prestr + key + "=" + value;
        } else {
            prestr = prestr + key + "=" + value + "&";
        }
    }

    return prestr;
}

From source file:com.threewks.thundr.proxy.http.Response.java

public static Response from(HttpResponse response) {
    int status = response.getStatus();

    Map<String, String> headers = new HashMap<String, String>();
    Map<String, List<String>> responseHeaders = response.getHeaders();
    for (String name : responseHeaders.keySet()) {
        if (name == null) {
            continue;
        }// w w  w .  j a  v a2 s . c om
        String value = StringUtils.join(responseHeaders.get(name), ",");
        headers.put(name, value);
    }

    byte[] body = response.getBodyAsBytes();
    if (body != null && body.length == 0) {
        body = null;
    }

    return new Response().status(status).headers(headers).body(body);
}

From source file:com.mashape.unirest.http.utils.MapUtil.java

public static List<NameValuePair> getList(Map<String, Object> parameters) {
    List<NameValuePair> result = new ArrayList<NameValuePair>();
    if (parameters != null) {

        Set<String> keySet = parameters.keySet();
        for (String key : keySet) {
            result.add(new BasicNameValuePair(key, parameters.get(key).toString()));
        }/*from w  w w .  j  ava2  s. c  o  m*/

    }
    return result;
}

From source file:Main.java

public static Map<Object, Object> copySafelyToObjectToObjectMap(Map<?, ?> map) {
    Map<Object, Object> castedCopy = new LinkedHashMap<Object, Object>();

    if (map == null) {
        return castedCopy;
    }/*from w ww  .j  a  v  a  2 s  . c  o  m*/

    Iterator<?> it = map.keySet().iterator();
    while (it.hasNext()) {
        Object nextKey = it.next();
        castedCopy.put(nextKey, map.get(nextKey));
    }
    return castedCopy;
}