List of usage examples for java.util LinkedHashMap put
V put(K key, V value);
From source file:Main.java
public static LinkedHashMap<String, Uri> GetMatchedContactsList(Context context, String searchTerm) { LinkedHashMap<String, Uri> contactList = new LinkedHashMap<String, Uri>(); ContentResolver cr = context.getContentResolver(); String columns[] = { ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.PHOTO_THUMBNAIL_URI }; Cursor cur;//from ww w . j a v a2 s .c o m if (searchTerm == null) { cur = cr.query(ContactsContract.Contacts.CONTENT_URI, columns, null, null, null); } else { cur = cr.query(ContactsContract.Contacts.CONTENT_URI, columns, ContactsContract.Contacts.DISPLAY_NAME + " LIKE " + DatabaseUtils.sqlEscapeString("%" + searchTerm + "%"), null, ContactsContract.Contacts.DISPLAY_NAME + " ASC"); } if (cur != null) { if (cur.getCount() > 0) { while (cur.moveToNext()) { String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); String photoURI = cur .getString(cur.getColumnIndex(ContactsContract.Contacts.PHOTO_THUMBNAIL_URI)); if (photoURI != null) { Uri thumbUri = Uri.parse(photoURI); contactList.put(name, thumbUri); } } } cur.close(); } return contactList; }
From source file:com.amazon.android.utils.JsonHelperTest.java
private Map<String, Object> getData1Map() { LinkedHashMap<String, Object> map = new LinkedHashMap<>(); map.put("test", "bar"); map.put("foo2", 1); map.put("foo3", new ArrayList<>()); map.put("foo4", new HashMap<>()); return map;//from w w w . j a v a 2 s .c o m }
From source file:ch.gianulli.trelloapi.Board.java
public ArrayList<TrelloList> getAllLists(TrelloAPI api) throws TrelloNotAuthorizedException, TrelloNotAccessibleException { ArrayList<TrelloList> result = new ArrayList<>(); try {//from ww w.j a va 2 s . c om LinkedHashMap<String, String> args = new LinkedHashMap<>(); args.put("cards", "open"); args.put("card_fields", "name,desc"); JSONArray array = api.makeJSONArrayRequest("GET", "boards/" + mId + "/lists", args, true); if (array != null) { for (int i = 0; i < array.length(); ++i) { JSONObject list = array.getJSONObject(i); JSONArray cardArray = list.getJSONArray("cards"); ArrayList<Card> cards = new ArrayList<>(cardArray.length()); for (int j = 0; j < cardArray.length(); ++j) { JSONObject card = cardArray.getJSONObject(j); cards.add(new Card(card.getString("id"), null, card.getString("name"), card.getString("desc"))); // list is null for now } TrelloList trelloList = new TrelloList(list.getString("id"), this, list.getString("name"), cards); // add list reference to cards for (Card c : cards) { c.setList(trelloList); } result.add(trelloList); } } } catch (JSONException e) { throw new TrelloNotAccessibleException("Server answer was not correctly formatted."); } return result; }
From source file:com.linkedin.pinot.tools.PinotSegmentRebalancer.java
/** * Rebalances a table within a tenant// w w w . j a va 2s .co m * @param tableName * @param tenantName * @throws Exception */ public void rebalanceTable(String tableName, String tenantName) throws Exception { final TableType tableType = TableNameBuilder.getTableTypeFromTableName(tableName); if (!tableType.equals(TableType.OFFLINE)) { // Rebalancing works for offline tables, not any other. LOGGER.warn("Don't know how to rebalance table " + tableName); return; } IdealState currentIdealState = helixAdmin.getResourceIdealState(clusterName, tableName); List<String> partitions = Lists.newArrayList(currentIdealState.getPartitionSet()); LinkedHashMap<String, Integer> states = new LinkedHashMap<>(); states.put("OFFLINE", 0); states.put("ONLINE", Integer.parseInt(currentIdealState.getReplicas())); Map<String, Map<String, String>> mapFields = currentIdealState.getRecord().getMapFields(); Set<String> currentHosts = new HashSet<>(); for (String segment : mapFields.keySet()) { currentHosts.addAll(mapFields.get(segment).keySet()); } AutoRebalanceStrategy rebalanceStrategy = new AutoRebalanceStrategy(tableName, partitions, states); TableNameBuilder builder = new TableNameBuilder(tableType); List<String> instancesInClusterWithTag = helixAdmin.getInstancesInClusterWithTag(clusterName, builder.forTable(tenantName)); LOGGER.info("Current: Nodes:" + currentHosts); LOGGER.info("New Nodes:" + instancesInClusterWithTag); Map<String, Map<String, String>> currentMapping = currentIdealState.getRecord().getMapFields(); ZNRecord newZnRecord = rebalanceStrategy.computePartitionAssignment(instancesInClusterWithTag, currentMapping, instancesInClusterWithTag); Map<String, Map<String, String>> newMapping = newZnRecord.getMapFields(); LOGGER.info("Current segment Assignment:"); printSegmentAssignment(currentMapping); LOGGER.info("Final segment Assignment:"); printSegmentAssignment(newMapping); if (!dryRun) { if (EqualityUtils.isEqual(newMapping, currentMapping)) { LOGGER.info("Skipping rebalancing for table:" + tableName + " since its already balanced"); } else { IdealState updatedIdealState = new IdealState(currentIdealState.getRecord()); updatedIdealState.getRecord().setMapFields(newMapping); LOGGER.info("Updating the idealstate for table:" + tableName); helixAdmin.setResourceIdealState(clusterName, tableName, updatedIdealState); int diff = Integer.MAX_VALUE; Thread.sleep(3000); do { diff = isStable(tableName); if (diff == 0) { break; } else { LOGGER.info("Waiting for externalView to match idealstate for table:" + tableName + " Num segments difference:" + diff); Thread.sleep(30000); } } while (diff > 0); LOGGER.info("Successfully rebalanced table:" + tableName); } } }
From source file:edu.cornell.kfs.gl.businessobject.ReversionUnitOfWork.java
/** * @see org.kuali.kfs.kns.bo.BusinessObjectBase#toStringMapper() *//*from w w w . j av a2 s . com*/ public LinkedHashMap toStringMapper() { LinkedHashMap pkMap = new LinkedHashMap(); pkMap.put("chartOfAccountsCode", this.chartOfAccountsCode); pkMap.put("accountNumber", this.accountNumber); pkMap.put("subAccountNumber", this.subAccountNumber); return pkMap; }
From source file:adalid.core.XS1.java
private static Collection<Field> getRidOfDupFields(Collection<Field> fields) { LinkedHashMap<String, Field> map = new LinkedHashMap<>(); String key;/*from ww w . j a va 2 s . c om*/ for (Field field : fields) { key = field.getName(); if (map.containsKey(key)) { TLC.getProject().getParser().error("Field " + key + " hides another field"); logger.error(TAB + "hiding field: " + field); logger.error(TAB + "hidden field: " + map.get(key)); } map.put(key, field); } return map.values(); }
From source file:com.amazon.android.utils.JsonHelperTest.java
private Map<String, Object> getData3Map() { LinkedHashMap<String, Object> map = new LinkedHashMap<>(); ArrayList<Object> foo = new ArrayList<>(); LinkedHashMap<String, Object> foo2 = new LinkedHashMap<>(); foo2.put("foo2", 1); ArrayList<Object> foo3 = new ArrayList<>(); foo3.add("foo3"); foo3.add("foo4"); foo.add(foo2);/* ww w . j av a 2s . co m*/ foo.add(foo3); foo.add("foo5"); foo.add(5); map.put("foo", foo); map.put("foo6", new ArrayList<>()); return map; }
From source file:com.intel.iotkitlib.LibModules.AccountManagement.java
public boolean addAnotherUserToYourAccount(String accountId, String inviteeUserId, Boolean isAdmin) throws JSONException { if (accountId == null || inviteeUserId == null) { Log.d(TAG, "userId or accountId of new user cannot be null"); return false; }// w w w. jav a 2 s . c o m //initiating put for adding another user to account HttpPutTask addUser = new HttpPutTask(new HttpTaskHandler() { @Override public void taskResponse(int responseCode, String response) { Log.d(TAG, String.valueOf(responseCode)); Log.d(TAG, response); statusHandler.readResponse(responseCode, response); } }); //populating the JSON body of adding user to account String body = null; if ((body = createBodyForAddingUserToAccount(accountId, inviteeUserId, isAdmin)) == null) { Log.d(TAG, "problem with Http body creation to add user to account"); return false; } addUser.setHeaders(basicHeaderList); addUser.setRequestBody(body); LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<String, String>(); linkedHashMap.put("invitee_user_id", inviteeUserId); linkedHashMap.put("account_id", accountId); String url = objIotKit.prepareUrl(objIotKit.addUserToAccount, linkedHashMap); return super.invokeHttpExecuteOnURL(url, addUser, "add user to account"); }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.ELTBrowseWorkspaceWidget.java
@Override public LinkedHashMap<String, Object> getProperties() { LinkedHashMap<String, Object> property = new LinkedHashMap<>(); property.put(propertyName, subJobPath.getText()); setToolTipErrorMessage();/*from w w w. j av a2s . c om*/ return property; }
From source file:com.jaspersoft.jasperserver.war.webflow.JsonModelView.java
public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response) throws Exception { if (log.isDebugEnabled()) { log.debug("rendering json model view"); }//from w w w . jav a 2s. c o m LinkedHashMap<String, Object> responseMap = new LinkedHashMap<String, Object>(); for (String modelName : modelNames) { Object modelObject = model.get(modelName); if (modelObject != null) { responseMap.put(modelName, modelObject); } } response.setContentType("application/json; charset=UTF-8"); ObjectMapper jsonMapper = new ObjectMapper(); ServletOutputStream out = response.getOutputStream(); jsonMapper.writeValue(out, responseMap); }