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:br.edimarmanica.weir2.rule.Loader.java

/**
 * //from w w w.  ja  va 2s  . c om
 * @param rule
 * @param entityIDs Map<page,entity>
 * @return Map<entity, value> value extracted for each entity or null if a value was not extracted for that entity
 */
public static Map<String, String> loadEntityValues(File rule, Map<String, String> entityIDs) {
    Map<String, String> pageValues = loadPageValues(rule, false);

    Map<String, String> entityValues = new HashMap<>();
    for (String page : entityIDs.keySet()) {
        entityValues.put(page, pageValues.get(page));
    }
    return entityValues;
}

From source file:de.thorstenberger.taskmodel.view.AJAXSaveStudentAnnotationAction.java

public static void logPostData(HttpServletRequest request, Tasklet tasklet) {
    Map vars = request.getParameterMap();
    StringBuffer parameters = new StringBuffer();
    Iterator keys = vars.keySet().iterator();
    while (keys.hasNext()) {
        String key = (String) keys.next();
        parameters.append(key + "=" + ((String[]) vars.get(key))[0] + "\n");
    }/*  w ww .  ja  v  a2 s  .  co  m*/
    tasklet.logPostData("StudentAnnotation: posted parameters:\n" + parameters.toString(),
            request.getRemoteAddr());
}

From source file:ke.co.tawi.babblesms.server.utils.StringUtil.java

/**
 * Converts a {@link Map} into a String, for example for logging purposes
 * /*from   w  ww .  j  a v  a  2  s.c o  m*/
 * @param map
 * @return a String representation of a Map.
 */
public static String objMapToString(Map map) {
    StringBuilder stringBuilder = new StringBuilder();

    for (Object key : map.keySet()) {
        if (stringBuilder.length() > 0) {
            stringBuilder.append("&");
        }
        String value = map.get(key).toString();

        stringBuilder.append(key.toString());
        stringBuilder.append("=");
        stringBuilder.append(value.toString());
    }

    return stringBuilder.toString();
}

From source file:com.dinochiesa.edgecallouts.util.CalloutUtil.java

public static Map<String, String> genericizeMap(Map properties) {
    // convert an untyped Map to a generic map
    Map<String, String> m = new HashMap<String, String>();
    Iterator iterator = properties.keySet().iterator();
    while (iterator.hasNext()) {
        Object key = iterator.next();
        Object value = properties.get(key);
        if ((key instanceof String) && (value instanceof String)) {
            m.put((String) key, (String) value);
        }// ww  w. ja  v a  2 s .co  m
    }
    return Collections.unmodifiableMap(m);
}

From source file:Main.java

public static <K, V> List<K> getKeyListByIndexes(Map<K, V> map, int[] indexes) {
    if ((indexes == null) || (indexes.length == 0)) {
        return null;
    }/*www .j  a  v  a2  s.c  o m*/
    List<K> keyList = new ArrayList<K>(indexes.length);

    int i = 0;
    for (K key : map.keySet()) {
        for (int index : indexes) {
            if (i == index) {
                keyList.add(key);
            }
        }
        i++;
    }
    return keyList;
}

From source file:org.focusns.common.web.page.config.PageConfigKey.java

public static String generateKey(String path, Map<String, ?> paramsMap) {
    if (paramsMap.isEmpty()) {
        return path;
    }//from   w w w. j  a v a  2s  . com
    //
    StringBuilder sb = new StringBuilder(path);
    for (String paramName : paramsMap.keySet()) {
        if (PARAM_NAMES_EXCLUDE.contains(paramName)) {
            continue;
        }
        //
        String paramValue = String.valueOf(paramsMap.get(paramName));
        if (StringUtils.hasText(paramValue)) {
            sb.append(paramName).append("=").append(paramsMap.get(paramName));
        }
    }
    //
    return sb.toString();
}

From source file:hu.petabyte.redflags.engine.util.MappingUtils.java

public static synchronized boolean setDeepProperties(BeanWrapper wrapper, Map<String, String> properties) {
    boolean r = true;
    for (String property : properties.keySet()) {
        String value = properties.get(property);
        r = r & setDeepProperty(wrapper, property, value);
    }/*from  w  ww .j a  v a 2  s . c om*/
    return r;
}

From source file:com.ec2box.common.util.AppConfig.java

/**
 * gets the property from config and replaces placeholders
 *
 * @param name property name/*www  .  j  a va2 s .c  om*/
 * @param replacementMap name value pairs of place holders to replace
 * @return configuration property
 */
public static String getProperty(String name, Map<String, String> replacementMap) {

    String value = prop.getString(name);
    //iterate through map to replace text
    Set<String> keySet = replacementMap.keySet();
    for (String key : keySet) {
        //replace values in string
        String rVal = replacementMap.get(key);
        value = value.replace("${" + key + "}", rVal);
    }
    return value;
}

From source file:com.bluexml.side.build.tools.graph.JungConverter.java

public static Graph<Componant, String> convert(Map<Componant, Set<Componant>> tree) {
    logger.info("JungConverter.convert() input :");
    logger.info("nb Componants :" + tree.keySet().size());

    int c = 0;//ww  w.  j a  v a 2 s  .  c o m
    Graph<Componant, String> g = new DirectedSparseMultigraph<Componant, String>();

    for (Map.Entry<Componant, Set<Componant>> iterable_element : tree.entrySet()) {
        Componant com = iterable_element.getKey();
        Set<Componant> links = iterable_element.getValue();
        for (Componant componant : links) {

            g.addEdge(c + "-", com, componant);
            c++;
        }
    }
    printGraphStats(g, "tree -> graph");

    return g;
}

From source file:com.ieasy.basic.util.CookieSupport.java

/**
 * cookies/*from   w  ww  .ja  va 2 s.c  om*/
 * 
 * @param response
 * @param cookieParams
 * @param maxAge
 */
public static final void writeCookies(HttpServletResponse response, Map<String, String> cookieParams,
        int maxAge) {
    if (cookieParams == null || cookieParams.size() == 0)
        return;
    Set<String> keySet = cookieParams.keySet();
    for (String key : keySet) {
        Cookie cookie = new Cookie(key, cookieParams.get(key));
        cookie.setMaxAge(maxAge);
        response.addCookie(cookie);
    }
}