List of usage examples for java.util HashMap size
int size
To view the source code for java.util HashMap size.
Click Source Link
From source file:com.ba.forms.settlement.BASettlementAction.java
public ActionForward getRoomRentDets(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { JSONObject json = new JSONObject(); BASettlementDTO vo = new BASettlementDTO(); try {//from w ww .ja v a 2 s . c om logger.info(" get method starts here"); String roomId = request.getParameter("roomId"); String bookingId = request.getParameter("bookingId"); HashMap hashMpRoomTariffDet = BASettlementFactory.getInstanceOfBASettlementFactory() .getRoomRentDets(bookingId, roomId); json.put("exception", ""); json.put("SettlementDets", hashMpRoomTariffDet); json.put("SettlementExit", hashMpRoomTariffDet.size()); logger.warn("strCurrent PageNo ------------->" + objPageCount); } catch (Exception ex) { logger.error("The Exception is :" + ex); ex.printStackTrace(); json.put("exception", BAHandleAllException.exceptionHandler(ex)); } response.getWriter().write(json.toString()); return null; }
From source file:com.ba.masters.configuration.BAConfigurationAction.java
public ActionForward baGet(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { JSONObject json = new JSONObject(); BAConfigurationDTO vo = new BAConfigurationDTO(); try {/*from w w w . j a v a 2 s . c om*/ logger.info(" get method starts here"); String order = request.getParameter("search"); HashMap hashMpConfigurationDet = BAConfigurationFactory.getInstanceOfBAConfigurationFactory() .getConfigurationDtls(order); json.put("exception", ""); json.put("ConfigurationDets", hashMpConfigurationDet); json.put("ConfigurationExit", hashMpConfigurationDet.size()); logger.warn("strCurrent PageNo ------------->" + objPageCount); } catch (Exception ex) { logger.error("The Exception is :" + ex); ex.printStackTrace(); json.put("exception", BAHandleAllException.exceptionHandler(ex)); } response.getWriter().write(json.toString()); return null; }
From source file:com.esri.geoevent.solutions.processor.eventjoiner.EventJoinerProcessor.java
public GeoEvent process(GeoEvent evt) throws Exception { try {/*from w w w . j a v a 2 s .com*/ if (recordCache == null) recordCache = new HashMap<String, TrackRecord>(); String curDefName = evt.getGeoEventDefinition().getName(); if (!defList.contains(curDefName)) return null; String uid = evt.getField(joinfield).toString(); if (!recordCache.containsKey(uid)) { TrackRecord tr = new TrackRecord(); tr.setId(uid); HashMap<String, GeoEvent> joinEvents = new HashMap<String, GeoEvent>(); joinEvents.put(curDefName, evt); tr.records.add(joinEvents); recordCache.put(uid, tr); } else { TrackRecord tr = recordCache.get(uid); Boolean exitLoop = false; while (!exitLoop) { for (HashMap<String, GeoEvent> rec : tr.records) { if (!rec.containsKey(curDefName)) { rec.put(curDefName, evt); if (rec.size() == defList.size()) { if (createNewDef) { ConstructGeoEventDef(rec); createNewDef = false; } return CreateGeoEvent(rec); } exitLoop = true; } } exitLoop = true; } HashMap<String, GeoEvent> joinEvents = new HashMap<String, GeoEvent>(); joinEvents.put(curDefName, evt); tr.records.add(joinEvents); } return null; } catch (Exception e) { LOG.error(e.getMessage()); throw (e); } }
From source file:com.ba.forms.settlement.BASettlementAction.java
public ActionForward baGet(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { JSONObject json = new JSONObject(); BASettlementDTO vo = new BASettlementDTO(); try {/*from w w w . j a v a 2 s . c om*/ logger.info(" get method starts here"); String roomId = request.getParameter("roomId"); String bookingId = request.getParameter("bookingId"); HashMap hashMpSettlementDet = BASettlementFactory.getInstanceOfBASettlementFactory() .getSettlementDtls(bookingId, roomId); json.put("exception", ""); json.put("SettlementDets", hashMpSettlementDet); json.put("SettlementExit", hashMpSettlementDet.size()); logger.warn("strCurrent PageNo ------------->" + objPageCount); } catch (Exception ex) { logger.error("The Exception is :" + ex); ex.printStackTrace(); json.put("exception", BAHandleAllException.exceptionHandler(ex)); } response.getWriter().write(json.toString()); return null; }
From source file:gov.nih.nci.rembrandt.web.helper.PCAAppletHelper.java
public static String generateParams(String sessionId, String taskId) { String htm = ""; DecimalFormat nf = new DecimalFormat("0.0000"); try {/*from w w w. j a v a 2s . c o m*/ //retrieve the Finding from cache and build the list of PCAData points PrincipalComponentAnalysisFinding principalComponentAnalysisFinding = (PrincipalComponentAnalysisFinding) businessTierCache .getSessionFinding(sessionId, taskId); ArrayList<PrincipalComponentAnalysisDataPoint> pcaData = new ArrayList(); Collection<ClinicalFactorType> clinicalFactors = new ArrayList<ClinicalFactorType>(); List<String> sampleIds = new ArrayList(); Map<String, PCAresultEntry> pcaResultMap = new HashMap<String, PCAresultEntry>(); List<PCAresultEntry> pcaResults = principalComponentAnalysisFinding.getResultEntries(); for (PCAresultEntry pcaEntry : pcaResults) { sampleIds.add(pcaEntry.getSampleId()); pcaResultMap.put(pcaEntry.getSampleId(), pcaEntry); } Collection<SampleResultset> validatedSampleResultset = ClinicalDataValidator .getValidatedSampleResultsetsFromSampleIDs(sampleIds, clinicalFactors); if (validatedSampleResultset != null) { String id; PCAresultEntry entry; for (SampleResultset rs : validatedSampleResultset) { id = rs.getBiospecimen().getSpecimenName(); entry = pcaResultMap.get(id); PrincipalComponentAnalysisDataPoint pcaPoint = new PrincipalComponentAnalysisDataPoint(id, entry.getPc1(), entry.getPc2(), entry.getPc3()); String diseaseName = rs.getDisease().getValueObject(); if (diseaseName != null) { pcaPoint.setDiseaseName(diseaseName); } else { pcaPoint.setDiseaseName(DiseaseType.NON_TUMOR.name()); } GenderDE genderDE = rs.getGenderCode(); if (genderDE != null) { String gt = genderDE.getValueObject(); if (gt != null) { GenderType genderType = GenderType.valueOf(gt); if (genderType != null) { pcaPoint.setGender(genderType); } } } Long survivalLength = rs.getSurvivalLength(); if (survivalLength != null) { //survival length is stored in days in the DB so divide by 30 to get the //approx survival in months double survivalInMonths = survivalLength.doubleValue() / 30.0; pcaPoint.setSurvivalInMonths(survivalInMonths); } pcaData.add(pcaPoint); } } //make a hashmap // [key=group] hold the array of double[][]s HashMap<String, ArrayList> hm = new HashMap(); //now we should have a collection of PCADataPts double[][] pts = new double[pcaData.size()][3]; for (int i = 0; i < pcaData.size(); i++) { //just create a large 1 set for now //are we breaking groups by gender or disease? PrincipalComponentAnalysisDataPoint pd = pcaData.get(i); pts[i][0] = pd.getPc1value(); pts[i][1] = pd.getPc2value(); pts[i][2] = pd.getPc3value(); ArrayList<double[]> al; try { if (hm.containsKey(pd.getDiseaseName())) { //already has it, so add this one al = (ArrayList) hm.get(pd.getDiseaseName()); } else { al = new ArrayList(); hm.put(pd.getDiseaseName(), new ArrayList()); } if (!al.contains(pts[i])) { al.add(pts[i]); } hm.put(pd.getDiseaseName(), al); } catch (Exception e) { System.out.print(e.toString()); } } int r = hm.size(); if (r == 1) { } //hm should now contain a hashmap of all the disease groups //generate the param tags htm += "<param name=\"key\" value=\"" + taskId + "\" >\n"; htm += "<param name=\"totalPts\" value=\"" + pts.length + "\" >\n"; htm += "<param name=\"totalGps\" value=\"" + hm.size() + "\" >\n"; int ii = 0; for (Object k : hm.keySet()) { String key = k.toString(); //for each group Color diseaseColor = Color.GRAY; if (DiseaseType.valueOf(key) != null) { DiseaseType disease = DiseaseType.valueOf(key); diseaseColor = disease.getColor(); } ArrayList<double[]> al = hm.get(key); htm += "<param name=\"groupLabel_" + ii + "\" value=\"" + key + "\" >\n"; htm += "<param name=\"groupCount_" + ii + "\" value=\"" + al.size() + "\" >\n"; htm += "<param name=\"groupColor_" + ii + "\" value=\"" + diseaseColor.getRGB() + "\" >\n"; int jj = 0; for (double[] d : al) { String comm = nf.format(d[0]) + "," + nf.format(d[1]) + "," + nf.format(d[2]); String h = "<param name=\"pt_" + ii + "_" + jj + "\" value=\"" + comm + "\">\n"; htm += h; jj++; } ii++; } /* //for bulk rendering for(int i=0; i<pts.length; i++) { String comm = String.valueOf(pts[i][0]) + "," + String.valueOf(pts[i][1]) + "," + String.valueOf(pts[i][2]); String h = "<param name=\"pt_"+i+"\" value=\""+ comm +"\">\n"; //htm += h; } */ } //try catch (Exception e) { } return htm; }
From source file:com.wavemaker.runtime.data.spring.SpringDataServiceManager.java
@Override public void commit() { if (txLogger.isInfoEnabled()) { txLogger.info("commit"); }/*w ww. j a v a 2s .co m*/ ThreadContext.Context ctx = ThreadContext.getContext(this.metaData.getName()); if (ctx == null) { if (txLogger.isWarnEnabled()) { txLogger.warn("ignoring commit - no tx in progress"); if (txLogger.isDebugEnabled()) { logStackTrace(); } } return; } TransactionStatus txStatus = ctx.getTransactionStatus(); try { if (txStatus == null) { if (txLogger.isWarnEnabled()) { txLogger.warn("ignoring commit - no tx status"); if (txLogger.isDebugEnabled()) { logStackTrace(); } } } else { this.txMgr.commit(txStatus); } } finally { ctx.setTransactionStatus(null); ThreadContext.unsetContext(this.metaData.getName()); HashMap<String, ThreadContext.Context> contextHash = ThreadContext.getThreadLocalHash(); if (contextHash != null && contextHash.size() > 0) { if (!TransactionSynchronizationManager.isSynchronizationActive()) { TransactionSynchronizationManager.initSynchronization(); } } else { if (TransactionSynchronizationManager.isSynchronizationActive()) { TransactionSynchronizationManager.clear(); Map map = TransactionSynchronizationManager.getResourceMap(); for (Object entry : map.keySet()) { TransactionSynchronizationManager.unbindResource(entry); } } } } }
From source file:com.ba.forms.advanceBookingForm.BAAdvanceBookingAction.java
public ActionForward baGet(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { JSONObject json = new JSONObject(); BAAdvanceBookingDTO dto = new BAAdvanceBookingDTO(); try {// w w w . ja va 2 s .co m logger.info(" get method starts here"); String advanceId = request.getParameter("search"); HashMap hashMpAdvanceBookingDet = BAAdvanceBookingFactory.getInstanceOfBAAdvanceBookingFactory1() .getAdvanceBookingDtls(advanceId); json.put("exception", ""); json.put("AdvanceBookingDets", hashMpAdvanceBookingDet); json.put("AdvanceBookingExit", hashMpAdvanceBookingDet.size()); // logger.warn("strCurrent PageNo ------------->"+objPageCount); } catch (Exception ex) { logger.error("The Exception is :" + ex); ex.printStackTrace(); json.put("exception", BAHandleAllException.exceptionHandler(ex)); } response.getWriter().write(json.toString()); return null; }
From source file:Main.java
public static boolean encodeLZW(String inText, int dictSize, int[] encodedData) { int[] returnData = { 0 }; try {//from w w w .j a va 2 s. com encodedData = new int[inText.length()]; int outCount = 0; HashMap<Integer, String> dict = newDictLZW(inText); String teststring = ""; for (int i = 0; i < inText.length() - 1; i++) { teststring = String.valueOf(inText.charAt(i)); String prevstring = teststring; int j = 0; // System.out.println("teststring = " + teststring + // "; prevstring= " + prevstring + "; i= " + i); while (dict.containsValue(teststring) && i + j < inText.length() - 1) { prevstring = teststring; j++; teststring = teststring.concat(String.valueOf(inText.charAt(i + j))); } // get key value for the string that matched Integer mapIndex = (getKeyByValue(dict, prevstring)); // add this key to the encoded outText as string (ASCII 8 bit) outText = // outText.concat(String.valueOf(((char)Integer.parseInt(mapIndex)))); encodedData[outCount] = mapIndex; outCount++; // add to dictionary the string that matched plus the next char in // sequence in inText // test that the new dictionary entry is not in the dictionary and // does not contain the new-line character if (!dict.containsValue(teststring) && teststring.charAt(teststring.length() - 1) != '\n' && dict.size() < dictSize) dict.put(dict.size(), teststring); // set index value i to point to that next char in sequence i = i + j - 1; } // TODO add switch to turn printing on and off System.out.println("\n-- Dictionary --"); printDictionary(dict); returnData = new int[outCount]; // count entries and use here. for (int i = 0; i < outCount; i++) { returnData[i] = encodedData[i]; } encodedData = returnData; } catch (Exception ex) { System.err.println( "---------------------------------------------\nencodeLZW() method failed\nprobably tried to encode an incompatable file\n---------------------------------------------"); return false; } return true; }
From source file:com.andrada.sitracker.reader.Samlib.java
@Override public boolean updateAuthor(@NotNull Author author) throws SQLException { boolean authorUpdated = false; HttpRequest request;//from w w w .j a va2s . c o m AuthorPageReader reader; try { URL authorURL = new URL(author.getUrl()); request = HttpRequest.get(authorURL); if (request.code() == 404) { //skip this author //Not available atm return false; } if (!authorURL.getHost().equals(request.url().getHost())) { //We are being redirected hell knows where. //Skip return false; } //TODO OutOfMemory thrown here reader = new SamlibAuthorPageReader(request.body()); //We go a blank response but no exception, skip author if (reader.isPageBlank()) { return false; } } catch (MalformedURLException e) { //Just swallow exception, as this is unlikely to happen //Skip author trackException(e.getMessage()); return false; } catch (HttpRequest.HttpRequestException e) { //Author currently inaccessible or no internet //Skip author trackException(e.getMessage()); return false; } AuthorDao authorDao = null; PublicationDao publicationsDao = null; try { publicationsDao = helper.getDao(Publication.class); } catch (SQLException e) { Log.e("Samlib", "Could not create DAO publicationsDao", e); } try { authorDao = helper.getDao(Author.class); } catch (SQLException e) { Log.e("Samlib", "Could not create DAO authorDao", e); } assert authorDao != null; assert publicationsDao != null; String authImgUrl = reader.getAuthorImageUrl(author.getUrl()); String authDescription = reader.getAuthorDescription(); if (authImgUrl != null) { author.setAuthorImageUrl(authImgUrl); } if (authDescription != null) { author.setAuthorDescription(authDescription); } authorDao.update(author); ForeignCollection<Publication> oldItems = author.getPublications(); List<Publication> newItems = reader.getPublications(author); HashMap<String, Publication> oldItemsMap = new HashMap<String, Publication>(); for (Publication oldPub : oldItems) { oldItemsMap.put(oldPub.getUrl(), oldPub); } if (newItems.size() == 0 && oldItemsMap.size() > 1) { LogUtils.LOGW(Constants.APP_TAG, "Something went wrong. No publications found for author that already exists"); //Just skip for now to be on the safe side. return false; } for (Publication pub : newItems) { //Find pub in oldItems if (oldItemsMap.containsKey(pub.getUrl())) { Publication old = oldItemsMap.get(pub.getUrl()); if (old.getUpdatesIgnored()) { //Do not check anything continue; } //Check size/name/description if (pub.getSize() != old.getSize() || !pub.getName().equals(old.getName())) { //if something differs //Store the old size if (old.getOldSize() != 0) { pub.setOldSize(old.getOldSize()); } else { pub.setOldSize(old.getSize()); } //Swap the ids, do an update in DB pub.setId(old.getId()); //Copy over custom properties that do not relate to samlib pub.setMyVote(old.getMyVote()); pub.setVoteCookie(old.getVoteCookie()); pub.setVoteDate(old.getVoteDate()); pub.setUpdatesIgnored(old.getUpdatesIgnored()); pub.setNew(true); authorUpdated = true; publicationsDao.update(pub); //Mark author new, update in DB author.setUpdateDate(new Date()); author.setNew(true); authorDao.update(author); } else if (!StringUtils.equalsIgnoreCase(old.getImagePageUrl(), pub.getImagePageUrl())) { pub.setId(old.getId()); //Update silently publicationsDao.update(pub); } } else { //Mark author new, update in DB author.setUpdateDate(new Date()); author.setNew(true); authorDao.update(author); //Mark publication new, create in DB pub.setNew(true); authorUpdated = true; publicationsDao.create(pub); } } return authorUpdated; }
From source file:com.ba.forms.receipt.BAReceiptAction.java
public ActionForward baGet(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { JSONObject json = new JSONObject(); BAReceiptDTO dto = new BAReceiptDTO(); try {//w w w .j a v a 2 s. c o m logger.info(" get method starts here"); String advanceId = request.getParameter("search"); HashMap hashMpReceiptDet = BAReceiptFactory.getInstanceOfBAReceiptFactory().getReceiptDtls(advanceId); json.put("exception", ""); json.put("ReceiptDets", hashMpReceiptDet); json.put("ReceiptExit", hashMpReceiptDet.size()); // logger.warn("strCurrent PageNo ------------->"+objPageCount); } catch (Exception ex) { logger.error("The Exception is :" + ex); ex.printStackTrace(); json.put("exception", BAHandleAllException.exceptionHandler(ex)); } response.getWriter().write(json.toString()); return null; }