List of usage examples for java.util LinkedHashMap LinkedHashMap
public LinkedHashMap()
From source file:com.gisgraphy.util.ConvertUtil.java
/** * Convert a java.util.List of LabelValue objects to a LinkedHashMap. * /* w ww . j ava2 s . c o m*/ * @param list * the list to convert * @return the populated map with the label as the key */ public static Map<String, String> convertListToMap(List<LabelValue> list) { Map<String, String> map = new LinkedHashMap<String, String>(); for (LabelValue option : list) { map.put(option.getLabel(), option.getValue()); } return map; }
From source file:Main.java
/** * Encodes a given object to url encoded string * @param name//from w ww.ja va2 s.c om * @param obj * @param objBuilder */ private static void encodeObjectAsQueryString(String name, Object obj, StringBuilder objBuilder) { try { if (obj == null) return; Map<String, Object> objectMap = new LinkedHashMap<String, Object>(); objectToMap(name, obj, objectMap, new HashSet<Integer>()); boolean hasParam = false; for (Map.Entry<String, Object> pair : objectMap.entrySet()) { String paramKeyValPair; //ignore nulls Object value = pair.getValue(); if (value == null) continue; hasParam = true; //load element value as string paramKeyValPair = String.format("%s=%s&", pair.getKey(), tryUrlEncode(value.toString())); objBuilder.append(paramKeyValPair); } //remove the last & if (hasParam) { objBuilder.setLength(objBuilder.length() - 1); } } catch (Exception ex) { } }
From source file:act.reports.controller.AbandonedVehicleReportControllerHelper.java
public List<Map<String, String>> convertAbandonedVehicleDetailsListAsExcelFormat( AbandonedVehicleDetailsList abandonedDetailsList) { logger.info("In convertAbandonedVehicleDetailsListAsExcelFormat(...) ..."); List<Map<String, String>> excelDetails = new ArrayList<Map<String, String>>(); try {// ww w . j ava 2 s . c o m for (int i = 0; i < abandonedDetailsList.getServiceCallDate().size(); i++) { Map<String, String> excelExpireData = new LinkedHashMap<String, String>(); excelExpireData.put("invoice", (abandonedDetailsList.getServiceCallDate().get(i) != null) ? abandonedDetailsList.getServiceCallDate().get(i) : ""); excelExpireData.put("serviceCalldate", (abandonedDetailsList.getOrDr().get(i) != null) ? abandonedDetailsList.getOrDr().get(i) : ""); excelExpireData.put("account", (abandonedDetailsList.getVin().get(i) != null) ? abandonedDetailsList.getVin().get(i) : ""); excelExpireData.put("reason", (abandonedDetailsList.getLicensePlate().get(i) != null) ? abandonedDetailsList.getLicensePlate().get(i) : ""); excelExpireData.put("year", (abandonedDetailsList.getTitleRequested().get(i) != null) ? abandonedDetailsList.getTitleRequested().get(i) : ""); excelExpireData.put("make", (abandonedDetailsList.getTitleReceived().get(i) != null) ? abandonedDetailsList.getTitleReceived().get(i) : ""); excelExpireData.put("model", (abandonedDetailsList.getReleased().get(i) != null) ? abandonedDetailsList.getReleased().get(i) : ""); excelDetails.add(excelExpireData); } } catch (Exception e) { logger.error(e); e.printStackTrace(); } return excelDetails; }
From source file:net.decix.jatlasx.ripe.atlas.json.JsonProbeBuilder.java
private void transformProbeDescription(ProbeDescription probe) { LinkedList<Map<String, Object>> probeDescription = new LinkedList<Map<String, Object>>(); LinkedList<Object> probes = new LinkedList<Object>(); Map<String, Object> def = new LinkedHashMap<String, Object>(); def.put(ApiKeys.target, probe.getTarget()); def.put(ApiKeys.ip_version, probe.getIp_version()); def.put(ApiKeys.timeout, probe.getTimeout()); def.put(ApiKeys.dcp, probe.getDescription()); def.put(ApiKeys.protocol, probe.getProtocol()); def.put(ApiKeys.resolve, probe.isResolve_on_probe()); def.put(ApiKeys.packets, probe.getPackets()); def.put(ApiKeys.size, probe.getSize()); def.put(ApiKeys.paris, probe.getParis()); def.put(ApiKeys.firstHop, probe.getFirsthop()); def.put(ApiKeys.dstOption, probe.getDestination_option_size()); def.put(ApiKeys.frag, probe.isDontfrag()); def.put(ApiKeys.type, probe.getType()); probeDescription.add(def);//from ww w.j a v a 2 s . c o m for (Probe currentProbe : probe.getList_of_probes()) { JSONObject jsonProbe = new JSONObject(); jsonProbe.put(ApiKeys.tags, currentProbe.getTags()); jsonProbe.put(ApiKeys.type, currentProbe.getType()); jsonProbe.put(ApiKeys.value, currentProbe.getId()); jsonProbe.put(ApiKeys.requested, currentProbe.getRequested()); probes.add(jsonProbe); } json.put(ApiKeys.def, probeDescription); json.put(ApiKeys.probes, probes); json.put(ApiKeys.oneoff, probe.isIs_oneoff()); jsonString = json.toString(); }
From source file:org.cloudfoundry.identity.uaa.oauth.UaaUserTokenConverter.java
@Override public Map<String, ?> convertUserAuthentication(Authentication authentication) { Map<String, Object> response = new LinkedHashMap<String, Object>(); if (authentication.getPrincipal() instanceof UaaPrincipal) { UaaPrincipal principal = (UaaPrincipal) authentication.getPrincipal(); response.put(USER_ID, principal.getId()); response.put(USER_NAME, principal.getName()); response.put(EMAIL, principal.getEmail()); }//from w ww. j av a 2s. c om return response; }
From source file:com.tussle.collision.ECBComponent.java
public ECBComponent() { ecbs = new LinkedHashMap<>(); }
From source file:am.ik.categolj2.infra.codelist.EnumCodeList.java
@Override public Map<String, String> asMap() { Map<String, String> codeList = new LinkedHashMap<String, String>(); Method method = ReflectionUtils.findMethod(enumClass, "values"); Enum<?>[] result = (Enum<?>[]) ReflectionUtils.invokeMethod(method, enumClass); for (Enum<?> e : result) { CodeListItem item = (CodeListItem) e; codeList.put(item.getCodeValue(), item.getCodeLabel()); }/*from w ww. j a v a 2 s .co m*/ return Collections.unmodifiableMap(codeList); }
From source file:net.letscarpool.web.HomeController.java
@RequestMapping(value = { "/", "/about" }, method = RequestMethod.GET) public Map<String, String> about() { // TODO: get version and build date from Gradle-generated // version.properties file Map<String, String> aboutMap = new LinkedHashMap<String, String>(); aboutMap.put("name", "Let's Carpool REST API"); aboutMap.put("version", "0.1-SNAPSHOT"); aboutMap.put("author", "Ross Coleman"); aboutMap.put("date", "2015-01-09"); return aboutMap; }
From source file:starterspringmvc4.web.HomeController.java
@RequestMapping(value = { "/", "/about" }, method = RequestMethod.GET) public Map<String, String> about() { // TODO: get version and build date from Gradle-generated // version.properties file Map<String, String> aboutMap = new LinkedHashMap<String, String>(); aboutMap.put("name", "Starter Spring MVC 4 Project"); aboutMap.put("version", "0.1-SNAPSHOT"); aboutMap.put("author", "Ross Coleman"); aboutMap.put("date", "2015-01-31"); return aboutMap; }
From source file:utils.WorkerManager.java
public WorkerManager(List<String> workerList) { workerMap = new LinkedHashMap<>(); write.lock();/*from w w w. ja v a 2 s .c o m*/ for (String workerURL : workerList) { try { String result = HttpComm.heartbeat(workerURL); if (result.equals("result:success")) workerMap.put(workerURL, "OK"); else workerMap.put(workerURL, "DOWN"); // catch http exception } catch (HttpHostConnectException | NoHttpResponseException ex) { WorkerManager.getWorkerMap().put(workerURL, "DOWN"); Logger.getLogger(TaskSubmitThread.class.getName()).log(Level.SEVERE, null, ex); } // catch general socket exception catch (SocketException ex) { WorkerManager.getWorkerMap().put(workerURL, "DOWN"); Logger.getLogger(TaskSubmitThread.class.getName()).log(Level.SEVERE, null, ex); } catch (Exception ex) { Logger.getLogger(TaskSubmitThread.class.getName()).log(Level.SEVERE, null, ex); } } write.unlock(); }