List of usage examples for java.util HashMap containsKey
public boolean containsKey(Object key)
From source file:entity.Chart.java
public JSONObject viewReport(HashMap<String, Object> params) throws SQLException { JSONObject jo = null;//from ww w . jav a2 s.com if (params == null) { params = new HashMap<String, Object>(); } for (int i = 0; rParams != null && i < rParams.length; i++) { if (params == null || !params.containsKey(rParams[i].name)) { JSONArray jSONArray = new JSONArray(); for (int j = 0; j < rParams.length; j++) { JSONObject jSONObject = new JSONObject(); jSONObject.put("Name", rParams[j].name); jSONObject.put("DefaultValue", rParams[j].value); jSONObject.put("DataType", rParams[j].type); jSONObject.put("ReportID", reportID); jSONArray.add(jSONObject); } jo = new JSONObject(); jo.put("params", jSONArray); } params.put(rParams[i].name, StringHelper.stringToObject( params.get(rParams[i].name) == null ? null : params.get(rParams[i].name).toString(), rParams[i].type)); } return jo == null ? generateReport(params) : jo; }
From source file:ca.ualberta.cs.expenseclaim.dao.ExpenseItemDao.java
public HashMap<String, Double> total(int claimId) { HashMap<String, Double> map = new HashMap<String, Double>(); for (ExpenseItem i : itemList) { if (i.getClaimId() == claimId) { String unit = i.getUnit(); Double amount;// w w w. java2 s. c o m if (map.containsKey(unit)) { amount = map.get(unit); } else { amount = 0.0; } amount += i.getAmount(); map.put(unit, amount); } } return map; }
From source file:info.plugmania.mazemania.Util.java
public boolean compare(HashMap<String, String> event, HashMap<String, String> entry) { for (String s : entry.keySet()) { if (!event.containsKey(s)) return false; if ((event.get(s) != entry.get(s)) && (entry.get(s) != "*")) return false; }// w ww . ja v a2s .c om return true; }
From source file:com.adaptris.util.datastore.SimpleDataStore.java
/** * @see DataStore#exists(String, String) *//* ww w . ja v a 2 s . c o m*/ @Override public boolean exists(String id, String type) throws DataStoreException { boolean containsKey = false; try { checkConfiguration(); HashMap data = readData(); containsKey = data.containsKey(id + type); } catch (Exception e) { throw new DataStoreException("Datastore could not be examined.", e); } finally { removeLock(); } return containsKey; }
From source file:userinterface.CountryNetworkAdminRole.CountryReportsJPanel.java
public PieDataset createDataSetForPatientReports() { DefaultPieDataset dataset = new DefaultPieDataset(); HashMap<String, Integer> organDonorMap = new HashMap<>(); for (Patient patient : patientList) { if (organDonorMap.containsKey(patient.getOrganNeeded().getOrganName())) { Integer count = organDonorMap.get(patient.getOrganNeeded().getOrganName()); count++;/*from w ww. j av a2s . c o m*/ organDonorMap.put(patient.getOrganNeeded().getOrganName(), count); } else { organDonorMap.put(patient.getOrganNeeded().getOrganName(), 1); } } for (Map.Entry<String, Integer> entry : organDonorMap.entrySet()) { Integer noOfDonors = entry.getValue(); noOfDonors = (noOfDonors * 100) / patientList.size(); organDonorMap.put(entry.getKey(), noOfDonors); } for (Map.Entry<String, Integer> entry : organDonorMap.entrySet()) { dataset.setValue(entry.getKey() + " = " + entry.getValue(), entry.getValue()); } return dataset; }
From source file:uniko.west.topology.bolts.InteractionGraphBolt.java
private void countRetweets(Map<Object, Object> message, HashMap<String, ArrayList<Interaction>> authorActions) { Map<Object, Object> retweetStatus = (Map<Object, Object>) message.get("retweeted_status"); if (retweetStatus != null) { if (!authorActions.containsKey("retweeted")) { authorActions.put("retweeted", new ArrayList<Interaction>()); }//from w w w . j a va 2 s . co m String authorId = (String) ((Map<Object, Object>) retweetStatus.get("user")).get("id_str"); authorActions.get("retweeted").add(new Interaction(authorId, (String) message.get("created_at"))); } }
From source file:com.nononsenseapps.notepad.sync.googleapi.GoogleTaskSync.java
/** * Loads the remote lists from the database and merges the two lists. If the * remote list contains all lists, then this method only adds local db-ids * to the items. If it does not contain all of them, this loads whatever * extra items are known in the db to the list also. * //from w w w . j a v a 2s. co m * Since all lists are expected to be downloaded, any non-existing entries * are assumed to be deleted and marked as such. */ public static void mergeListsWithLocalDB(final Context context, final String account, final List<GoogleTaskList> remoteLists) { Log.d(TAG, "mergeList starting with: " + remoteLists.size()); final HashMap<String, GoogleTaskList> localVersions = new HashMap<String, GoogleTaskList>(); final Cursor c = context.getContentResolver().query(GoogleTaskList.URI, GoogleTaskList.Columns.FIELDS, GoogleTaskList.Columns.ACCOUNT + " IS ? AND " + GoogleTaskList.Columns.SERVICE + " IS ?", new String[] { account, GoogleTaskList.SERVICENAME }, null); try { while (c.moveToNext()) { GoogleTaskList list = new GoogleTaskList(c); localVersions.put(list.remoteId, list); } } finally { if (c != null) c.close(); } for (final GoogleTaskList remotelist : remoteLists) { // Merge with hashmap if (localVersions.containsKey(remotelist.remoteId)) { //Log.d(TAG, "Setting merge id"); remotelist.dbid = localVersions.get(remotelist.remoteId).dbid; //Log.d(TAG, "Setting merge delete status"); remotelist.setDeleted(localVersions.get(remotelist.remoteId).isDeleted()); localVersions.remove(remotelist.remoteId); } } // Remaining ones for (final GoogleTaskList list : localVersions.values()) { list.remotelyDeleted = true; remoteLists.add(list); } Log.d(TAG, "mergeList finishing with: " + remoteLists.size()); }
From source file:edu.cornell.mannlib.vitro.webapp.web.jsptags.OptionsForPropertyTag.java
public int doStartTag() { try {//from ww w. j av a2s .c o m VitroRequest vreq = new VitroRequest((HttpServletRequest) pageContext.getRequest()); WebappDaoFactory wdf = vreq.getWebappDaoFactory(); if (wdf == null) throw new Exception("could not get WebappDaoFactory from request."); Individual subject = wdf.getIndividualDao().getIndividualByURI(getSubjectUri()); if (subject == null) throw new Exception("could not get individual for subject uri " + getSubjectUri()); ObjectProperty objProp = wdf.getObjectPropertyDao().getObjectPropertyByURI(getPredicateUri()); if (objProp == null) throw new Exception("could not get object property for predicate " + getPredicateUri()); List<VClass> vclasses = new ArrayList<VClass>(); vclasses = wdf.getVClassDao().getVClassesForProperty(getPredicateUri(), true); HashMap<String, Individual> indMap = new HashMap<String, Individual>(); for (VClass vclass : vclasses) { for (Individual ind : wdf.getIndividualDao().getIndividualsByVClassURI(vclass.getURI(), -1, -1)) if (!indMap.containsKey(ind.getURI())) indMap.put(ind.getURI(), ind); } List<Individual> individuals = new ArrayList(indMap.values()); List<ObjectPropertyStatement> stmts = subject.getObjectPropertyStatements(); if (stmts == null) throw new Exception("object properties for subject were null"); individuals = removeIndividualsAlreadyInRange(individuals, stmts); Collections.sort(individuals, new compareEnts()); JspWriter out = pageContext.getOut(); int optionsCount = 0; for (Individual ind : individuals) { String uri = ind.getURI(); if (uri != null) { out.print("<option value=\"" + StringEscapeUtils.escapeHtml(uri) + '"'); if (uri.equals(getSelectedUri())) out.print(" selected=\"selected\""); out.print('>'); out.print(StringEscapeUtils.escapeHtml(ind.getName())); out.println("</option>"); ++optionsCount; } } log.trace("added " + optionsCount + " options for object property \"" + getPredicateUri() + "\" in OptionsForPropertyTag.doStartTag()"); } catch (Exception ex) { throw new Error("Error in doStartTag: " + ex.getMessage()); } return SKIP_BODY; }
From source file:Data.c_CardDB.java
public boolean isInBlock(c_Deck deck, String block) { boolean isDeckInBlock = true; c_Card card;/*from www. java 2s .c om*/ for (int mid : deck.getAllCards().keySet()) { card = getCard(mid); if (contains(card.Name)) { boolean isCardInBlock = false; for (c_Expansion exp : getExpansionList(card.Name).keySet()) { if (exp.getBlock().equals(block)) { isCardInBlock = true; } } if (!isCardInBlock) { isDeckInBlock = false; break; } else if (m_expansionDB.doesBlockContainLegals(block)) { HashMap<Integer, Keyword> legals = m_expansionDB.getBlockLegals(block); int nameHash = card.Name.hashCode(); if (legals.containsKey(nameHash)) { if (legals.get(nameHash).equals(Keyword.Banned) || deck.getAmountOfCard(mid, c_Deck.WhichHalf.BOTH) > 1) { isDeckInBlock = false; legals = null; break; } } legals = null; } } } card = null; return isDeckInBlock; }
From source file:com.pablog178.pdfcreator.android.PdfcreatorModule.java
private void generateWebArchiveFunction(HashMap args) { if (args.containsKey("fileName")) { Object fileName = args.get("fileName"); if (fileName instanceof String) { this.fileName = (String) fileName; Log.i(PROXY_NAME, "fileName: " + this.fileName); }/*from ww w . j a v a 2s . c o m*/ } else return; if (args.containsKey("view")) { Object viewObject = args.get("view"); if (viewObject instanceof TiViewProxy) { TiViewProxy viewProxy = (TiViewProxy) viewObject; this.view = viewProxy.getOrCreateView(); if (this.view == null) { Log.e(PROXY_NAME, "NO VIEW was created!!"); return; } Log.i(PROXY_NAME, "view: " + this.view.toString()); } } else return; try { WebView webView = (WebView) this.view.getNativeView(); webView.saveWebArchive( TiFileFactory.getDataDirectory(true).getAbsolutePath() + File.separator + this.fileName); sendCompleteEvent(); } catch (Exception exception) { Log.e(PROXY_NAME, "Error: " + exception.toString()); sendErrorEvent(exception.toString()); } }