List of usage examples for java.util Map size
int size();
From source file:circleplus.app.http.AbstractHttpApi.java
private static String createStringParams(Map<String, String> params) { if (params == null || params.size() == 0) { return ""; }//from w ww .j a v a 2 s . co m StringBuilder sb = new StringBuilder(); sb.append('?'); Set<String> keys = params.keySet(); int i = 0; for (String key : keys) { String value = params.get(key); if (value != null) { if (i > 0) { sb.append('&'); } sb.append(key); sb.append('='); sb.append(params.get(key)); } i++; } if (D) Log.d(TAG, "parse request params: " + sb.toString()); return sb.toString(); }
From source file:com.cubeia.backoffice.report.RequestBean.java
public static RequestBean parse(HttpServletRequest req) { /*//from w w w. j av a 2 s . c om * Trim the path (which becomes the report name) */ String path = trim(req.getPathInfo()); /* * check the format and do default if needed */ String form = req.getParameter("format"); if (form == null) { form = Format.CSV.name(); } /* * Convert parameter map to a simple string-string map */ @SuppressWarnings("rawtypes") Map params = req.getParameterMap(); Map<String, String> tmp = new HashMap<String, String>(params.size()); for (Object key : params.keySet()) { tmp.put(key.toString(), req.getParameter(key.toString())); } /* * Continue parsing */ return parse(path, tmp, form); }
From source file:Main.java
/** * Returns map with rendering hints from a Graphics instance. * * @param g2d Graphics instance//ww w .j av a2 s . c o m * @param hintsToSave map of RenderingHint key-values * @param savedHints map to save hints into * @return map with rendering hints from a Graphics instance */ private static Map getRenderingHints(final Graphics2D g2d, final Map hintsToSave, Map savedHints) { if (savedHints == null) { savedHints = new RenderingHints(null); } else { savedHints.clear(); } if (hintsToSave == null || hintsToSave.size() == 0) { return savedHints; } final Set objects = hintsToSave.keySet(); for (final Object o : objects) { final RenderingHints.Key key = (RenderingHints.Key) o; final Object value = g2d.getRenderingHint(key); if (value != null) { savedHints.put(key, value); } } return savedHints; }
From source file:com.android.volley.toolbox.HttpClientStack.java
@SuppressWarnings("unused") private static List<NameValuePair> getPostParameterPairs(Map<String, String> postParams) { List<NameValuePair> result = new ArrayList<NameValuePair>(postParams.size()); for (String key : postParams.keySet()) { result.add(new BasicNameValuePair(key, postParams.get(key))); }/* w w w . ja va 2 s .c om*/ return result; }
From source file:Main.java
/** * Check whether two {@link Map} equal./* w w w . ja v a 2 s . c o m*/ */ public static <T> boolean equals(Map<T, byte[]> map, Map<T, byte[]> otherMap) { if (map == otherMap) { return true; } if (map == null || otherMap == null) { return false; } if (map.size() != otherMap.size()) { return false; } Set<T> keys = map.keySet(); if (!keys.equals(otherMap.keySet())) { return false; } for (T key : keys) { if (!Objects.deepEquals(map.get(key), otherMap.get(key))) { return false; } } return true; }
From source file:Main.java
/** * Check whether two {@link Map} equal.//from w w w . j a v a 2 s . co m */ static <T> boolean equals(Map<T, byte[]> map, Map<T, byte[]> otherMap) { if (map == otherMap) { return true; } if (map == null || otherMap == null) { return false; } if (map.size() != otherMap.size()) { return false; } Set<T> keys = map.keySet(); if (!keys.equals(otherMap.keySet())) { return false; } for (T key : keys) { if (!Objects.deepEquals(map.get(key), otherMap.get(key))) { return false; } } return true; }
From source file:com.bluexml.xforms.controller.navigation.NavigationSessionListener.java
/** * Gets the page id./* ww w.j a v a 2 s .c o m*/ * * @param sessionId * the session id * * @return the page id */ public static String getPageId(String sessionId) { Map<String, NavigationPath> pages = getNavigationPathFromSession(sessionId); Integer i = pages.size(); do { i++; } while (pages.get(i.toString()) != null); return i.toString(); }
From source file:com.netsteadfast.greenstep.base.sys.UserCurrentCookie.java
public static Map<String, String> getCurrentData(HttpServletRequest request) { Map<String, String> dataMap = new HashMap<String, String>(); try {/*from w w w . j a v a 2 s .c o m*/ Cookie[] cookies = request.getCookies(); for (int i = 0; cookies != null && dataMap.size() == 0 && i < cookies.length; i++) { Cookie cookie = cookies[i]; if (cookie.getName().equals(Constants.APP_SITE_CURRENTID_COOKIE_NAME)) { if (StringUtils.isBlank(cookie.getValue())) { return dataMap; } String decVal = SimpleUtils.deHex(cookie.getValue()); decVal = EncryptorUtils.decrypt(Constants.getEncryptorKey1(), Constants.getEncryptorKey2(), decVal); String tmp[] = decVal.split(Constants.ID_DELIMITER); if (tmp != null && tmp.length == 4) { dataMap.put("currentId", tmp[0]); dataMap.put("sessionId", tmp[1]); dataMap.put("account", tmp[2]); dataMap.put("lang", tmp[3]); } } } } catch (Exception e) { e.printStackTrace(); } return dataMap; }
From source file:org.apache.gobblin.HttpTestUtils.java
public static void assertEqual(RestRequestBuilder actual, RestRequestBuilder expect) throws IOException { // Check entity ByteString actualEntity = actual.getEntity(); ByteString expectedEntity = expect.getEntity(); if (actualEntity == null) { Assert.assertTrue(expectedEntity == null); } else {//from w w w. j a v a 2 s.c o m Assert.assertEquals(actualEntity.length(), expectedEntity.length()); Assert.assertEquals(actualEntity.asString(StandardCharsets.UTF_8), expectedEntity.asString(StandardCharsets.UTF_8)); } // Check request RestRequest actualRequest = actual.build(); RestRequest expectedRequest = expect.build(); Assert.assertEquals(actualRequest.getMethod(), expectedRequest.getMethod()); Assert.assertEquals(actualRequest.getURI().toString(), expectedRequest.getURI().toString()); Map<String, String> actualHeaders = actualRequest.getHeaders(); Map<String, String> expectedHeaders = expectedRequest.getHeaders(); Assert.assertEquals(actualHeaders.size(), expectedHeaders.size()); for (String key : actualHeaders.keySet()) { Assert.assertEquals(actualHeaders.get(key), expectedHeaders.get(key)); } }
From source file:com.clustercontrol.util.EndpointManager.java
public static List<EndpointUnit> getActiveManagerList() { Map<String, EndpointUnit> activeManagerMap = getInstance().getActiveManagerMap(); return (0 < activeManagerMap.size()) ? new ArrayList<EndpointUnit>(activeManagerMap.values()) : new ArrayList<EndpointUnit>(); }