List of usage examples for java.util LinkedHashMap LinkedHashMap
public LinkedHashMap()
From source file:io.spring.initializr.service.info.CloudFoundryInfoContributor.java
@Override public void contribute(Info.Builder builder) { String applicationName = this.environment.getProperty("vcap.application.name"); if (StringUtils.hasText(applicationName)) { Map<String, String> details = new LinkedHashMap<>(); details.put("name", applicationName); builder.withDetail("app", details); }/*www . ja va2 s. c o m*/ }
From source file:net.sf.ehcache.store.FifoMemoryStore.java
/** * Constructor for the FifoMemoryStore object. * <p/>//w w w . j a v a2 s.com * First tries to use {@link java.util.LinkedHashMap}. If not found uses * Jakarta Commons collections. */ public FifoMemoryStore(Ehcache cache, Store diskStore) { super(cache, diskStore); map = new LinkedHashMap(); }
From source file:com.linkedin.flashback.http.HttpUtilities.java
/** * Converts a URL / POST parameter string to an ordered map of key / value pairs * @param paramsString the URL-encoded &-delimited string of key / value pairs * @return a LinkedHashMap representing the decoded parameters */// w ww .j av a2s . co m static public Map<String, String> stringToUrlParams(String paramsString, String charset) throws UnsupportedEncodingException { Map<String, String> params = new LinkedHashMap<>(); if (!StringUtils.isBlank(paramsString)) { for (String param : paramsString.split("&")) { String[] keyValue = param.split("="); assert (keyValue.length > 0); if (keyValue.length == 1) { params.put(URLDecoder.decode(keyValue[0], charset), ""); } else { params.put(URLDecoder.decode(keyValue[0], charset), URLDecoder.decode(keyValue[1], charset)); } } } return params; }
From source file:com.sugaronrest.restapicalls.methodcalls.InsertLinkedEntry.java
/** * Updates entry [SugarCRM REST method - set_entry]. * * @param url REST API Url./*from w w w . j a v a 2 s .c o m*/ * @param sessionId Session identifier. * @param moduleName SugarCRM module name. * @param entity The entity object to update. * @param selectFields Selected field list. * @return ReadEntryResponse object. */ public static UpdateEntryResponse run(String url, String sessionId, String moduleName, Object entity, List<String> selectFields) { UpdateEntryResponse updateEntryResponse = null; ErrorResponse errorResponse = null; String jsonRequest = new String(); String jsonResponse = new String(); ObjectMapper mapper = JsonObjectMapper.getMapper(); try { Map<String, Object> requestData = new LinkedHashMap<String, Object>(); requestData.put("session", sessionId); requestData.put("module_name", moduleName); Map<String, Object> fields = EntityToNameValueList(entity, selectFields); fields.remove("id"); requestData.put("name_value_list", fields); String jsonRequestData = mapper.writeValueAsString(requestData); Map<String, Object> request = new LinkedHashMap<String, Object>(); request.put("method", "set_entry"); request.put("input_type", "json"); request.put("response_type", "json"); request.put("rest_data", requestData); jsonRequest = mapper.writeValueAsString(request); request.put("rest_data", jsonRequestData); HttpResponse response = Unirest.post(url).fields(request).asString(); if (response == null) { updateEntryResponse = new UpdateEntryResponse(); errorResponse = ErrorResponse.format("An error has occurred!", "No data returned."); updateEntryResponse.setStatusCode(HttpStatus.SC_BAD_REQUEST); updateEntryResponse.setError(errorResponse); } else { jsonResponse = response.getBody().toString(); if (StringUtils.isNotBlank(jsonResponse)) { // First check if we have an error errorResponse = ErrorResponse.fromJson(jsonResponse); if (errorResponse == null) { updateEntryResponse = mapper.readValue(jsonResponse, UpdateEntryResponse.class); } } if (updateEntryResponse == null) { updateEntryResponse = new UpdateEntryResponse(); updateEntryResponse.setError(errorResponse); updateEntryResponse.setStatusCode(HttpStatus.SC_OK); if (errorResponse != null) { updateEntryResponse.setStatusCode(errorResponse.getStatusCode()); } } else { updateEntryResponse.setStatusCode(HttpStatus.SC_OK); } } } catch (Exception exception) { updateEntryResponse = new UpdateEntryResponse(); errorResponse = ErrorResponse.format(exception, exception.getMessage()); updateEntryResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR); errorResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR); updateEntryResponse.setError(errorResponse); } updateEntryResponse.setJsonRawRequest(jsonRequest); updateEntryResponse.setJsonRawResponse(jsonResponse); return updateEntryResponse; }
From source file:com.sugaronrest.restapicalls.methodcalls.InsertRelationship.java
/** * Insert relationship [SugarCRM REST method - set_relationship]. * /*from w w w . j av a 2 s . com*/ * @param url * @param sessionId * @param moduleName * @param moduleId * @param linkFieldName * @param relatedIds * @param selectFields * @return */ public static InsertRelationshipResponse run(String url, String sessionId, String moduleName, String moduleId, String linkFieldName, List<String> relatedIds, List<String> selectFields) { InsertRelationshipResponse insertRelationship = null; ErrorResponse errorResponse = null; String jsonRequest = new String(); String jsonResponse = new String(); ObjectMapper mapper = JsonObjectMapper.getMapper(); try { Map<String, Object> requestData = new LinkedHashMap<String, Object>(); requestData.put("session", sessionId); requestData.put("module_name", moduleName); requestData.put("module_id", moduleId); requestData.put("link_field_name", linkFieldName); requestData.put("related_ids", relatedIds); requestData.put("deleted", 0); String jsonRequestData = mapper.writeValueAsString(requestData); Map<String, Object> request = new LinkedHashMap<String, Object>(); request.put("method", "set_relationship"); request.put("input_type", "json"); request.put("response_type", "json"); request.put("rest_data", requestData); jsonRequest = mapper.writeValueAsString(request); request.put("rest_data", jsonRequestData); HttpResponse response = Unirest.post(url).fields(request).asString(); if (response == null) { insertRelationship = new InsertRelationshipResponse(); errorResponse = ErrorResponse.format("An error has occurred!", "No data returned."); insertRelationship.setStatusCode(HttpStatus.SC_BAD_REQUEST); insertRelationship.setError(errorResponse); } else { jsonResponse = response.getBody().toString(); if (StringUtils.isNotBlank(jsonResponse)) { // First check if we have an error errorResponse = ErrorResponse.fromJson(jsonResponse); if (errorResponse == null) { insertRelationship = mapper.readValue(jsonResponse, InsertRelationshipResponse.class); } } if (insertRelationship == null) { insertRelationship = new InsertRelationshipResponse(); insertRelationship.setError(errorResponse); insertRelationship.setStatusCode(HttpStatus.SC_OK); if (errorResponse != null) { insertRelationship.setStatusCode(errorResponse.getStatusCode()); } } else { insertRelationship.setStatusCode(HttpStatus.SC_OK); } } } catch (Exception exception) { insertRelationship = new InsertRelationshipResponse(); errorResponse = ErrorResponse.format(exception, exception.getMessage()); insertRelationship.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR); errorResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR); insertRelationship.setError(errorResponse); } insertRelationship.setJsonRawRequest(jsonRequest); insertRelationship.setJsonRawResponse(jsonResponse); return insertRelationship; }
From source file:com.k42b3.quantum.worker.TwitterWorker.java
@Override public Map<String, String> getParameters() { LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>(); parameters.put("consumer_key", "Consumer key"); parameters.put("consumer_secret", "Consumer secret"); parameters.put("token", "Token"); parameters.put("token_secret", "Token secret"); return parameters; }
From source file:de.comci.bitmap.JooqDimensionBuilder.java
public JooqDimensionBuilder(Connection conn, String table, SQLDialect dialect) { this.connection = conn; this.table = table; // db context ctx = DSL.using(connection, dialect); // collect fields from table availableFields = new LinkedHashMap<>(); Result<Record> singleRow = ctx.selectFrom(DSL.tableByName(table)).limit(1).fetch(); for (Field f : singleRow.fields()) { availableFields.put(f.getName(), new Column(f.getName(), f.getType(), f)); }/*from w ww. j ava 2s . com*/ LOG.trace(String.format("%d columns found in table '%s'", availableFields.size(), table)); }
From source file:org.xwiki.velocity.tools.URLTool.java
/** * Parse a query string into a map of key-value pairs. * /* w w w .j av a2 s . com*/ * @param query query string to be parsed * @return a mapping of parameter names to values suitable e.g. to pass into {@link EscapeTool#url(Map)} */ public Map<String, List<String>> parseQuery(String query) { Map<String, List<String>> queryParams = new LinkedHashMap<>(); if (query != null) { for (NameValuePair params : URLEncodedUtils.parse(query, StandardCharsets.UTF_8)) { String name = params.getName(); List<String> values = queryParams.get(name); if (values == null) { values = new ArrayList<>(); queryParams.put(name, values); } values.add(params.getValue()); } } return queryParams; }
From source file:com.allinfinance.startup.init.MenuInfoUtil.java
/** * ??/*from ww w.ja v a2s . c om*/ */ @SuppressWarnings("unchecked") public static void init() { String hql = "from com.allinfinance.po.TblFuncInf t where t.FuncType in ('0','1','2') order by t.FuncId"; ICommQueryDAO commQueryDAO = (ICommQueryDAO) ContextUtil.getBean("CommQueryDAO"); List<TblFuncInf> funcInfList = commQueryDAO.findByHQLQuery(hql); for (int i = 0, n = funcInfList.size(); i < n; i++) { TblFuncInf tblFuncInf = funcInfList.get(i); Map<String, Object> menuBean = new LinkedHashMap<String, Object>(); if (StringUtil.isEmpty(tblFuncInf.getIconPath()) || "-".equals(tblFuncInf.getIconPath().trim())) { menuBean.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENUITEM); } else { menuBean.put(Constants.TOOLBAR_ICON, tblFuncInf.getIconPath().trim()); } if (Constants.MENU_LVL_1.equals(tblFuncInf.getFuncType())) {//?? // Map<String, Object> menuBean = new LinkedHashMap<String, Object>(); menuBean.put(Constants.MENU_ID, tblFuncInf.getFuncId().toString().trim()); menuBean.put(Constants.MENU_TEXT, tblFuncInf.getFuncName().trim()); menuBean.put(Constants.MENU_CLS, Constants.MENU_FOLDER); allMenuBean.addJSONArrayElement(menuBean); } else if (Constants.MENU_LVL_2.equals(tblFuncInf.getFuncType())) {//?? // Map<String, Object> menuBean = new LinkedHashMap<String, Object>(); menuBean.put(Constants.MENU_ID, tblFuncInf.getFuncId().toString().trim()); menuBean.put(Constants.MENU_TEXT, tblFuncInf.getFuncName().trim()); menuBean.put(Constants.MENU_PARENT_ID, tblFuncInf.getFuncParentId().toString().trim()); menuBean.put(Constants.MENU_CLS, Constants.MENU_FOLDER); addLvl2Menu(menuBean); } else if (Constants.MENU_LVL_3.equals(tblFuncInf.getFuncType())) { // Map<String, Object> menuBean = new LinkedHashMap<String, Object>(); menuBean.put(Constants.MENU_ID, tblFuncInf.getFuncId().toString().trim()); menuBean.put(Constants.MENU_TEXT, tblFuncInf.getFuncName().trim()); menuBean.put(Constants.MENU_PARENT_ID, tblFuncInf.getFuncParentId().toString().trim()); menuBean.put(Constants.MENU_LEAF, true); menuBean.put(Constants.MENU_URL, tblFuncInf.getPageUrl().trim()); menuBean.put(Constants.MENU_CLS, Constants.MENU_FILE); // if("-".equals(tblFuncInf.getIconPath().trim())) { // menuBean.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENUITEM); // } else { // menuBean.put(Constants.TOOLBAR_ICON, tblFuncInf.getIconPath().trim()); // } addLvl3Menu(menuBean); } } //?? List<Object> menuLvl1List = allMenuBean.getDataList(); for (int i = 0; i < menuLvl1List.size(); i++) { Map<String, Object> menuLvl1Bean = (Map<String, Object>) menuLvl1List.get(i); if (!menuLvl1Bean.containsKey(Constants.MENU_CHILDREN)) { menuLvl1List.remove(i); i--; continue; } List<Object> menuLvl2List = (List<Object>) menuLvl1Bean.get(Constants.MENU_CHILDREN); for (int j = 0; j < menuLvl2List.size(); j++) { Map<String, Object> menuLvl2Bean = (Map<String, Object>) menuLvl2List.get(j); if (!menuLvl2Bean.containsKey(Constants.MENU_CHILDREN)) { menuLvl2List.remove(j); menuLvl1Bean.put(Constants.MENU_CHILDREN, menuLvl2List); menuLvl1List.set(i, menuLvl1Bean); allMenuBean.setDataList(menuLvl1List); j--; } } } }
From source file:org.uaa.admin.resource.Apilogs.java
@Path("/addrs") @GET//w w w . ja va2s .co m public String getUniqueAddrCount(@QueryParam("interval") Integer interval) { if (interval == null) interval = default_interval; Timestamp now = new Timestamp(System.currentTimeMillis()); Integer count = apilogService.getUniqueAddrCount(interval, now.getTime()); Map<String, Object> attrs = new LinkedHashMap<String, Object>(); attrs.put("count", count); ResponseWithData res = new ResponseWithData(attrs); return res.toJson(); }