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.mc.printer.model.panel.task.BuildModelTask.java
@Override public Object doBackgrounp() { javax.swing.JTabbedPane tabs = AutoPrinterApp.getMainView().getMainWorkPanel(); if (tabs != null) { if (tabs.getSelectedIndex() >= 0) { Component selectedcom = tabs.getSelectedComponent(); if (selectedcom instanceof CanvasWork) { CanvasWork selectPanel = (CanvasWork) selectedcom; FormBeans beansForm = selectPanel.getBeansForm(); /**/ if (beansForm.getHeightcm() == 0 || beansForm.getWidthcm() == 0) { int res = BaseMessage.CONFIRM( "?\r\nA4."); if (res != JOptionPane.OK_OPTION) { return null; }/*w w w . ja va 2 s . c o m*/ } String imagePath = beansForm.getImgpath(); HashMap<String, ComponentBean> parameterMap = selectPanel.getSavedForms(); if (parameterMap.size() > 0) { Set set = parameterMap.keySet(); boolean foundKey = false; //??? List<ComponentBean> beans = new ArrayList(); Iterator it = set.iterator(); while (it.hasNext()) { ComponentBean com = parameterMap.get(it.next().toString()); beans.add(com); if (com.isIskey()) { foundKey = true; } } beansForm.setElements(beans); // // if (!foundKey) { // BaseMessage.ERROR("PRIMARY KEY."); // return null; // } BaseFileChoose fileChoose = new BaseFileChoose("?", new String[] { Constants.MODEL_SUFFIX }, AutoPrinterApp.getMainFrame()); String selectedPath = fileChoose.showSaveDialog(); if (!selectedPath.trim().equals("")) { //get formname selectedPath = selectedPath + File.separator + beansForm.getFormname(); //String time=DateHelper.format(new Date(), "yyyyMMddHHmmss"); String finalZip = selectedPath; if (!selectedPath.endsWith("." + Constants.MODEL_SUFFIX)) { finalZip = selectedPath + "." + Constants.MODEL_SUFFIX; } String tempDir = selectedPath + File.separator + Constants.MODEL_TEMP_DIR; File imageFile = new File(imagePath); String xmlPath = tempDir + File.separator + imageFile.getName() + ".xml"; XMLHelper helper = new XMLHelper(xmlPath, beansForm); try { helper.write(); } catch (JAXBException ex) { ex.printStackTrace(); logger.error(ex.getMessage()); return ex; } File paramFile = new File(xmlPath); if (paramFile.isFile() && paramFile.exists()) { try { FileUtils.copyFileToDirectory(imageFile, new File(tempDir)); ZipHelper.createZip(tempDir, finalZip); return "??.\r\n" + finalZip; } catch (IOException ex) { ex.printStackTrace(); logger.error(ex.getMessage()); return ex; } finally { try { FileUtils.deleteDirectory(new File(selectedPath)); } catch (IOException ex) { ex.printStackTrace(); logger.error(ex.getMessage()); return ex; } } } } } else { return "??."; } } else { return "??????."; } } else { return "."; } } else { return "."; } return null; }
From source file:com.mc.printer.model.panel.client.paper.ReadSavedTask.java
@Override public Object doBackgrounp() { /*?*///from ww w. j a v a 2s . co m HashMap<String, List<SaveOject>> datas = getLocalData(); //?? if (AutoPrinterApp.currentOpenMode.equals(AutoPrinterApp.MODE_CLIENT)) { if (datas == null || datas.size() <= 0) { datas = getRemoteServer(); } } return datas; }
From source file:it.cnr.icar.eric.service.validationTest.cppaValidation.CPPAValidation.java
public SOAPElement validateContent(SOAPElement partValidateContentRequest) throws RemoteException { try {//from w w w .j a v a 2s .co m if (log.isDebugEnabled()) { printNodeToConsole(partValidateContentRequest); } HashMap<String, DataHandler> repositoryItemDHMap = getRepositoryItemDHMap(); if (log.isDebugEnabled()) { log.debug("Attachments: " + repositoryItemDHMap.size()); } Object requestObj = getBindingObjectFromNode(partValidateContentRequest); if (!(requestObj instanceof ValidateContentRequest)) { throw new Exception( "Wrong response received from validation service. Expected ValidationContentRequest, got: " + partValidateContentRequest.getElementName().getQualifiedName()); } vcReq = (ValidateContentRequest) requestObj; IdentifiableType originalContentIT = vcReq.getOriginalContent().getIdentifiable().get(0).getValue(); IdentifiableType invocationControlIT = vcReq.getInvocationControlFile().get(0); DataHandler originalContentDH = repositoryItemDHMap.get(originalContentIT.getId()); DataHandler invocationControlDH = repositoryItemDHMap.get(invocationControlIT.getId()); if (log.isDebugEnabled()) { log.debug("originalContentIT id: " + originalContentIT.getId()); log.debug("invocationControlIT id: " + invocationControlIT.getId()); } StreamSource invocationControlSrc = new StreamSource(invocationControlDH.getInputStream()); TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(invocationControlSrc); StringWriter sw = new StringWriter(); transformer.transform(new StreamSource(originalContentDH.getInputStream()), new StreamResult(sw)); vcResp = cmsFac.createValidateContentResponse(); boolean success = Boolean.valueOf(sw.toString()).booleanValue(); if (success) { vcResp.setStatus(CANONICAL_RESPONSE_STATUS_TYPE_ID_Success); } else { RegistryError re = rsFac.createRegistryError(); re.setValue(sw.toString()); re.setCodeContext(errorCodeContext); re.setErrorCode("InvalidContentException"); RegistryErrorList el = rsFac.createRegistryErrorList(); el.getRegistryError().add(re); el.setHighestSeverity("Failure"); vcResp.setStatus(CANONICAL_RESPONSE_STATUS_TYPE_ID_Failure); vcResp.setRegistryErrorList(el); } vcRespElement = getSOAPElementFromBindingObject(vcResp); } catch (Exception e) { throw new RemoteException("Could not create response.", e); } return vcRespElement; }
From source file:kmi.taa.core.SmallSetAnalyser.java
public double mean(HashMap<Integer, Double> map) { double sum = 0; for (Double v : map.values()) { sum += v.doubleValue();/*from w w w . j a v a2s.c o m*/ } return sum / map.size(); }
From source file:org.kitodo.data.index.elasticsearch.type.ProjectTypeTest.java
@Test public void shouldCreateDocuments() throws Exception { ProjectType processType = new ProjectType(); List<Project> processes = prepareData(); HashMap<Integer, HttpEntity> documents = processType.createDocuments(processes); assertEquals("HashMap of documents doesn't contain given amount of elements!", 3, documents.size()); }
From source file:com.tealeaf.Downloader.java
public HashMap<String, File> download(HashMap<String, String> uris) { HashMap<String, File> files = new HashMap<String, File>(); if (uris == null) { return null; }//w w w . j a va2s .com String[] urls = new String[uris.size()]; uris.keySet().toArray(urls); for (String url : urls) { if (cached(uris.get(url))) { logger.log("{downloader}", uris.get(url), "is cached"); continue; } File f = http.getFile(URI.create(url), uris.get(url)); if (f != null) { logger.log("{downloader} Downloading updated file", url, "to", f.getAbsolutePath()); files.put(url, f); } else { logger.log("{downloader} ERROR: Unable to download file", url); return null; } } return files; }
From source file:org.kitodo.data.elasticsearch.index.type.ProjectTypeTest.java
@Test public void shouldCreateDocuments() { ProjectType processType = new ProjectType(); List<Project> processes = prepareData(); HashMap<Integer, HttpEntity> documents = processType.createDocuments(processes); assertEquals("HashMap of documents doesn't contain given amount of elements!", 3, documents.size()); }
From source file:edu.illinois.cs.cogcomp.transliteration.WikiTransliteration.java
public static HashMap<String, Double> GetFixedSizeNgramProbs(int n, Iterable<String> examples) { HashMap<String, Integer> ngramCounts = GetNgramCounts(n, examples, true); HashMap<String, Integer> ngramTotals = new HashMap<>(); for (String key : ngramCounts.keySet()) { int v = ngramCounts.get(key); Dictionaries.IncrementOrSet(ngramTotals, key.substring(0, n - 1), v, v); }// w ww .j a v a2 s.co m HashMap<String, Double> result = new HashMap<>(ngramCounts.size()); for (String key : ngramCounts.keySet()) { int v = ngramCounts.get(key); result.put(key, ((double) v) / ngramTotals.get(key.substring(0, n - 1))); } return result; }
From source file:de.betterform.agent.web.servlet.XFormsErrorServlet.java
private String getHTML(HttpServletRequest request) { StringBuffer html = new StringBuffer(); String msg = (String) request.getSession().getAttribute("betterform.exception.message"); String xpath = "unknown"; String cause = " "; if (msg != null) { int start = msg.indexOf("::"); if (start > 3) { xpath = msg.substring(start + 2); msg = msg.substring(0, start); }/*from w w w. ja v a2 s . c om*/ } Exception ex = (Exception) request.getSession().getAttribute("betterform.exception"); if (ex != null && ex.getCause() != null && ex.getCause().getMessage() != null) { cause = ex.getCause().getMessage(); } request.getSession().removeAttribute("betterform.exception"); request.getSession().removeAttribute("betterform.exception.message"); html.append("<div class=\"message2\" id=\"msg\">"); html.append(msg); html.append("</div>"); html.append("<div class=\"message3\"><strong>URL:</strong><br/>"); html.append(request.getSession().getAttribute("betterform.referer")); html.append("</div>"); html.append("<div class=\"message3\"><strong>Element causing Exception:</strong><br/>"); html.append(xpath); html.append("</div>"); if (ex.getCause() != null) { html.append("<div class=\"message3\"><strong>Caused by:</strong><br/>"); html.append(cause); html.append("</div>"); } if (ex instanceof XFormsErrorIndication) { Object o = ((XFormsErrorIndication) ex).getContextInfo(); if (o instanceof HashMap) { HashMap<String, Object> map = (HashMap) ((XFormsErrorIndication) ex).getContextInfo(); if (map.size() != 0) { html.append("<table>"); html.append("<caption>Context Information:</caption>"); for (Map.Entry<String, Object> entry : map.entrySet()) { html.append("<tr><td>"); html.append(entry.getKey()); html.append("</td>"); html.append("<td>"); html.append(entry.getValue().toString()); html.append("</td></tr>"); } html.append("</table>"); } } //todo: check -> there are contextInfos containing a simple string but seems to be integrated within above error message already - skip for now /* else{ html.append("<div>"); html.append(o.toString()); html.append("</div>"); } */ } html.append("<form><input type=\"button\" value=\"Back\" onClick=\"history.back()\"/></form>"); try { String mail = Config.getInstance().getProperty("admin.mail"); StringBuffer mailbody = new StringBuffer(); html.append("<div class=\"message3\">"); html.append("<a href=\"mailto:"); html.append(mail); mailbody.append("?subject=XForms Problem at "); mailbody.append(request.getSession().getAttribute("betterform.referer")); mailbody.append("&Body=Message:\n"); mailbody.append(msg); mailbody.append("%0D%0A%0D%0AElement causing Exception:"); mailbody.append(xpath); mailbody.append("%0D%0A%0D%0ACaused by:\n"); mailbody.append(URLEncoder.encode(cause, "UTF-8")); html.append(mailbody.toString()); html.append("\">"); html.append("Report this problem...</a>"); html.append("</div>"); } catch (Exception e) { LOGGER.debug(e); } LOGGER.error(html.toString()); return html.toString(); }
From source file:ru.apertum.qsystem.reports.formirovators.DistributionJobDay.java
@Override public String validate(String driverClassName, String url, String username, String password, HttpRequest request, HashMap<String, String> params) { // ? //from w w w . j a va 2 s.c om QLog.l().logger().trace("? \"" + params.toString() + "\"."); if (params.size() == 1) { // date Date date; String sdate; try { date = Uses.format_dd_MM_yyyy.parse(params.get("date")); sdate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(date); } catch (ParseException ex) { return "<br> ! ? ? (..)."; } paramMap.put("sdate", sdate); paramMap.put("date", date); } else { return "<br> !"; } return null; }