List of usage examples for java.util HashMap entrySet
Set entrySet
To view the source code for java.util HashMap entrySet.
Click Source Link
From source file:com.funambol.exchange.httptransport.HTTP_FBA_Authentication.java
String createCookieString(HashMap<String, String> cookieJar) { ArrayList<String> pairs = new ArrayList<String>(); for (Entry<String, String> entry : cookieJar.entrySet()) { pairs.add(entry.getKey() + "=" + entry.getValue()); }/*from ww w. j av a 2 s . co m*/ String result = StringUtils.join(pairs.toArray(), "; "); return result; }
From source file:com.elsevier.spark_xml_utils.xquery.XQueryProcessor.java
/** * Set the namespaces in the XQueryCompiler. * //from w ww. java 2 s .c om * @param xqueryCompiler * @param namespaceMappings Namespace prefix to Namespace uri mappings */ private void setPrefixNamespaceMappings(XQueryCompiler xqueryCompiler, HashMap<String, String> namespaceMappings) { if (namespaceMappings != null) { // Get the mappings Set<Entry<String, String>> mappings = namespaceMappings.entrySet(); // If mappings exist, set the namespaces if (mappings != null) { Iterator<Entry<String, String>> it = mappings.iterator(); while (it.hasNext()) { Entry<String, String> entry = it.next(); xqueryCompiler.declareNamespace(entry.getKey(), entry.getValue()); } } } // Add in the defaults xqueryCompiler.declareNamespace("xml", NamespaceConstant.XML); xqueryCompiler.declareNamespace("xs", NamespaceConstant.SCHEMA); xqueryCompiler.declareNamespace("fn", NamespaceConstant.FN); }
From source file:edu.kit.dama.staging.util.DataOrganizationUtils.java
/** * Zip the content of the provided collection node and write the result to * the provided output stream.// w w w. j a v a2 s.c o m * * @param pNode The node whose content is zipped. * @param pOutputStream The output stream to which the zipped data will * send. * @param pSizeLimit The max. size in bytes that will be streamed. * Otherwise, an IOException will occur. Provide a value smaller 0 for no * limit. * @throws java.io.IOException If the size limit has been exceeded or * streaming fails. */ public static void zip(ICollectionNode pNode, OutputStream pOutputStream, long pSizeLimit) throws IOException { byte[] buf = new byte[1024]; HashMap<String, File> map = new HashMap<>(); long size = DataOrganizationUtils.generateZipEntries(pNode, null, map); if (pSizeLimit > 0 && size > pSizeLimit) { throw new IOException("Size limit of " + pSizeLimit + " bytes exceeded. Zip operation aborted."); } Set<Entry<String, File>> entries = map.entrySet(); try (ZipOutputStream zipOut = new ZipOutputStream(pOutputStream)) { for (Entry<String, File> entry : entries) { if (entry.getValue() == null) { //directory node zipOut.putNextEntry(new ZipEntry(entry.getKey() + "/")); } else { //file node zipOut.putNextEntry(new ZipEntry(entry.getKey())); } if (entry.getValue() != null) { try (final FileInputStream in = new FileInputStream(entry.getValue())) { // Add ZIP entry to output stream. // Transfer bytes from the file to the ZIP file int len; while ((len = in.read(buf)) > 0) { zipOut.write(buf, 0, len); } } } zipOut.closeEntry(); } zipOut.finish(); zipOut.flush(); } }
From source file:com.nridge.core.io.gson.DocumentJSON.java
/** * Saves the Document to the writer stream specified as a parameter. * * @param aWriter Json writer stream instance. * @param aDocument Document instance./* w w w .java2 s . c o m*/ * * @throws java.io.IOException I/O related exception. */ public void save(JsonWriter aWriter, Document aDocument) throws IOException { aWriter.beginObject(); IOJSON.writeNameValue(aWriter, IO.JSON_NAME_MEMBER_NAME, aDocument.getName()); IOJSON.writeNameValue(aWriter, IO.JSON_VERSION_MEMBER_NAME, aDocument.getSchemaVersion()); IOJSON.writeNameValue(aWriter, IO.JSON_TYPE_MEMBER_NAME, aDocument.getType()); IOJSON.writeNameValue(aWriter, IO.JSON_TITLE_MEMBER_NAME, aDocument.getTitle()); IOJSON.writeNameValue(aWriter, IO.JSON_FEATURES_ARRAY_NAME, aDocument.getFeatures()); DataTableJSON dataTableJSON = new DataTableJSON(aDocument.getTable()); dataTableJSON.save(aWriter, true); ArrayList<Relationship> relationshipList = aDocument.getRelationships(); if (relationshipList.size() > 0) { aWriter.name(IO.JSON_RELATED_ARRAY_NAME).beginArray(); RelationshipJSON relationshipJSON = new RelationshipJSON(); for (Relationship relationship : relationshipList) relationshipJSON.save(aWriter, relationship); aWriter.endArray(); } HashMap<String, String> docACL = aDocument.getACL(); if (docACL.size() > 0) { aWriter.name(IO.JSON_ACL_ARRAY_NAME).beginArray(); for (Map.Entry<String, String> aclEntry : docACL.entrySet()) { aWriter.beginObject(); aWriter.name(IO.JSON_NAME_MEMBER_NAME).value(aclEntry.getKey()); aWriter.name(IO.JSON_VALUE_MEMBER_NAME).value(aclEntry.getValue()); aWriter.endObject(); } aWriter.endArray(); } aWriter.endObject(); }
From source file:com.thoughtworks.go.config.materials.PackageMaterial.java
@Override public void populateEnvironmentContext(EnvironmentVariableContext context, MaterialRevision materialRevision, File workingDir) {/* w ww . j ava2 s. c o m*/ context.setProperty( upperCase(format("GO_PACKAGE_%s_LABEL", escapeEnvironmentVariable(getName().toString()))), materialRevision.getRevision().getRevision(), false); for (ConfigurationProperty configurationProperty : getPackageDefinition().getRepository() .getConfiguration()) { context.setProperty( getEnvironmentVariableKey("GO_REPO_%s_%s", configurationProperty.getConfigurationKey().getName()), configurationProperty.getValue(), configurationProperty.isSecure()); } for (ConfigurationProperty configurationProperty : getPackageDefinition().getConfiguration()) { context.setProperty( getEnvironmentVariableKey("GO_PACKAGE_%s_%s", configurationProperty.getConfigurationKey().getName()), configurationProperty.getValue(), configurationProperty.isSecure()); } HashMap<String, String> additionalData = materialRevision.getLatestModification().getAdditionalDataMap(); if (additionalData != null) { for (Map.Entry<String, String> entry : additionalData.entrySet()) { boolean isSecure = false; for (EnvironmentVariableContext.EnvironmentVariable secureEnvironmentVariable : context .getSecureEnvironmentVariables()) { String urlEncodedValue = null; try { urlEncodedValue = URLEncoder.encode(secureEnvironmentVariable.value(), "UTF-8"); } catch (UnsupportedEncodingException e) { } boolean isSecureEnvironmentVariableEncoded = !StringUtils.isBlank(urlEncodedValue) && !secureEnvironmentVariable.value().equals(urlEncodedValue); if (isSecureEnvironmentVariableEncoded && entry.getValue().contains(urlEncodedValue)) { isSecure = true; break; } } String key = entry.getKey(); String value = entry.getValue(); context.setProperty(getEnvironmentVariableKey("GO_PACKAGE_%s_%s", key), value, isSecure); } } }
From source file:com.ibm.storlet.sbus.SBusDatagram.java
private void setCommandAndParamsFromJSON(String strJSONParams) { HashMap<String, ?> ParamsAndCommand = convertJSONtoMap(strJSONParams); HashMap<String, String> JustParams = new HashMap<String, String>(); for (Entry<String, ?> e : ParamsAndCommand.entrySet()) { String strKey = e.getKey(); String strValue = e.getValue().toString(); if (strKey.equals(strCommandKeyName)) setCommand(convertStringToCommand(strValue)); else if (strKey.equals(strTaskIdName)) setTaskId(strValue);/* www .ja v a 2s . c o m*/ else JustParams.put(strKey, strValue); } setExecParams(JustParams); }
From source file:org.owasp.benchmark.score.report.ScatterVulns.java
private void makeDataLabels(String category, Set<Report> toolResults, XYPlot xyplot) { HashMap<Point2D, String> map = makePointList(category, toolResults); for (Entry<Point2D, String> e : map.entrySet()) { if (e.getValue() != null) { Point2D p = e.getKey(); String label = sort(e.getValue()); XYTextAnnotation annotation = new XYTextAnnotation(label, p.getX(), p.getY()); annotation.setTextAnchor(p.getX() < 3 ? TextAnchor.TOP_LEFT : TextAnchor.TOP_CENTER); annotation.setBackgroundPaint(Color.white); if (label.toCharArray()[0] == averageLabel) { annotation.setPaint(Color.magenta); } else { annotation.setPaint(Color.blue); }// w w w . j a va2s .c o m annotation.setFont(theme.getRegularFont()); xyplot.addAnnotation(annotation); } } }
From source file:keel.Algorithms.UnsupervisedLearning.AssociationRules.Visualization.keelassotiationrulesbarchart.ResultsProccessor.java
private String findSmallerValue(HashMap<String, String> map) { double valueNumber = Double.MAX_VALUE; String smallerElement = ""; for (Map.Entry<String, String> entry : map.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (!"".equals(value) && Double.parseDouble(value) < valueNumber) { smallerElement = key;// www . j a v a 2 s.com valueNumber = Double.parseDouble(value); } } return smallerElement; }
From source file:com.intuit.tank.httpclient5.TankHttpClient5.java
/** * Set all the header keys// ww w . j av a2 s . c om * * @param connection */ @SuppressWarnings("rawtypes") private void setHeaders(BaseRequest request, ClassicHttpRequest method, HashMap<String, String> headerInformation) { try { Set set = headerInformation.entrySet(); Iterator iter = set.iterator(); while (iter.hasNext()) { Map.Entry mapEntry = (Map.Entry) iter.next(); method.setHeader((String) mapEntry.getKey(), (String) mapEntry.getValue()); } } catch (Exception ex) { LOG.warn(request.getLogUtil().getLogMessage("Unable to set header: " + ex.getMessage(), LogEventType.System)); } }
From source file:com.thoughtworks.go.config.materials.PluggableSCMMaterial.java
@Override public void populateEnvironmentContext(EnvironmentVariableContext context, MaterialRevision materialRevision, File workingDir) {// w ww . j a v a2 s .c o m context.setProperty(getEnvironmentVariableKey("GO_SCM_%s_%s", "LABEL"), materialRevision.getRevision().getRevision(), false); for (ConfigurationProperty configurationProperty : scmConfig.getConfiguration()) { context.setProperty( getEnvironmentVariableKey("GO_SCM_%s_%s", configurationProperty.getConfigurationKey().getName()), configurationProperty.getValue(), configurationProperty.isSecure()); } HashMap<String, String> additionalData = materialRevision.getLatestModification().getAdditionalDataMap(); if (additionalData != null) { for (Map.Entry<String, String> entry : additionalData.entrySet()) { boolean isSecure = false; for (EnvironmentVariableContext.EnvironmentVariable secureEnvironmentVariable : context .getSecureEnvironmentVariables()) { String urlEncodedValue = null; try { urlEncodedValue = URLEncoder.encode(secureEnvironmentVariable.value(), "UTF-8"); } catch (UnsupportedEncodingException e) { } boolean isSecureEnvironmentVariableEncoded = !StringUtils.isBlank(urlEncodedValue) && !secureEnvironmentVariable.value().equals(urlEncodedValue); if (isSecureEnvironmentVariableEncoded && entry.getValue().contains(urlEncodedValue)) { isSecure = true; break; } } String key = entry.getKey(); String value = entry.getValue(); context.setProperty(getEnvironmentVariableKey("GO_SCM_%s_%s", key), value, isSecure); } } }