List of usage examples for java.util SortedMap entrySet
Set<Map.Entry<K, V>> entrySet();
From source file:com.cilogi.aws.cart.SignRequests.java
/** * Make the query string canonical as required by Amazon. * /* w w w . ja va2s . c o m*/ * @param sortedParamMap Parameter name-value pairs in lexicographical order. * @return Canonical form of query string. */ private String makeCanonical(@NonNull SortedMap<String, String> sortedParamMap) { StringBuilder buffer = new StringBuilder(); Iterator<Map.Entry<String, String>> iter = sortedParamMap.entrySet().iterator(); while (iter.hasNext()) { Map.Entry<String, String> keyValuePair = iter.next(); buffer.append(percentEncodeRfc3986(keyValuePair.getKey())); buffer.append("="); buffer.append(percentEncodeRfc3986(keyValuePair.getValue())); if (iter.hasNext()) { buffer.append("&"); } } return buffer.toString(); }
From source file:org.kalypso.model.wspm.ewawi.utils.GewShape.java
public static GewShapeRow findRow(final Geometry geometry, final List<GewShapeRow> rows, final XyzEwawiLogger logger, final String category) { final SHP2JTS shp2jts = new SHP2JTS(geometry.getFactory()); /* Collect the distances, so if none intersects, we can use them to return the nearest. */ final SortedMap<Double, GewShapeRow> distances = new TreeMap<>(); /* Check, if intersecting. */ for (final GewShapeRow row : rows) { final ISHPGeometry shape = row.getShape(); final Geometry value = shp2jts.transform(shape); if (value == null) continue; if (value.intersects(geometry)) { System.out.println("Geometrie schneidet einen Gewsserabschnitt, dieser wird verwendet."); return row; }//ww w. j a v a 2s . co m final double distance = value.distance(geometry); distances.put(new Double(distance), row); } if (distances.size() == 0) { final String message = "Keine Gewsserabschnitte verfgbar."; System.out.println(message); if (logger != null) { final Point centroid = geometry.getCentroid(); logger.logXyzLine(centroid.getX(), centroid.getY(), -9999.0, message, category, -9999.0); } return null; } final Entry<Double, GewShapeRow> entry = distances.entrySet().iterator().next(); final Double key = entry.getKey(); final GewShapeRow value = entry.getValue(); final String message = String.format( "Geometrie schneidet keinen Gewsserabschnitt, nhester wird verwendet. Distanz: %f", key.doubleValue()); System.out.println(message); if (logger != null) { final Point centroid = geometry.getCentroid(); logger.logXyzLine(centroid.getX(), centroid.getY(), -9999.0, message, category, key.doubleValue()); } return value; }
From source file:org.geowebcache.storage.jdbc.metastore.JDBCMBIdCache.java
private String marshall(Map<String, String> parameters) { StringBuilder sb = new StringBuilder(); SortedMap<String, String> sorted = new TreeMap<String, String>(parameters); for (Map.Entry<String, String> e : sorted.entrySet()) { sb.append('&').append(e.getKey()).append('=').append(e.getValue()); }/* w w w.ja v a 2 s.c o m*/ return sb.toString(); }
From source file:com.github.fge.jsonschema.syntax.checkers.draftv3.DraftV3PropertiesSyntaxChecker.java
@Override protected void extraChecks(final ProcessingReport report, final SchemaTree tree) throws ProcessingException { final SortedMap<String, JsonNode> map = Maps.newTreeMap(); map.putAll(JacksonUtils.asMap(tree.getNode().get(keyword))); String member;// w w w. j a v a 2 s . c om JsonNode required; NodeType type; for (final Map.Entry<String, JsonNode> entry : map.entrySet()) { member = entry.getKey(); required = entry.getValue().get("required"); if (required == null) continue; type = NodeType.getNodeType(required); if (type != NodeType.BOOLEAN) { report.error(newMsg(tree, "draftv3PropertiesRequired").put("property", member) .put("expected", NodeType.BOOLEAN).put("found", type)); } } }
From source file:uk.q3c.krail.i18n.ClassBundleWriter.java
/** * Writes out the class as a sub-class of EnumResourceBundle. If bundleName is present, uses that as the class * name. If it is not present, uses the bundleName from the bundle's I18NKey. If there are no keys defined, uses * 'Unknown' as the class name//from ww w . j a v a 2s .c o m * * @param locale * @param bundleName * if present, use as the class name * * @throws IOException */ @Override public void write(Locale locale, Optional<String> bundleName) throws IOException { String bundleNameWithLocale = bundleNameWithLocale(locale, bundleName); StringBuilder buf = new StringBuilder(); buf.append("package ").append(pkg).append(";\n\n"); String indent = " "; String indent2 = indent + indent; List<Class<?>> imps = imports; for (Class<?> clazz : imps) { buf.append("import ").append(clazz.getName()).append(";\n"); } buf.append("\n"); buf.append("/**\n* ").append(classJavaDoc).append("\n*\n*/\n"); buf.append("public class ").append(bundleNameWithLocale).append(" extends ").append(genericSuperClass()) .append(" {\n\n"); buf.append(indent).append("@Override\n"); buf.append(indent).append("protected void loadMap() {\n"); //transfer to a TreeMap to sort by key SortedMap<String, String> sortedMap = new TreeMap<>(); entryMap.forEach((k, v) -> { sortedMap.put(k.name(), v); }); for (Map.Entry<String, String> entry : sortedMap.entrySet()) { buf.append(indent2).append("put(").append(keyClass.getSimpleName()).append(".").append(entry.getKey()) .append(", \"").append(entry.getValue()).append("\");\n"); } buf.append(indent).append("}\n"); buf.append("}\n"); File file = new File(getOptionWritePath(), bundleNameWithLocale + ".java"); FileUtils.writeStringToFile(file, buf.toString()); }
From source file:com.github.fge.jsonschema.core.keyword.syntax.checkers.draftv3.DraftV3PropertiesSyntaxChecker.java
@Override protected void extraChecks(final ProcessingReport report, final MessageBundle bundle, final SchemaTree tree) throws ProcessingException { final SortedMap<String, JsonNode> map = Maps.newTreeMap(); map.putAll(JacksonUtils.asMap(tree.getNode().get(keyword))); String member;// ww w.j av a2 s . c o m JsonNode required; NodeType type; for (final Map.Entry<String, JsonNode> entry : map.entrySet()) { member = entry.getKey(); required = entry.getValue().get("required"); if (required == null) continue; type = NodeType.getNodeType(required); if (type != NodeType.BOOLEAN) { report.error(newMsg(tree, bundle, "draftv3.properties.required.incorrectType") .putArgument("property", member).putArgument("found", type) .put("expected", NodeType.BOOLEAN)); } } }
From source file:ratpack.codahale.metrics.internal.WebSocketReporter.java
private void writeMeters(JsonGenerator json, SortedMap<String, Meter> meters) throws IOException { json.writeArrayFieldStart("meters"); for (Map.Entry<String, Meter> entry : meters.entrySet()) { Meter meter = entry.getValue();/* ww w . ja v a2s . com*/ json.writeStartObject(); json.writeStringField("name", entry.getKey()); json.writeNumberField("count", meter.getCount()); json.writeNumberField("meanRate", convertRate(meter.getMeanRate())); json.writeNumberField("oneMinuteRate", convertRate(meter.getOneMinuteRate())); json.writeNumberField("fiveMinuteRate", convertRate(meter.getFiveMinuteRate())); json.writeNumberField("fifteenMinuteRate", convertRate(meter.getFifteenMinuteRate())); json.writeEndObject(); } json.writeEndArray(); }
From source file:com.scraper.SignedRequestsHelper.java
private String canonicalize(SortedMap<String, String> sortedParamMap) { if (sortedParamMap.isEmpty()) { return ""; }/*from w ww . ja va2s. c o m*/ StringBuffer buffer = new StringBuffer(); Iterator<Map.Entry<String, String>> iter = sortedParamMap.entrySet().iterator(); while (iter.hasNext()) { Map.Entry<String, String> kvpair = iter.next(); buffer.append(percentEncodeRfc3986(kvpair.getKey())); buffer.append("="); buffer.append(percentEncodeRfc3986(kvpair.getValue())); if (iter.hasNext()) { buffer.append("&"); } } String canonical = buffer.toString(); return canonical; }
From source file:ratpack.codahale.metrics.internal.WebSocketReporter.java
private void writeCounters(JsonGenerator json, SortedMap<String, Counter> counters) throws IOException { json.writeArrayFieldStart("counters"); for (Map.Entry<String, Counter> entry : counters.entrySet()) { Counter counter = entry.getValue(); json.writeStartObject();/*from w ww . j av a 2s. co m*/ json.writeStringField("name", entry.getKey()); json.writeNumberField("count", counter.getCount()); json.writeEndObject(); } json.writeEndArray(); }
From source file:ratpack.codahale.metrics.internal.WebSocketReporter.java
@SuppressWarnings("rawtypes") private void writeGauges(JsonGenerator json, SortedMap<String, Gauge> gauges) throws IOException { json.writeArrayFieldStart("gauges"); for (Map.Entry<String, Gauge> entry : gauges.entrySet()) { Gauge gauge = entry.getValue();//from w w w . j ava 2 s . c om json.writeStartObject(); json.writeStringField("name", entry.getKey()); try { json.writeFieldName("value"); json.writeObject(gauge.getValue()); } catch (Exception e) { LOGGER.log(Level.FINE, "Exception encountered while reporting [" + entry.getKey() + "]: " + e.getLocalizedMessage()); json.writeNull(); } json.writeEndObject(); } json.writeEndArray(); }