List of usage examples for java.util TreeMap entrySet
EntrySet entrySet
To view the source code for java.util TreeMap entrySet.
Click Source Link
From source file:Yak_Hax.Yak_Hax_Mimerme.PostRequest.java
public static String PostBodyRequest(String URL, String JSONRaw, TreeMap<String, String> headers) throws IOException { HttpPost post = new HttpPost(URL); HttpClient httpclient = HttpClients.custom().build(); post.setEntity(new StringEntity(JSONRaw)); post.setHeader("Content-Type", "application/json; charset=utf-8"); for (Map.Entry<String, String> entry : headers.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); post.setHeader(key, value);/*www . j a v a 2 s . co m*/ } HttpResponse response = httpclient.execute(post); BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuffer result = new StringBuffer(); String line = ""; while ((line = rd.readLine()) != null) { result.append(line); } return result.toString(); }
From source file:com.azaptree.services.spring.application.SpringApplicationService.java
private static void logDebugSystemProperties(final Logger log) { Assert.notNull(log);//from ww w . j a v a2 s .c o m if (log.isDebugEnabled()) { final TreeMap<String, String> sysProps = new TreeMap<>(); for (final Map.Entry<Object, Object> entry : System.getProperties().entrySet()) { sysProps.put(entry.getKey().toString(), entry.getValue().toString()); } final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final PrintStream ps = new PrintStream(bos); for (final Map.Entry<String, String> entry : sysProps.entrySet()) { ps.print(entry.getKey()); ps.print('='); ps.println(entry.getValue()); } log.debug("System Properties:\n{}", bos); } }
From source file:cn.digirun.frame.payment.unionpay.util.SDKUtil.java
/** * //w w w .j a v a 2 s . co m * @param data * @return */ public static String genHtmlResult(Map<String, String> data) { TreeMap<String, String> tree = new TreeMap<String, String>(); Iterator<Entry<String, String>> it = data.entrySet().iterator(); while (it.hasNext()) { Entry<String, String> en = it.next(); tree.put(en.getKey(), en.getValue()); } it = tree.entrySet().iterator(); StringBuffer sf = new StringBuffer(); while (it.hasNext()) { Entry<String, String> en = it.next(); String key = en.getKey(); String value = en.getValue(); if ("respCode".equals(key)) { sf.append("<b>" + key + SDKConstants.EQUAL + value + "</br></b>"); } else sf.append(key + SDKConstants.EQUAL + value + "</br>"); } return sf.toString(); }
From source file:org.apdplat.superword.tools.SentenceScorer.java
public static void toTextFile(TreeMap<Float, Map<String, List<String>>> scores, String fileName) { LOGGER.debug("" + fileName); AtomicInteger bookCount = new AtomicInteger(); AtomicInteger sentenceCount = new AtomicInteger(); try (BufferedWriter writer = new BufferedWriter( new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(fileName))))) { AtomicInteger i = new AtomicInteger(); scores.entrySet().forEach(score -> { writeLine(writer,/*from w w w. j a v a 2 s .c o m*/ "score_(" + i.incrementAndGet() + "/" + scores.size() + ")" + "" + score.getKey()); Map<String, List<String>> books = score.getValue(); AtomicInteger j = new AtomicInteger(); books.entrySet().forEach(book -> { writeLine(writer, "\tbook_(" + j.incrementAndGet() + "/" + books.size() + ")" + "" + book.getKey()); bookCount.incrementAndGet(); AtomicInteger k = new AtomicInteger(); book.getValue().forEach(sentence -> { writeLine(writer, "\t\tsentence_(" + k.incrementAndGet() + "/" + book.getValue().size() + ")" + "" + sentence); sentenceCount.incrementAndGet(); }); }); }); writeLine(writer, "??" + sentenceCount.get()); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } LOGGER.debug("" + scores.keySet().size()); LOGGER.debug("??" + sentenceCount.get()); LOGGER.debug("?"); }
From source file:io.fabric8.maven.core.config.ProcessorConfig.java
private static Map<String, TreeMap> mergeConfig(ProcessorConfig... processorConfigs) { Map<String, TreeMap> ret = new HashMap<>(); if (processorConfigs.length > 0) { // Reverse iteration order so that earlier entries have a higher precedence for (int i = processorConfigs.length - 1; i >= 0; i--) { ProcessorConfig processorConfig = processorConfigs[i]; if (processorConfig != null) { Map<String, TreeMap> config = processorConfig.config; if (config != null) { for (Map.Entry<String, TreeMap> entry : config.entrySet()) { TreeMap newValues = entry.getValue(); if (newValues != null) { TreeMap existing = ret.get(entry.getKey()); if (existing == null) { ret.put(entry.getKey(), new TreeMap(newValues)); } else { for (Map.Entry newValue : (Set<Map.Entry>) newValues.entrySet()) { existing.put(newValue.getKey(), newValue.getValue()); }//from w w w .j a v a 2 s .c om } } } } } } } return ret.size() > 0 ? ret : null; }
From source file:com.netflix.discovery.shared.Applications.java
/** * Gets the reconciliation hashcode. The hashcode is used to determine whether the applications list * has changed since the last time it was acquired. * @param instanceCountMap the instance count map to use for generating the hash * @return the hash code for this instance *///from w ww .j a v a 2s . c om public static String getReconcileHashCode(TreeMap<String, AtomicInteger> instanceCountMap) { String reconcileHashCode = ""; for (Map.Entry<String, AtomicInteger> mapEntry : instanceCountMap.entrySet()) { reconcileHashCode = reconcileHashCode + mapEntry.getKey() + STATUS_DELIMITER + mapEntry.getValue().get() + STATUS_DELIMITER; } return reconcileHashCode; }
From source file:disko.DU.java
/** * Insert a set of strings at specified positions in the given text. A TreeMap is * used to ensure that the insert position are in increasing order. */// ww w. j a v a2 s.co m public static String insertStuff(String text, TreeMap<Integer, String> stuff) { int last = 0; StringBuffer result = new StringBuffer(); for (Map.Entry<Integer, String> e : stuff.entrySet()) { int pos = e.getKey(); System.out.println("Inserting text b/w " + last + " and " + pos); result.append(text.substring(last, pos)); result.append(e.getValue()); last = pos; } result.append(text.substring(last)); return result.toString(); }
From source file:acp.sdk.SDKUtil.java
/** * Map???Keyascii???key1=value1&key2=value2? ????signature * // ww w .ja v a 2 s . c o m * @param data * Map? * @return ? */ public static String coverMap2String(Map<String, String> data) { TreeMap<String, String> tree = new TreeMap<String, String>(); Iterator<Entry<String, String>> it = data.entrySet().iterator(); while (it.hasNext()) { Entry<String, String> en = it.next(); if (SDKConstants.param_signature.equals(en.getKey().trim())) { continue; } tree.put(en.getKey(), en.getValue()); } it = tree.entrySet().iterator(); StringBuffer sf = new StringBuffer(); while (it.hasNext()) { Entry<String, String> en = it.next(); sf.append(en.getKey() + SDKConstants.EQUAL + en.getValue() + SDKConstants.AMPERSAND); } return sf.substring(0, sf.length() - 1); }
From source file:com.boyuanitsm.pay.unionpay.util.SDKUtil.java
/** * Map???Keyascii???key1=value1&key2=value2? ????signature * /*from w ww . j a v a2s .c om*/ * @param data * Map? * @return ? */ public static String coverMap2String(Map<String, String> data) { TreeMap<String, String> tree = new TreeMap<String, String>(); Iterator<Entry<String, String>> it = data.entrySet().iterator(); while (it.hasNext()) { Entry<String, String> en = it.next(); if (SDKConstants.param_signature.equals(en.getKey().trim())) { continue; } tree.put(en.getKey(), en.getValue()); } it = tree.entrySet().iterator(); StringBuffer sf = new StringBuffer(); while (it.hasNext()) { Entry<String, String> en = it.next(); sf.append(en.getKey() + SDKConstants.EQUAL + en.getValue() + SDKConstants.AMPERSAND); } if (sf.length() == 0) { return ""; } return sf.substring(0, sf.length() - 1); }
From source file:io.fabric8.kit.enricher.api.EnrichersConfig.java
@SafeVarargs private static <P extends ProjectContext> Map<String, TreeMap<String, String>> mergeConfig( EnrichersConfig<P>... enrichersConfigs) { Map<String, TreeMap<String, String>> ret = new HashMap<>(); if (enrichersConfigs.length > 0) { // Reverse iteration order so that earlier entries have a higher precedence for (int i = enrichersConfigs.length - 1; i >= 0; i--) { EnrichersConfig<P> enrichersConfig = enrichersConfigs[i]; if (enrichersConfig != null) { if (enrichersConfig.config != null) { for (Map.Entry<String, TreeMap<String, String>> entry : enrichersConfig.config.entrySet()) { TreeMap<String, String> newValues = entry.getValue(); if (newValues != null) { TreeMap<String, String> existing = ret.get(entry.getKey()); if (existing == null) { ret.put(entry.getKey(), new TreeMap<>(newValues)); } else { for (Map.Entry<String, String> newValue : newValues.entrySet()) { existing.put(newValue.getKey(), newValue.getValue()); }//from w ww. ja v a 2s .c om } } } } } } } return ret.size() > 0 ? ret : null; }