List of usage examples for java.util Map keySet
Set<K> keySet();
From source file:Main.java
public static Map<String, String> paraFilter(Map<String, String> para) { Map<String, String> result = new HashMap<String, String>(); if (para == null || para.size() <= 0) { return result; }// www . j ava 2 s .c o m for (String key : para.keySet()) { String value = para.get(key); if (value == null || value.equals("") || key.equalsIgnoreCase(SIGNATURE) || key.equalsIgnoreCase(SIGN_METHOD)) { continue; } result.put(key, value); } return result; }
From source file:hu.petabyte.redflags.engine.util.MappingUtils.java
public static void normalizeMapKeys(Map<String, String> map) { Set<String> keys = new LinkedHashSet<String>(map.keySet()); for (String key : keys) { String value = map.get(key); map.remove(key);//from w w w .ja v a 2 s . c o m key = key.replaceAll("0", "."); map.put(key, value); } }
From source file:costumetrade.common.util.HttpClientUtils.java
/** * @param url/*w w w .j a va2 s .c o m*/ * @param ? * @return */ public static String doPost(String url, Map<String, Object> params) { List<BasicNameValuePair> nvps = new ArrayList<>(params.size()); for (String key : params.keySet()) { Object value = params.get(key); if (value != null) { nvps.add(new BasicNameValuePair(key, value.toString())); } } return doPost(url, new UrlEncodedFormEntity(nvps, StandardCharsets.UTF_8)); }
From source file:jef.testbase.JefTester.java
private static Entry<Integer, Integer> getSmall(Map<Integer, Integer> data) { int min = Integer.MAX_VALUE; Integer key = null;/* ww w . j av a 2 s. com*/ for (Integer i : data.keySet()) { if (data.get(i) < min) { key = i; min = data.get(i); } } return new Entry<Integer, Integer>(key, data.remove(key)); }
From source file:Main.java
public static Document createXMLResult(String rootName, Map<String, String> map, Document d) { try {/*from w w w . j a v a2 s . c om*/ Element r = d.createElement(rootName); d.appendChild(r); for (String elementName : map.keySet()) { Element eltName = d.createElement(elementName); eltName.appendChild(d.createTextNode(map.get(elementName))); r.appendChild(eltName); } d.normalizeDocument(); return d; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:Main.java
/** * Utility method that return a String representation of a map. The elements * will be represented as "key = value"//from ww w. j a v a2 s . c o m * * @param map * The map to transform to a string * @return A csv string */ public static final String mapToString(Map map, String tabs) { if ((map == null) || (map.size() == 0)) { return ""; } StringBuffer sb = new StringBuffer(); Iterator iter = map.keySet().iterator(); while (iter.hasNext()) { Object key = iter.next(); sb.append(tabs); sb.append(key); Object value = map.get(key); sb.append(" = '").append(value.toString()).append("'\n"); } return sb.toString(); }
From source file:com.iflytek.android.framework.volley.toolbox.HttpClientStack.java
private static void addHeaders(HttpUriRequest httpRequest, Map<String, String> headers) { for (String key : headers.keySet()) { VolleyLog.d("2:" + key + ";" + headers.get(key)); httpRequest.setHeader(key, headers.get(key)); }//from ww w.jav a2 s .c om }
From source file:org.apache.hive.service.auth.HttpAuthUtils.java
/** * Parses a cookie token to retrieve client user name. * @param tokenStr Token String./* www .j a v a 2s . c o m*/ * @return A valid user name if input is of valid format, else returns null. */ public static String getUserNameFromCookieToken(String tokenStr) { Map<String, String> map = splitCookieToken(tokenStr); if (!map.keySet().equals(COOKIE_ATTRIBUTES)) { LOG.error("Invalid token with missing attributes " + tokenStr); return null; } return map.get(COOKIE_CLIENT_USER_NAME); }
From source file:Main.java
public static String httpPost(String url, Map<String, String> params) { List<NameValuePair> lst = new ArrayList<NameValuePair>(); if (params != null) { Iterator<String> keyItors = params.keySet().iterator(); while (keyItors.hasNext()) { String key = keyItors.next(); String val = params.get(key); lst.add(new BasicNameValuePair(key, val)); }//from ww w .j a v a 2s. c o m } return httpPost(url, lst); }
From source file:Main.java
public static HttpEntity buildUrlEncodedFormEntity(Map<String, String> keyValuePairs) { List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>(); if (keyValuePairs != null) { Set<String> keys = keyValuePairs.keySet(); for (String key : keys) { String value = keyValuePairs.get(key); BasicNameValuePair param = new BasicNameValuePair(key, value); params.add(param);// w w w .j av a 2 s .co m } } try { return new UrlEncodedFormEntity(params); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; }